xmltv/grab Grab_XML.pm,1.17,1.18
Nick Morrott <[email protected]> Thu, 02 Jul 2015 23:53:13 +0000
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/grab
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7360/grab
Modified Files:
Grab_XML.pm
Log Message:
Remove duplicate programme elements from concatenated list returned from XMLTV::cat
Index: Grab_XML.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/Grab_XML.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Grab_XML.pm 8 Jan 2006 18:38:43 -0000 1.17
--- Grab_XML.pm 2 Jul 2015 23:53:11 -0000 1.18
***************
*** 334,337 ****
--- 334,356 ----
}
$bar->finish() if not $opt_quiet;
+
+ # Ensure unique programme elements
+ #
+ # Process list of programmes in reverse order to prefer latest
+ # occurence of a duplicated programme entry. Duplicates are
+ # determined based upon a combination of start time, stop time
+ # and channel.
+ #
+ # Splice logic based on http://stackoverflow.com/a/14191738
+ #
+ my $xmltv_data = XMLTV::cat(@listingses);
+ my @progs = reverse @{$xmltv_data->[3]};
+ my %seen_progs;
+ my @dupe_indexes = reverse(grep { $seen_progs{ $progs[$_]->{start} . "|" . $progs[$_]->{stop} . "|" . $progs[$_]->{channel} }++ } 0..$#progs);
+ foreach my $item (@dupe_indexes) {
+ splice (@progs,$item,1);
+ }
+ $xmltv_data->[3] = [reverse @progs];
+
my %w_args = ();
if (defined $opt_output) {
------------------------------------------------------------------------------
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/