2000-11-26 15:23:39 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
# A simple EPG to HTML converter
|
|
|
|
#
|
|
|
|
# Converts the EPG data written by 'vdr' into the file /video/epg.data
|
|
|
|
# into a simple HTML programme listing, consisting of one file per channel
|
|
|
|
# plus an 'index.htm' file. All output files are written into the current
|
|
|
|
# directory.
|
|
|
|
#
|
|
|
|
# Usage: epg2html.pl < /video/epg.data
|
|
|
|
#
|
|
|
|
# See the main source file 'vdr.c' for copyright information and
|
|
|
|
# how to reach the author.
|
|
|
|
#
|
2004-03-28 11:16:17 +02:00
|
|
|
# $Id: epg2html.pl 1.6 2004/03/28 11:15:01 kls Exp $
|
2000-11-26 15:23:39 +01:00
|
|
|
|
|
|
|
@Index = ();
|
|
|
|
|
|
|
|
sub GetDay
|
|
|
|
{
|
|
|
|
return substr(localtime(shift), 0, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub GetTime
|
|
|
|
{
|
|
|
|
return substr(localtime(shift), 11, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub Tags
|
|
|
|
{
|
|
|
|
my $s = shift;
|
|
|
|
$s =~ s/\&/&/g;
|
|
|
|
$s =~ s/</</g;
|
|
|
|
$s =~ s/>/>/g;
|
|
|
|
return $s;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
chomp;
|
|
|
|
if (/^C ([^ ]+) *(.*)/) {
|
|
|
|
my $Channel = $2;
|
2000-12-01 18:37:46 +01:00
|
|
|
(my $Page = $Channel) =~ y/\/ /-_/;
|
|
|
|
$Page .= ".htm";
|
2000-11-26 15:23:39 +01:00
|
|
|
$Channel = Tags($Channel);
|
2000-12-01 18:37:46 +01:00
|
|
|
push(@Index, qq{<a href="$Page">$Channel</a><br>\n});
|
2000-11-26 15:23:39 +01:00
|
|
|
my %Events = ();
|
|
|
|
while (<>) {
|
2002-05-30 09:50:19 +02:00
|
|
|
if (/^E (.*?) (.*?) ([^ ]*)/) {
|
2000-11-26 15:23:39 +01:00
|
|
|
(my $Time, $Duration) = ($2, $3);
|
2004-02-22 13:33:20 +01:00
|
|
|
my $Title = "", $Subtitle = "", $Description = "", $Vps = 0;
|
2000-11-26 15:23:39 +01:00
|
|
|
while (<>) {
|
|
|
|
if (/^T (.*)/) { $Title = Tags($1); }
|
|
|
|
elsif (/^S (.*)/) { $Subtitle = Tags($1); }
|
2004-03-28 11:16:17 +02:00
|
|
|
elsif (/^D (.*)/) { $Description = Tags($1); $Description =~ s/\|/<br>/g; }
|
2004-02-22 13:33:20 +01:00
|
|
|
elsif (/^V (.*)/) { $Vps = $1; }
|
2000-11-26 15:23:39 +01:00
|
|
|
elsif (/^e/) {
|
2004-02-22 13:33:20 +01:00
|
|
|
$Events{$Time} = [($Duration, $Title, $Subtitle, $Description, $Vps)];
|
2000-11-26 15:23:39 +01:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif (/^c/) {
|
|
|
|
my @Schedule = ();
|
|
|
|
my $Day = "";
|
|
|
|
for $t (sort keys %Events) {
|
2004-02-22 13:33:20 +01:00
|
|
|
(my $Duration, $Title, $Subtitle, $Description, $Vps) = @{$Events{$t}};
|
2000-11-26 15:23:39 +01:00
|
|
|
my $d = GetDay($t);
|
|
|
|
if ($d ne $Day) {
|
|
|
|
push(@Schedule, "</table>\n") if ($Day && @Schedule);
|
|
|
|
push(@Schedule, "<h2>$d</h2>\n");
|
|
|
|
push(@Schedule, "<table cellspacing=2>\n");
|
|
|
|
$Day = $d;
|
|
|
|
}
|
|
|
|
my $Entry = $Title;
|
|
|
|
$Entry .= "<br><i>$Subtitle</i>" if $Subtitle;
|
|
|
|
$Entry .= "<br>$Description" if $Description;
|
2004-02-22 13:33:20 +01:00
|
|
|
$Entry .= "<br>(VPS = " . scalar localtime($Vps) . ")" if $Vps && $Vps != $t;
|
2000-11-26 15:23:39 +01:00
|
|
|
push(@Schedule, "<tr><td valign=top>" . GetTime($t) . "</td><td>$Entry</td></tr>\n");
|
|
|
|
}
|
|
|
|
push(@Schedule, "</table>\n") if (@Schedule);
|
2000-12-01 18:37:46 +01:00
|
|
|
open(PAGE, ">$Page") or die "$Page: $!\n";
|
2000-11-26 15:23:39 +01:00
|
|
|
print PAGE "<html>\n<head><title>$Channel</title><head>\n<body>\n";
|
|
|
|
print PAGE "<h1>$Channel</h1>\n";
|
|
|
|
print PAGE @Schedule;
|
|
|
|
print PAGE "</body>\n</html>\n";
|
|
|
|
close(PAGE);
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-01 18:37:46 +01:00
|
|
|
open(INDEX, ">index.htm") or die "index.htm: $!\n";
|
2000-11-26 15:23:39 +01:00
|
|
|
print INDEX "<html>\n<head><title>EPG Index</title><head>\n<body>\n";
|
|
|
|
print INDEX sort { lc($a) cmp lc($b) } @Index;
|
|
|
|
print INDEX "</body>\n</html>\n";
|
|
|
|
close(INDEX);
|
|
|
|
|