xmltv/grab/uk_atlas tv_grab_uk_atlas,1.18,1.19

Geoff <[email protected]>
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/uk_atlas
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3576

Modified Files:
	tv_grab_uk_atlas 
Log Message:
output Atlas genres before PA genres, and in the same order as they arrive

Index: tv_grab_uk_atlas
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_atlas/tv_grab_uk_atlas,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** tv_grab_uk_atlas	23 Jan 2014 13:12:38 -0000	1.18
--- tv_grab_uk_atlas	6 Mar 2014 15:08:37 -0000	1.19
***************
*** 406,416 ****
  				}
  				
! 				# Store all the (unique) genres. Map them to alternative name if requested.
  				#
  				$item{'genres'} = {};				# use a hash so we can auto-ignore duplicate values
  				foreach my $gtext (@{$prog{'genres'}}) {
  						if ($gtext =~ m|^http://pressassociation.com/genres/(.*)|) {
  								foreach ( map_category( uc_words( map_PA_category($1) ) ) ) {
! 									$item{'genres'}->{ $_ } = 1; 
  								}
  								# (nb: if genre not found then the code will be passed through to XML - this way we can spot any which are missing
--- 406,443 ----
  				}
  				
! 				# Store all the (unique) genres (aka categories). Map them to alternative name if requested.
! 				#
! 				# 6-Mar-2014
! 				# We use a hash to store the genres to avoid manually de-duping the list. However, using a hash means the 
! 				# output order of the categories is indeterminate (& varies).
! 				# To assist those PVRs which can only handle 1 category/genre per programme we will have to sort the keys.
! 				#
! 				# It seems the categories ("genres") added by Atlas are intended to be a top-level category (the PA ones are quite 
! 				# detailed (and unnecessarily so in some cases). So we'll output the Atlas genres first and then the PA ones.
! 				# PVRs which can handle multiple categories won't care, and those which can handle only 1 category will get a
! 				# top-level category (assuming Atlas have added one) rather than a sub-category.  
! 				# (Aside: I don't know how those single-cat PVRs cope with films; they will all come out as "Film" with no clue 
! 				# whatsoever as to what the film is about! That seems like a tremendous oversight IMO.)
! 				#
! 				# In an ideal world the XMLTV DTD would differentiate between top-level categories and sub-categories; but it doesn't.
! 				#
! 				# Atlas don't say if the order of the Atlas genres (when there's more than 1) is important - I think it merely reflects 
! 				# the order of the PA codes in their database (which in itself is random?)
! 				# 
! 				# Although the PA genres usually come first this isn't always the case (I've seen them jumbled up e.g. "Daily Politics" on BBC2)
! 				# Also note there might not be an Atlas category at all!
! 				# 
! 				# Atlas genres are here: https://github.com/atlasapi/atlas-model/blob/master/src/main/java/org/atlasapi/genres/AtlasGenre.java
! 				# PA genres are here: https://docs.metabroadcast.com/display/ATLAS/PA+Genres
! 				#
  				#
  				$item{'genres'} = {};				# use a hash so we can auto-ignore duplicate values
+ 				my $i = 0;
  				foreach my $gtext (@{$prog{'genres'}}) {
+ 						$i++;
  						if ($gtext =~ m|^http://pressassociation.com/genres/(.*)|) {
  								foreach ( map_category( uc_words( map_PA_category($1) ) ) ) {
! 									# $item{'genres'}->{ $_ } = 1; 
! 									$item{'genres'}->{ $_ } = $i | 32  if !defined $item{'genres'}->{ $_ } ; 
  								}
  								# (nb: if genre not found then the code will be passed through to XML - this way we can spot any which are missing
***************
*** 418,426 ****
  						elsif ( $gtext =~ m|^http://ref.atlasapi.org/genres/atlas/(.*)|) {
  								foreach ( map_category( uc_words( $1 ) ) ) {
! 									$item{'genres'}->{ $_ } = 1; 
  								}
  						}
  				}
  				
  				# Get the people information
  				#		(note: Although Presenter is a defined <role> it seems Commentator and Presenter are defined with <role> = 'actor' 
--- 445,455 ----
  						elsif ( $gtext =~ m|^http://ref.atlasapi.org/genres/atlas/(.*)|) {
  								foreach ( map_category( uc_words( $1 ) ) ) {
! 									# $item{'genres'}->{ $_ } = 1; 
! 									$item{'genres'}->{ $_ } = $i  if ( !defined $item{'genres'}->{ $_ } || $item{'genres'}->{ $_ } > (0 | 32) );  
  								}
  						}
  				}
  				
+ 				
  				# Get the people information
  				#		(note: Although Presenter is a defined <role> it seems Commentator and Presenter are defined with <role> = 'actor' 
***************
*** 565,574 ****
  		if ($item{'film'}) {
  			foreach ( map_category( 'Film' ) ) {
! 				$item{'genres'}->{ $_ } = 1; 
  			}
  		}
  		if (scalar (keys %{$item{'genres'}}) > 0) {		
! 			while (my ($key, $value) = each %{$item{'genres'}}) {
! 				push @{$xmlprog{category}}, [ codify( $key ), 'en' ];
  			}
  		}
--- 594,604 ----
  		if ($item{'film'}) {
  			foreach ( map_category( 'Film' ) ) {
! 				$item{'genres'}->{ $_ } = 32; 
  			}
  		}
  		if (scalar (keys %{$item{'genres'}}) > 0) {		
! 			# 6-Mar-2014:   while (my ($key, $value) = each %{$item{'genres'}}) {
! 			foreach ( sort { $item{'genres'}{$a} <=> $item{'genres'}{$b} } keys %{$item{'genres'}} ) {
! 				push @{$xmlprog{category}}, [ codify( $_ ), 'en' ];
  			}
  		}


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.