From a6138160501bf5c1bf42c5f16c6d0333d7b31e9d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 4 Dec 2011 14:36:37 +0100 Subject: Removed the '.pl' suffix from all scripts --- epg2html | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 epg2html (limited to 'epg2html') diff --git a/epg2html b/epg2html new file mode 100755 index 00000000..8b9e7b1f --- /dev/null +++ b/epg2html @@ -0,0 +1,97 @@ +#!/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 < /video/epg.data +# +# See the main source file 'vdr.c' for copyright information and +# how to reach the author. +# +# $Id: epg2html 2.1 2011/12/04 14:17:35 kls Exp $ + +@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; + return $s; +} + +while (<>) { + chomp; + if (/^C ([^ ]+) *(.*)/) { + my $Channel = $2; + (my $Page = $Channel) =~ y/\/ /-_/; + $Page .= ".htm"; + $Channel = Tags($Channel); + push(@Index, qq{$Channel
\n}); + my %Events = (); + while (<>) { + if (/^E (.*?) (.*?) ([^ ]*)/) { + (my $Time, $Duration) = ($2, $3); + my $Title = "", $Subtitle = "", $Description = "", $Vps = 0; + while (<>) { + if (/^T (.*)/) { $Title = Tags($1); } + elsif (/^S (.*)/) { $Subtitle = Tags($1); } + elsif (/^D (.*)/) { $Description = Tags($1); $Description =~ s/\|/
/g; } + elsif (/^V (.*)/) { $Vps = $1; } + elsif (/^e/) { + $Events{$Time} = [($Duration, $Title, $Subtitle, $Description, $Vps)]; + last; + } + } + } + elsif (/^c/) { + my @Schedule = (); + my $Day = ""; + for $t (sort keys %Events) { + (my $Duration, $Title, $Subtitle, $Description, $Vps) = @{$Events{$t}}; + my $d = GetDay($t); + if ($d ne $Day) { + push(@Schedule, "\n") if ($Day && @Schedule); + push(@Schedule, "

$d

\n"); + push(@Schedule, "\n"); + $Day = $d; + } + my $Entry = $Title; + $Entry .= "
$Subtitle" if $Subtitle; + $Entry .= "
$Description" if $Description; + $Entry .= "
(VPS = " . scalar localtime($Vps) . ")" if $Vps && $Vps != $t; + push(@Schedule, "\n"); + } + push(@Schedule, "
" . GetTime($t) . "$Entry
\n") if (@Schedule); + open(PAGE, ">$Page") or die "$Page: $!\n"; + print PAGE "\n$Channel\n\n"; + print PAGE "

$Channel

\n"; + print PAGE @Schedule; + print PAGE "\n\n"; + close(PAGE); + last; + } + } + } + } + +open(INDEX, ">index.htm") or die "index.htm: $!\n"; +print INDEX "\nEPG Index\n\n"; +print INDEX sort { lc($a) cmp lc($b) } @Index; +print INDEX "\n\n"; +close(INDEX); -- cgit v1.2.3