/[mplayer-eee-tv]/program/xmltv.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /program/xmltv.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 20 - (hide annotations)
Sat Oct 31 13:53:52 2009 UTC (14 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1906 byte(s)
make blank slots blank

1 dpavlin 18 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use XML::Simple;
7     use Data::Dump qw(dump);
8    
9     my $tv = XMLin( 'tv.xml',
10     ContentKey => '-content',
11     );
12    
13     warn dump $tv;
14    
15     print qq|
16 dpavlin 19 <html>
17     <head>
18     <meta charset=utf-8>
19 dpavlin 18
20     <style type="text/css">
21    
22     ,hour {
23     border-top: 1px dashed #ccc;
24     }
25    
26 dpavlin 19 .hhmm {
27     font-size: 50%;
28     color: #888;
29     float: right;
30     }
31    
32 dpavlin 18 </style>
33    
34 dpavlin 19 </head>
35     <body>
36    
37 dpavlin 18 <table border=1 >
38     <tr><td></td>
39     |;
40    
41     my @channels = keys %{ $tv->{channel} };
42     warn "# channels ",dump @channels;
43    
44     print qq|<th><img src="|, $_->{'icon'}->{'src'}, qq|"><br>|, $_->{'display-name'}->{'content'}, qq|</th>| foreach map { $tv->{channel}->{$_} } @channels;
45    
46     print qq|
47     </tr>
48     |;
49    
50     my $programs;
51    
52     sub hh { substr $_[0], 8, 2 }
53     sub mm { substr $_[0], 10, 2 }
54    
55     sub in_mins { hh($_[0]) * 60 + mm($_[0]) }
56    
57     foreach my $p ( @{ $tv->{programme} } ) {
58     warn "# p ",dump $p;
59     my $t_start = in_mins $p->{start};
60     my $t_stop = in_mins $p->{stop};
61    
62     warn "# t $t_start - $t_stop\n";
63     if ( ! defined $programs->{ $p->{channel} } ) {
64     push @{ $programs->{ $p->{channel} } }, [ 0, $t_start ];
65     }
66     push @{ $programs->{ $p->{channel} } }, [ $t_start, $t_stop - $t_start, $p ];
67     }
68    
69     warn "# programs ", dump $programs;
70    
71     foreach my $hh ( 0 .. 23 ) {
72     foreach my $mm ( 0 .. 59 ) {
73    
74     my $hhmm = sprintf '%02d:%02d', $hh, $mm;
75    
76     print "<!-- $hh$mm -->\n";
77    
78     my @td;
79    
80     foreach my $c ( @channels ) {
81     if ( $programs->{$c}->[0]->[0] == $hh * 60 + $mm ) {
82     my $p = shift @{ $programs->{$c} };
83 dpavlin 19 my $span = $p->[1]; # - 1;
84 dpavlin 20
85     my $html = '';
86     $html = join("\n"
87     , qq|<span class="hhmm">$hhmm<br>$span</span>|
88     , $p->[2]->{title}->{content}
89     , "<!-- $c -->"
90     ) if $p->[2];
91    
92     push @td, qq|<td rowspan=$span>$html</td>|;
93 dpavlin 18 }
94     }
95    
96     my ($th,$class) = ('','');
97     ($th,$class) = ( "<th rowspan=60>$hh</th>", ' class="hour"' ) if $mm == 0;
98     print qq|<tr$class>$th|, join('', @td), qq|</tr>\n|;
99     }
100     }
101    
102     print qq|
103     </table>
104 dpavlin 19
105     </body>
106    
107     </html>
108 dpavlin 18 |;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26