###RUN_PERL: #!/usr/bin/perl

# updlist.pl is generated from updlist.1.pl.
#
# The framelist update bot
#
# Copyright (C) 2016, 2017, 2023  Balthasar Szczepański
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use strict;
#use warnings;
###PERL_LIB: use lib /botm/lib/bsta
use bsta_lib qw(readdatafile writedatafile);
use File::Copy;

###PERL_DATA_PATH:      DATA_PATH      = /botm/data/bsta/
###PERL_DATA_LIST_PATH: DATA_LIST_PATH = /botm/data/bsta/list

my %framedata;
my %gotolist;

my $frame;

%gotolist=readdatafile(DATA_LIST_PATH);

for($frame=0; ; ++$frame) {
	%framedata=readdatafile(DATA_PATH.$frame);
	if($framedata{'ongtime'} eq '') {
		last;
	}
	
	print $frame.' '.$framedata{'ongtime'}.' '.$framedata{'title'}."\n";
	
	$gotolist{'title-'.$frame}=$framedata{'title'};
	$gotolist{'ongtime-'.$frame}=$framedata{'ongtime'};
}

writedatafile (DATA_LIST_PATH,%gotolist);
