ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Video-Capture-V4l/examples/dumpepg
Revision: 1.1
Committed: Fri May 5 20:21:53 2000 UTC (24 years ago) by pcg
Branch: MAIN
CVS Tags: rel-0_9, rel-0_902, HEAD
Log Message:
Initial check-in

File Contents

# Content
1 #!/usr/bin/perl
2
3 # dumpepg dumps the epg database given as first argument run "getepg" to
4 # create it.
5
6 use Storable;
7 use POSIX 'strftime';
8
9 my $db_name = $ARGV[0];
10 $db_name .= ".epg" unless -e $db_name;
11
12 print "Electronic Program Guide <$db_name>\n\n";
13
14 *db = Storable::retrieve($db_name);
15
16 sub dump_ai {
17 my $ai = shift;
18 printf "EPG STREAM 1 <%d>", $ai->{epg_version};
19 printf " #ni %d, #oi %d, #mi %d\n", $ai->{no_navigation}, $ai->{no_osd}, $ai->{no_message};
20 printf "EPG STREAM 2 <%d>", $ai->{epg_version_swo};
21 printf " #ni %d, #oi %d, #mi %d\n", $ai->{no_navigation_swo}, $ai->{no_osd_swo}, $ai->{no_message_swo};
22
23 printf "this network #%d (%s) # updates %d\n", $ai->{this_network_op}, $ai->{service_name}, $ai->{no_updates};
24 for (@{$ai->{networks}}) {
25 printf " network #%04x (%s), LTO %d, %d days, range<%d-%d/%d>, @%d, +%03x\n",
26 @$_{qw/cni netwop_name LTO nodays prog_start_no prog_stop_no prog_stop_swo default_alphabet network_add_info/};
27 }
28 print "\n";
29 }
30
31 sub string2text {
32 local $_ = shift;
33 y/~{|}[]/ßaöäüÄÜ/;
34 s/(.{40})/$1\n/g;
35 s/([\x00-\x07])/sprintf " [%dm", ord($1)+30/ge;
36 s/([\x00-\x09\x0b-\x1a\x1c-\x1f])/sprintf "·[%02x]",ord $1/ge;
37 s/^ //g;
38 $_."";
39 }
40
41 sub date2unix {
42 my($date,$time,$lto)=@_;
43 381283200
44 + ($date-45000) * 86400
45 + ($time >> 12 ) * 10 * 60 * 60
46 + ($time >> 8 & 15) * 60 * 60
47 + ($time >> 4 & 15) * 10 * 60
48 + ($time & 15) * 60
49 + $lto * 15;
50 }
51
52 sub date2text {
53 sprintf "{%04x}", $_[0];
54 }
55
56 sub time2text {
57 sprintf "%02x:%02x", $_[0] >> 8, $_[0] & 0xff;
58 }
59
60 dump_ai($db{ai});
61
62 my @pi = map values %$_, values %{$db{pi}};
63
64 printf "Dump of %d program information structures\n\n", 1*@pi;
65
66 for (sort { $a->{start_date} <=> $b->{start_date} ||
67 $a->{start_time} <=> $b->{start_time} ||
68 $a->{netwop_no} <=> $b->{netwop_no} } @pi) {
69 my $ti = string2text($_->{title});
70
71 my $start = date2unix($_->{start_date}, $_->{start_time}, $db{ai}{networks}[$_->{netwop_no}]{LTO});
72 my $stop = date2unix($_->{start_date}, $_->{stop_time }, $db{ai}{networks}[$_->{netwop_no}]{LTO});
73 $stop += 86400 if $stop < $start;
74
75 printf "PI #%d (%s) %s - %s \"%s\"\n", $_->{block_no}, $db{ai}{networks}[$_->{netwop_no}]{netwop_name},
76 strftime("%A %Y-%m-%d %H:%M", localtime $start), strftime("%H:%M", localtime $stop),
77 $ti;
78 my $si = string2text($_->{shortinfo}); $si =~ s/^/ /gm; print $si,"\n";
79 my $si = string2text($_->{longinfo}); $si =~ s/^/ /gm; print " =>",$si,"\n";
80 print " FLAGS <";
81 printf " editorial rating %d", $_->{editoral_rating} if $_->{editoral_rating}>0;
82 printf " parental rating %d", $_->{parental_rating} if $_->{parental_rating}>0;
83 print " Mono" if $_->{audio_flags}==0;
84 print " 2 Channel" if $_->{audio_flags}==1;
85 print " Stereo" if $_->{audio_flags}==2;
86 print " Surround" if $_->{audio_flags}==3;
87 print " Widescreen" if $_->{feature_flags}&4;
88 print " PAL+" if $_->{feature_flags}&8;
89 print " Digital" if $_->{feature_flags}&16;
90 print " Encrypted" if $_->{feature_flags}&32;
91 print " Live" if $_->{feature_flags}&64;
92 print " Repeated" if $_->{feature_flags}&128;
93 print " Subtitled" if $_->{feature_flags}&256;
94 print " >\n";
95 print "\n";
96 }