/[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

Contents of /program/xmltv.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (show annotations)
Sat Oct 31 14:35:51 2009 UTC (14 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1961 byte(s)
align cells to top
1 #!/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 <html>
17 <head>
18 <meta charset=utf-8>
19
20 <style type="text/css">
21
22 td {
23 font-family:sans-serif;
24 vertical-align: top;
25 }
26
27 ,hour {
28 border-top: 1px dashed #ccc;
29 }
30
31 .hhmm {
32 font-size: 50%;
33 color: #888;
34 float: right;
35 }
36
37 </style>
38
39 </head>
40 <body>
41
42 <table border=1 >
43 <tr><td></td>
44 |;
45
46 my @channels = keys %{ $tv->{channel} };
47 warn "# channels ",dump @channels;
48
49 print qq|<th><img src="|, $_->{'icon'}->{'src'}, qq|"><br>|, $_->{'display-name'}->{'content'}, qq|</th>| foreach map { $tv->{channel}->{$_} } @channels;
50
51 print qq|
52 </tr>
53 |;
54
55 my $programs;
56
57 sub hh { substr $_[0], 8, 2 }
58 sub mm { substr $_[0], 10, 2 }
59
60 sub in_mins { hh($_[0]) * 60 + mm($_[0]) }
61
62 foreach my $p ( @{ $tv->{programme} } ) {
63 warn "# p ",dump $p;
64 my $t_start = in_mins $p->{start};
65 my $t_stop = in_mins $p->{stop};
66
67 warn "# t $t_start - $t_stop\n";
68 if ( ! defined $programs->{ $p->{channel} } ) {
69 push @{ $programs->{ $p->{channel} } }, [ 0, $t_start ];
70 }
71 push @{ $programs->{ $p->{channel} } }, [ $t_start, $t_stop - $t_start, $p ];
72 }
73
74 warn "# programs ", dump $programs;
75
76 foreach my $hh ( 0 .. 23 ) {
77 foreach my $mm ( 0 .. 59 ) {
78
79 my $hhmm = sprintf '%02d:%02d', $hh, $mm;
80
81 print "<!-- $hh$mm -->\n";
82
83 my @td;
84
85 foreach my $c ( @channels ) {
86 if ( $programs->{$c}->[0]->[0] == $hh * 60 + $mm ) {
87 my $p = shift @{ $programs->{$c} };
88 my $span = $p->[1]; # - 1;
89
90 my $html = '';
91 $html = join("\n"
92 , qq|<span class="hhmm">$hhmm<br>$span</span>|
93 , $p->[2]->{title}->{content}
94 , "<!-- $c -->"
95 ) if $p->[2];
96
97 push @td, qq|<td rowspan=$span>$html</td>|;
98 }
99 }
100
101 my ($th,$class) = ('','');
102 ($th,$class) = ( "<th rowspan=60>$hh</th>", ' class="hour"' ) if $mm == 0;
103 print qq|<tr$class>$th|, join('', @td), qq|</tr>\n|;
104 }
105 }
106
107 print qq|
108 </table>
109
110 </body>
111
112 </html>
113 |;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26