xmltv/lib XMLTV.pm.in,1.168,1.169

Nick Morrott <[email protected]> Sun, 05 Jul 2015 04:32:25 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/lib
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31954/lib

Modified Files:
	XMLTV.pm.in 
Log Message:
Remove duplicate programmes (based on start/stop times, title and channel id) in XMLTV::cat and XMLTV::catfiles routines

Index: XMLTV.pm.in
===================================================================
RCS file: /cvsroot/xmltv/xmltv/lib/XMLTV.pm.in,v
retrieving revision 1.168
retrieving revision 1.169
diff -C2 -d -r1.168 -r1.169
*** XMLTV.pm.in	25 Jun 2015 11:19:56 -0000	1.168
--- XMLTV.pm.in	5 Jul 2015 04:32:22 -0000	1.169
***************
*** 963,966 ****
--- 963,967 ----
      my @encs;	# encoding of all files being catenated
      my %seen_ch;
+     my %seen_progs;
      
      $DIE_ON_MULTIPLE_ENCODINGS = ( defined $w_args->{UTF8} ? 0 : 1 );
***************
*** 1013,1017 ****
  	      }
  	   }
! 	   $w->write_programme($p);
         },
         @_);
--- 1014,1024 ----
  	      }
  	   }
! 	   if (! $seen_progs{ $p->{start} . "|" . $p->{stop} . "|" . $p->{title}[0][0] . "|" . $p->{channel} }++) {
! 	      $w->write_programme($p);
! 	   }
! 	   else {
! 	      # warn "duplicate programme detected, skipping\n"
! 	      # . "  " . $p->{start} . "|" . $p->{stop} . "|" . $p->{title}[0][0] . "|" . $p->{channel} . "\n";
! 	   }
         },
         @_);
***************
*** 1120,1123 ****
--- 1127,1140 ----
  
      if ($do_progs) {
+         @all_progs = reverse @all_progs;
+         my %seen_progs;
+         my @dupe_indexes = reverse(grep { $seen_progs{ $all_progs[$_]->{start} . "|" . $all_progs[$_]->{stop} . "|" . $all_progs[$_]->{title}[0][0] . "|" . $all_progs[$_]->{channel} }++ } 0..$#all_progs);
+         foreach my $item (@dupe_indexes) {
+             # warn "duplicate programme detected, skipping\n"
+             #      . "  " . $all_progs[$item]->{start} . "|" . $all_progs[$item]->{stop} . "|" . $all_progs[$item]->{title}[0][0] . "|" . $all_progs[$item]->{channel} . "\n";
+             splice (@all_progs,$item,1);
+         }
+         @all_progs = reverse @all_progs;
+ 
  	return [ $all_encoding, \%all_credits, \%all_channels, \@all_progs ];
      }


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/