6 use lib
"$FindBin::Bin/../../lib";
8 use NonameTV
::Factory qw
/CreateDataStore/;
12 # How large an empty xmltv-file can be.
13 use constant EMPTY_SIZE
=> 140;
15 if( scalar( @ARGV ) != 2 )
18 nonametv
-xmltv
-genhtml
<outputdir
> <installationdir
>
20 Generate a table with data
for each day
and channel
. The
.xml
.gz
-files
21 should be located
in <dir
> and the table will be written to
24 <installationdir
> should be the basedir
for a nonametv installation
.
26 Furthermore
, the program generates a file
00logos
.html that contains
27 a list of all channels
and shows their logos
.
29 If the result of nonametv
-xmltv
-genhtml is identical to the previous
30 content of
00index.html
, the original file will be left untouched
.
37 my( $dir, $installdir ) = @ARGV;
39 my $ds = CreateDataStore
();
44 foreach my $file ( glob("$dir/*.xml.gz") )
46 my( $name ) = ($file =~ m
%/([^/]+_\d
{4}-\d
{2}-\d
{2}).xml
.gz
%);
47 $files{$name} = "X" if defined $name;
50 foreach my $file (keys %files)
52 if( -s
( "$dir/$file.xml.gz" ) < EMPTY_SIZE
)
63 my $ch = $ds->sa->LookupMany( "channels", { export
=> 1 }, ['xmltvid'] );
65 foreach my $c (@
{$ch}) {
66 push @channels, $c->{xmltvid
};
69 foreach my $file (keys %files)
71 my( $channel, $date ) = split( "_", $file );
75 open OUT
, "> $dir/00index.html.new"
76 or die "Failed to open output file: $@";
78 print OUT
<< "EOHEAD";
81 <style type
="text/css">
82 .X
{ text
-align
: center
; }
83 .E
{ text
-align
: center
; background
-color
: grey
; }
94 foreach my $date (sort keys %dates)
96 my( $s ) = ($date =~ m/(\d\d-\d\d)$/);
97 print OUT
" <td>$s</td>\n";
107 foreach my $channel (@channels)
115 foreach my $date (sort keys %dates)
117 my $file = "${channel}_$date";
118 $files{$file} = ' ' unless defined $files{$file};
120 if( $files{$file} eq 'U' )
122 print OUT
"<td class='$files{$file}'><a href='$file.diff'>$files{$file}</a></td>";
126 print OUT
"<td class='$files{$file}'><a href='displayfile.html?$file'>$files{$file}</a></td>";
144 update_if_changed
( "$dir/00index.html.new", "$dir/00index.html" );
146 open OUT
, "> $dir/00logos.html.new"
147 or die "Failed to open output file: $@";
149 print OUT
<< "EOHEAD";
153 <script language
="JavaScript">
154 function changeBg
(col
)
156 document
.bgColor
= col
;
165 <a href
="javascript:changeBg('#ffffff')">White
</a
>
166 <a href
="javascript:changeBg('#dddddd')">Light grey
</a
>
167 <a href
="javascript:changeBg('#333333')">Dark grey
</a
>
168 <a href
="javascript:changeBg('#000000')">Black
</a
>
169 <a href
="javascript:changeBg('#0000dd')">Dark blue
</a
>
175 foreach my $channel (@channels)
177 print OUT
<< "EOREC";
180 <td
><img src
="http://xmltv.spaetfruehstuecken.org/chanlogos/$channel.png"></td
>
181 <td
><img src
="http://xmltv.spaetfruehstuecken.org/chanlogos/44x44/$channel.png"></td
>
182 <td
><img src
="http://xmltv.spaetfruehstuecken.org/chanlogos/16x16/$channel.png"></td
>
189 print OUT
<< "EOFOOT";
198 update_if_changed
( "$dir/00logos.html.new", "$dir/00logos.html" );
200 system( "zcat $dir/channels.xml.gz | xsltproc $installdir/examples/channel-list.xsl - > $dir/channels.html.new" );
202 update_if_changed
( "$dir/channels.html.new", "$dir/channels.html" );
204 sub update_if_changed
{
205 my( $new, $old ) = @_;
207 system("diff $new $old > /dev/null 2>&1");
209 move
( "$new", "$old" );