Changeset 481
- Timestamp:
- 02/01/07 15:29:27 (6 years ago)
- Files:
-
- 3 modified
-
grabbers/rex (modified) (16 diffs)
-
grabbers/rex.conf (modified) (1 diff)
-
status (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
grabbers/rex
r423 r481 3 3 # "Rex" 4 4 5 my $version = '3. 3.9';5 my $version = '3.4.0'; 6 6 7 7 # An Australian TV Guide Grabber (a.k.a. tv_grab_au) … … 71 71 # 3.3.8 : Bugfix : better handling of failed downloads & parses 72 72 # 3.3.9 : Bugfix : more descriptive dies 73 # 3.4.0 : Feature: micrograbbing (--gaps_file) 73 74 74 75 use strict; … … 83 84 use JavaScript; 84 85 use Storable; 85 use Cwd;86 use POSIX; 86 87 87 88 use XMLTV; … … 110 111 my $channels = {}; 111 112 my $opt_channels = {}; 113 my $gaps; 112 114 my %chanid; 113 115 my $cached; 116 my $lastpids; 114 117 my $precache; 115 118 my $ua; … … 140 143 141 144 read_channels_file(); 145 read_gaps_file(); 142 146 143 147 if ($opt->{test}) … … 407 411 if ($ua) 408 412 { 413 print stats() if ($debug and $opt->{stats}); 409 414 print "Sleeping...\n" if ($debug); 410 415 sleep 5 + int(rand(20)); … … 652 657 if ($start) 653 658 { 654 addme($pid, $title, $start, $pextra );659 addme($pid, $title, $start, $pextra, $curchan); 655 660 $pextra = undef; 656 661 $title = undef; … … 682 687 if ($pid) 683 688 { 684 addme($pid, $title, $start, $pextra );689 addme($pid, $title, $start, $pextra, $curchan); 685 690 } 686 691 else … … 695 700 sub addme 696 701 { 697 my ($pid, $title, $start, $pextra ) = @_;702 my ($pid, $title, $start, $pextra, $curchan) = @_; 698 703 699 704 if ($precache->{$pid}) … … 714 719 'sub-title' => $pextra 715 720 }; 721 my $lastpid = $lastpids->{$curchan}; 722 if ($lastpid) 723 { 724 $precache->{$lastpid}->{stop} = $start; 725 if ($start < $precache->{$lastpid}->{start}) 726 { 727 die "Logical error in stop time processing: pid $pid"; 728 } 729 if ($gaps) 730 { 731 if (is_outside_gaps($curchan, $precache->{$lastpid}->{start}, $precache->{$lastpid}->{stop})) 732 { 733 delete $precache->{$lastpid}; 734 } 735 } 736 } 737 $lastpids->{$curchan} = $pid; 716 738 } 717 739 } … … 903 925 } 904 926 927 sub is_outside_gaps 928 { 929 my ($ch, $start, $stop) = @_; 930 931 $start = udate_to_epoch($start); 932 $stop = udate_to_epoch($stop); 933 934 print "Gap check: $start to $stop vs:\n"; 935 foreach my $gap (@{$gaps->{$ch}}) 936 { 937 if ($gap =~ /(\d+)-(\d+)/) 938 { 939 print " - $1 - $2\n"; 940 return 0 if ($stop > $1 and $start < $2); 941 } 942 } 943 return 1; 944 } 945 946 sub udate_to_epoch 947 { 948 my $udate = shift; 949 950 if ($udate =~ /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/) 951 { 952 my ($year, $month, $day, $hour, $minute, $second) = ($1, $2, $3, $4, $5, $6); 953 $month--; 954 $year -= 1900; 955 return POSIX::strftime("%s", $second, $minute, $hour, $day, $month, $year); 956 } 957 die "Unable to parse udate $udate!"; 958 } 959 905 960 sub readjs { 906 961 my $data = shift; … … 915 970 916 971 sub read_channels_file 917 { 918 print "Reading channels file: $opt->{channels_file}\n"; 919 if (-r $opt->{channels_file}) 920 { 921 local (@ARGV, $/) = ($opt->{channels_file}); 972 { 973 read_config_file('channels', 'channels_file'); 974 } 975 976 sub read_gaps_file 977 { 978 read_config_file('gaps', 'gaps_file'); 979 # foreach my $ch (keys %$gaps) 980 # { 981 # foreach my $gap (@{$gaps->{$ch}}) 982 # { 983 # if ($gap =~ /(\d+)-(\d+)/) 984 # { 985 # my ($start, $end) = ($1, $2); 986 # $gap = epoch 987 988 989 } 990 991 sub read_config_file 992 { 993 my ($name, $arg) = @_; 994 995 return unless ($opt->{$arg}); 996 print "Reading $name file: $opt->{$arg}\n"; 997 if (-r $opt->{$arg}) 998 { 999 local (@ARGV, $/) = ($opt->{$arg}); 922 1000 no warnings 'all'; 923 1001 eval <>; 924 die "Can't parse channelsfile: $@" if ($@);1002 die "Can't parse $name file: $@" if ($@); 925 1003 } 926 1004 else 927 1005 { 928 print "Unable to read configfile.\n";1006 print "Unable to read $name file.\n"; 929 1007 } 930 1008 } … … 948 1026 config-file=s 949 1027 channels_file=s 1028 gaps_file=s 950 1029 stats=i 951 1030 test … … 980 1059 "Output file: " . ($opt->{output} ? $opt->{output} : "None") . "\n" . 981 1060 "Chann file : $opt->{channels_file}\n" . 1061 ($opt->{gaps_file} ? "Gaps file : " . $opt->{gaps_file} . "\n" : '') . 982 1062 "Statistics : " . ($opt->{stats} ? "every " . $opt->{stats} . " seconds" : "off") . "\n"; 983 1063 } … … 1014 1094 'region' => 94, 1015 1095 'stats' => 300, 1016 'output' => cwd() . '/output.xmltv',1017 'cache-file' => cwd() . '/cache.dat',1018 'channels_file' => cwd() . '/channels.conf'1096 'output' => getcwd() . '/output.xmltv', 1097 'cache-file' => getcwd() . '/cache.dat', 1098 'channels_file' => getcwd() . '/channels.conf' 1019 1099 }; 1020 1100 … … 1066 1146 --output <file> Write XML into the specified file 1067 1147 --channels_file <file> Read channel subscriptions from file 1148 --gaps_file <file> Read gaps from file 1068 1149 1069 1150 --region <n> Grab data for region code <n> -
grabbers/rex.conf
r453 r481 15 15 }, 16 16 'max_runtime' => '240', 17 'option_days' => '--days' 17 'option_days' => '--days', 18 'micrograbs' => 1 18 19 }; -
status
r480 r481 1 1 application shepherd 0.4.39 2 2 grabber yahoo7widget 1.77 3 grabber rex 3. 3.9-r13 grabber rex 3.4.0 4 4 grabber abc_website 2.05 5 5 grabber abc2_website 2.05
