Changeset 959

Show
Ignore:
Timestamp:
10/27/07 10:27:33 (6 years ago)
Author:
paul
Message:

yahoo7widget: fix times

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/grabbers/yahoo7widget

    r947 r959  
    2222 
    2323my $progname = "yahoo7widget"; 
    24 my $version = "1.93"; 
     24my $version = "1.94"; 
    2525 
    2626use XMLTV; 
     
    4343my $channels, my $opt_channels; 
    4444my $tv_guide; 
    45 my $time_offset = 0; 
    4645my $input_xml; 
    4746my $d; 
     
    6261        'days=i'        => \$opt->{days}, 
    6362        'offset=i'      => \$opt->{offset}, 
    64         'timezone=s'    => \$opt->{timezone}, 
    6563        'channels_file=s' => \$opt->{channels_file}, 
    6664        'cachefile=s' => \$opt->{obsolete}, 
     
    10098die "no channel file specified, see --help for instructions\n", unless (defined $opt->{channels_file}); 
    10199 
     100$ENV{TZ}="Australia/Melbourne"; # yahoo7widget times are always localtime on Eastern States .. 
     101 
    102102$opt->{days} = 8 if $opt->{days} > 8;   # no data beyond 8 days 
    103103 
     
    107107 
    108108# normalize starttime to an hour.. 
    109 my $starttime = time - $time_offset; 
     109my $starttime = $script_start_time; 
    110110my $endtime = $starttime + ($opt->{days} * 86400); 
    111111$starttime += (86400 * $opt->{offset}) if (defined $opt->{offset}); 
    112 &calculate_time_offset; 
    113  
    114 &log(sprintf "going to grab %d days%s of data into %s (%s%s) region %s, time offset %d", 
     112 
     113&log(sprintf "going to grab %d days%s of data into %s (%s%s) region %s", 
    115114        $opt->{days}, 
    116115        ($opt->{offset} ? " (skipping first $opt->{offset} days)" : ""), 
     
    118117        (defined $opt->{fast} ? "with haste" : "slowly"), 
    119118        (defined $opt->{warper} ? ", anonymously" : ""), 
    120         $opt->{region}, $time_offset); 
     119        $opt->{region}); 
    121120 
    122121if (-r $opt->{channels_file}) { 
     
    201200        --obfuscate             pretend to be a proxy servicing multiple clients 
    202201        --lang=[s]              set language of xmltv output data (default $opt->{lang}) 
    203         --timezone=HHMM         timezone for channel data (default: system-local timezone) 
    204202 
    205203        --scan-chan=(chanfile)  (debugging) check channel discrepancies 
     
    210208 
    211209        exit(0); 
    212 } 
    213  
    214 ###################################################################################################### 
    215 # yahoo7widget times are always localtime on Eastern States .. 
    216 # we need to calculate the amount of time to offset the data to the user's local timezone. 
    217  
    218 sub calculate_time_offset 
    219 { 
    220         my $local_time_offset = POSIX::strftime("%z",localtime(time)); 
    221  
    222         $ENV{TZ}="Australia/Melbourne"; 
    223         my $melbourne_time_offset = POSIX::strftime("%z",localtime(time)); 
    224  
    225         $time_offset = 
    226                 ((int(substr($melbourne_time_offset,1,2))-int(substr($local_time_offset,1,2)))*(60*60)) + 
    227                 ((int(substr($melbourne_time_offset,3,2))-int(substr($local_time_offset,3,2)))*(60)); 
    228  
    229         # set TZ variable back to an appropriate setting 
    230         if ($opt->{region} =~ /^(74|108|81|107|82|83|85|86)$/) { 
    231                 $ENV{TZ} = "Australia/Adelaide";        # NT/SA 
    232         } elsif ($opt->{region} =~ /^(101|102)$/) { 
    233                 $ENV{TZ} = "Australia/Perth";           # WA 
    234         } elsif ($opt->{region} =~ /^(75|78|79|114)$/) { 
    235                 $ENV{TZ} = "Australia/Brisbane";        # QLD 
    236         } elsif ($opt->{region} =~ /^(88)$/) { 
    237                 $ENV{TZ} = "Australia/Hobart";          # TAS 
    238         } elsif ($opt->{region} =~ /^(63)$/) { 
    239                 $ENV{TZ} = "Australia/Broken_Hill";     # NSW Broken Hill 
    240         } else { 
    241                 $ENV{TZ} = "Australia/Melbourne";       # VIC/NSW 
    242         } 
    243210} 
    244211 
     
    531498                        $tv_guide->{$channel}->{data}->{$event_id}->{'channel'} = $opt_channels->{$channel} if (defined $opt_channels->{$channel}); 
    532499 
    533                         $tv_guide->{$channel}->{data}->{$event_id}->{'start'} =         POSIX::strftime("%Y%m%d%H%M", localtime($event_start+$time_offset)); 
    534                         $tv_guide->{$channel}->{data}->{$event_id}->{'stop'} =          POSIX::strftime("%Y%m%d%H%M", localtime($event_end+$time_offset)); 
     500                        $tv_guide->{$channel}->{data}->{$event_id}->{'start'} =         POSIX::strftime("%Y%m%d%H%M", localtime($event_start)); 
     501                        $tv_guide->{$channel}->{data}->{$event_id}->{'stop'} =          POSIX::strftime("%Y%m%d%H%M", localtime($event_end)); 
    535502                        $tv_guide->{$channel}->{data}->{$event_id}->{'title'} =         [[ $e{title}, $opt->{lang} ]] if $e{title}; 
    536503                        $tv_guide->{$channel}->{data}->{$event_id}->{'sub-title'} =     [[ $e{subtitle}, $opt->{lang} ]] if $e{subtitle}; 
  • trunk/status

    r958 r959  
    33reference       Shepherd/Common.pm  0.29 
    44reference       Shepherd/MythTV.pm  0.6 
    5 grabber         yahoo7widget        1.93 
     5grabber         yahoo7widget        1.94 
    66grabber         rex                 3.6.2 
    77grabber         abc_website         3.14-r1