xmltv/grab/uk_rt tv_grab_uk_rt,1.41,1.42

Nick Morrott <[email protected]> Sun, 16 Aug 2015 03:08:20 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/uk_rt
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26245/grab/uk_rt

Modified Files:
	tv_grab_uk_rt 
Log Message:
Improve handling of timeshifted part-time channels

Index: tv_grab_uk_rt
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_rt/tv_grab_uk_rt,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** tv_grab_uk_rt	16 Jun 2015 00:51:33 -0000	1.41
--- tv_grab_uk_rt	16 Aug 2015 03:08:18 -0000	1.42
***************
*** 1259,1263 ****
                  if (defined $channel_offset{$xmltv_id}) {
                      $prog{'_repeat'} = 1;
!                     t("  Ignoring premiere flag on timeshifted channel");
                  }
                  else {
--- 1259,1263 ----
                  if (defined $channel_offset{$xmltv_id}) {
                      $prog{'_repeat'} = 1;
!                     t("    Ignoring premiere flag on timeshifted channel");
                  }
                  else {
***************
*** 2880,2883 ****
--- 2880,2886 ----
      # broadcast times.
      #
+     # If the channel's timeshift is a multiple of 24hrs (e.g. Channel 5 +24)
+     # we adjust the channel's start/stop times accordingly.
+     #
      if (defined $broadcast_hours{ $prog->{channel} }) {
          $broadcast_hours{ $prog->{channel} } =~ m/(\d\d)(\d\d)-(\d\d)(\d\d)/;
***************
*** 2893,2897 ****
              time_zone  => 'Europe/London',
          );
-         my $chan_start  = "" . $chan_start_dt->ymd('') . $chan_start_dt->hms('') . ' ' . DateTime::TimeZone->offset_as_string($chan_start_dt->offset);
  
          my $chan_stop_dt = DateTime->new(
--- 2896,2899 ----
***************
*** 2905,2931 ****
          );
  
          # Correct the stop time if it is earlier than the start time
!         my $chan_stop_next_day = 0;
          if ($chan_start_dt >= $chan_stop_dt) {
              $chan_stop_dt = $chan_stop_dt + $day_dur;
!             $chan_stop_next_day = 1;
          }
          my $chan_stop  = "" . $chan_stop_dt->ymd('') . $chan_stop_dt->hms('') . ' ' . DateTime::TimeZone->offset_as_string($chan_stop_dt->offset);
  
!         t("    " . $chan_start . " - Start time of channel (current day)");
!         t("    " . $chan_stop  . " - Stop time of channel (current day)");
  
!         # Include the current programme if its timeslot lies inside the
          # channel's broadcast window
!         if ($start_dt >= $chan_start_dt && $stop_dt <= $chan_stop_dt) {
              t("    '" . $prog->{'_title'} . "' shown whilst channel is on-air, adding");
          }
          # If the channel starts and stops broadcasting on the same
!         # calendar day and the programme's timeslot is outside the
          # broadcast window, skip it
!         elsif (( $start_dt < $chan_start_dt || $stop_dt > $chan_stop_dt)
!                 && $chan_stop_next_day == 0 ) {
!             t("    '" . $prog->{'_title'} . "' shown whilst channel is off-air, skipping\n");
!             return undef;
          }
          else {
--- 2907,2947 ----
          );
  
+         # Shift channel start/stop times forward by whole days if necessary.
+         if (defined $channel_offset{ $prog->{channel} } and $ts_dt->in_units( 'hours' ) % 24 == 0) {
+             $chan_start_dt = $chan_start_dt + $ts_dt;
+             $chan_stop_dt  = $chan_stop_dt  + $ts_dt;
+             t("    Applying channel timeshift of " . $ts_dt->in_units( 'hours' ) . " hours");
+         }
+ 
          # Correct the stop time if it is earlier than the start time
!         my $chan_stops_next_day = 0;
          if ($chan_start_dt >= $chan_stop_dt) {
              $chan_stop_dt = $chan_stop_dt + $day_dur;
!             $chan_stops_next_day = 1;
          }
+ 
+         my $chan_start  = "" . $chan_start_dt->ymd('') . $chan_start_dt->hms('') . ' ' . DateTime::TimeZone->offset_as_string($chan_start_dt->offset);
          my $chan_stop  = "" . $chan_stop_dt->ymd('') . $chan_stop_dt->hms('') . ' ' . DateTime::TimeZone->offset_as_string($chan_stop_dt->offset);
  
!         t("    " . $chan_start . " - Start time of channel (normal)");
!         t("    " . $chan_stop  . " - Stop time of channel (normal)");
  
!         # Include the current programme if its start time lies inside the
          # channel's broadcast window
!         if ($start_dt >= $chan_start_dt && $start_dt < $chan_stop_dt) {
              t("    '" . $prog->{'_title'} . "' shown whilst channel is on-air, adding");
          }
          # If the channel starts and stops broadcasting on the same
!         # calendar day and the programme's start time is outside the
          # broadcast window, skip it
!         elsif ($chan_stops_next_day == 0 ) {
!             if ($start_dt < $chan_start_dt) {
!                 t("    '" . $prog->{'_title'} . "' starts before channel has started, skipping\n");
!                 return undef;
!             }
!             elsif ($start_dt >= $chan_stop_dt) {
!                 t("    '" . $prog->{'_title'} . "' starts after channel has stopped, skipping\n");
!                 return undef;
!             }
          }
          else {
***************
*** 2955,2959 ****
              # Test again to see if the programme falls between the adjusted
              # channel broadcast times
!             if ($start_dt >= $chan_start_dt && $stop_dt <= $chan_stop_dt) {
                  t("    '" . $prog->{'_title'} . "' shown whilst channel is on-air, adding");
              } else {
--- 2971,2975 ----
              # Test again to see if the programme falls between the adjusted
              # channel broadcast times
!             if ($start_dt >= $chan_start_dt && $start_dt < $chan_stop_dt) {
                  t("    '" . $prog->{'_title'} . "' shown whilst channel is on-air, adding");
              } else {


------------------------------------------------------------------------------