diff -Nur tvlisting-2.0.0b7/MANIFEST tvlisting/MANIFEST --- tvlisting-2.0.0b7/MANIFEST Sat Mar 16 11:47:18 2002 +++ tvlisting/MANIFEST Wed Mar 20 23:53:51 2002 @@ -13,5 +13,6 @@ lib/TVListing/TVGuide.pm lib/TVListing/TVListing.pm lib/TVListing/Text.pm +lib/TVListing/Xawtv.pm sample_rc t/tvlisting.t diff -Nur tvlisting-2.0.0b7/bin/tvlisting tvlisting/bin/tvlisting --- tvlisting-2.0.0b7/bin/tvlisting Sat Mar 16 12:33:46 2002 +++ tvlisting/bin/tvlisting Thu Mar 21 02:48:27 2002 @@ -66,6 +66,7 @@ Text => [ 1.1, qw(OUTPUT) ], LaTeX => [ 1.0, qw(OUTPUT) ], CGI_HTML => [ 1.0, qw(OUTPUT) ], + Xawtv => [ 1.0, qw(OUTPUT) ], ); # Any variable that might be in a 'configuration' file must use 'our'. @@ -143,6 +144,9 @@ # Foreground, Info/Date, Times, Channels, Fav. TEXT_COLORS => [ "white", "red", "green", "yellow", "blue" ], + ### XAWTV OUTPUT OPTIONS + XAWTV_HEAD_FILE => "$ENV{HOME}/.tvlisting-xawtv", # Header file for .xawtv + ### DEBUGGING USE_WEB => $TRUE, LOCAL_FILENAME => \"listing.html", @@ -371,6 +375,8 @@ $options{TIME_OFFSET} = $_[1] if $_[1] < 61 }, "version" => \&version, + "xawtv" => sub { $options{KEEP_CHANNEL_NUMBER} = 1; $options{OUTPUT_FORMAT} = qw(XAWTV) }, + "xawtvhead=s" => sub { $options{XAWTV_HEAD_FILE} = $_[1] }, ); my %help_debug_options = ( diff -Nur tvlisting-2.0.0b7/lib/TVListing/TVListing.pm tvlisting/lib/TVListing/TVListing.pm --- tvlisting-2.0.0b7/lib/TVListing/TVListing.pm Sat Mar 16 11:57:19 2002 +++ tvlisting/lib/TVListing/TVListing.pm Wed Mar 20 23:51:02 2002 @@ -390,6 +390,8 @@ $output = TVListing::HTML->new(); } elsif ( $out =~ /text/i ) { $output = TVListing::Text->new(); + } elsif ( $out =~ /xawtv/i ) { + $output = TVListing::Xawtv->new(); } else { die "\n *** No OUTPUT_FORMAT defined. ***\n\n"; } diff -Nur tvlisting-2.0.0b7/lib/TVListing/Xawtv.pm tvlisting/lib/TVListing/Xawtv.pm --- tvlisting-2.0.0b7/lib/TVListing/Xawtv.pm Wed Dec 31 19:00:00 1969 +++ tvlisting/lib/TVListing/Xawtv.pm Thu Mar 21 02:48:33 2002 @@ -0,0 +1,148 @@ +package TVListing::Xawtv; + +=head1 NAME + + TVListing::Xawtv - Outputs the TV listing in Xawtv format. + +=head1 SYNOPSIS + + This class is used by TVListing::TVListing.pm + + You likely don't want to call this class yourself. + +=head1 DESCRIPTION + + TVListing::Xawtv displays the TV listing obtained by the Perl script + 'tvlisting' in Xawtv .xawtv format. + +=head1 AUTHOR + + Kurt V. Hindenburg + Modified from TVListing::Text by Stu Tomlinson + +=head1 COPYRIGHT + + Copyright (C) 2002 Kurt Hindenburg + This program comes with NO WARRANTY, to the extent permitted by law. + This code is released under the BSD license (read LICENSE). + + +=head1 SEE ALSO + + perl, tvlisting + +=cut + +###################################################################### +# +# The original version of tvguide was by Clifford 'Buddy' Smith and +# was released under the BSD license. +# +###################################################################### +# +### +# +use strict; +require Exporter; + +our @ISA = qw(Exporter); +our @EXPORT = qw(); # This module is a class, no need to export anything. +our @EXPORT_OK = qw(); + +our $VERSION = 1.1; + +use vars qw(%options); + + +my ( $TRUE, $FALSE ) = ( 1, 0 ); + +sub new +{ + my $invocant = shift; + my $class = ref($invocant) || $invocant; # Object or class name + my $self = {}; + bless($self, $class); + return $self; +} + +sub init +{ + my $self = shift; + my $hash_ref = shift; + + %options = %$hash_ref; +# TODO check that --keepchannelnumber was set +# TODO check that only one of --filterchannels and --blankentries was specified +# TODO warn if USE_COLOR was set (to stderr) + +} + +sub help +{ +print << "EOH"; + Display TV listings in Xawtv format. + + --xawtv display TV listings in Xawtv format. +EOH +} + +sub display_xawtv_chan { + my $desc = shift; + my $cn = shift; + print "[ $desc ]\n"; + print "channel = $cn\n"; + print "\n\n"; +} +sub display_show_title +{ + my $chan_start = shift; + my $cn = shift; + my $cm = shift; + my $l = shift; + my $j = $chan_start+1; + if ( $options{FILTER_CHANNELS} == 0 ) { while ($j < $cn) { + display_xawtv_chan("$j - (Unknown)", $j); + $j++; + } + } + display_xawtv_chan("$cm - $l", $cn); + +} +# Parameters : "listing for", date, times (array ref), listing (array ref) +sub output +{ + my( $self, $l_lf, $l_date, $l_times_ref, $l_listing_ref ) = @_; + + my $previous = 0; + + # TODO output header stuff here!!!! + if ( -e $options{XAWTV_HEAD_FILE}) { + # dump from file + open(XTFILE, $options{XAWTV_HEAD_FILE}) or die "can't open $options{XAWTV_HEAD_FILE}: $!"; + print $_ while ; + close(XTFILE); + } else { + print STDERR "Warning: no such file $options{XAWTV_HEAD_FILE}\n"; + } + + # Traverse though actual listing + foreach my $c ( @$l_listing_ref ) { + my @items = split(/#/,$c); + my $i = 0; my $cn; my $cm; my $first; # $iterations++; + + $cn = $items[$i++] ; + $cm = $items[$i]; + $i++; + $first = $i; + + while ( $i < $#items ) { + if ( $i == $first) { display_show_title($previous, $cn, $cm, $items[$i+1]); } + $i++ if ($options{KEEP_DETAIL_NUMBER} == $TRUE); + $i = $i + 2; + } + $previous = $cn; + } + print "\n"; +} + +1;