xmltv/grab/uk_atlas tv_grab_uk_atlas,1.1,1.2

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-serv15506

Modified Files:
	tv_grab_uk_atlas 
Log Message:
Tidy up some code

Index: tv_grab_uk_atlas
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_atlas/tv_grab_uk_atlas,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tv_grab_uk_atlas	17 Oct 2013 16:13:03 -0000	1.1
--- tv_grab_uk_atlas	18 Oct 2013 19:54:53 -0000	1.2
***************
*** 42,116 ****
  
  
- # #############################################################################
- # #############################################################################
- #
- # There's a 'bug' in XMLTV::Handlers{'credits'} in XMLTV 0.5.63
- # The DTD says that credits->actor can have a 'role' attribute
- #			<!ELEMENT actor       (#PCDATA)>
- #    	<!ATTLIST actor role  CDATA #IMPLIED>
- # 	but XMLTV can't do this.
- # So we'll redeclare the 'credits' handlers with ones which *can* deal with this attribute.
- #
- undef $XMLTV::Handlers{'credits'}->[0];
- undef $XMLTV::Handlers{'credits'}->[1];
- $XMLTV::Handlers{credits}->[0] = sub( $ ) {
-     my $node = shift;
-     my @roles = qw(director actor writer adapter producer composer
-                    editor presenter commentator guest);
-     my %known_role; ++$known_role{$_} foreach @roles;
-     my %r;
-     foreach (get_subelements($node)) {
- 			my $role = get_name($_);
- 			unless ($known_role{$role}++) {
- 				warn "unknown thing in credits: $role";
- 				next;
- 			}
- 		
- 			# BEGIN modified code needed to support role attribute
- 			my %attrs = %{get_attrs($_)};
- 			my $character = $attrs{role} if exists $attrs{role};
- 			if (defined $character) {
- 				push @{$r{$role}}, [ get_text($_), $character ] ;
- 			} else {
- 				push @{$r{$role}}, get_text($_);
- 			}
- 			# END 
- 			
-     }
-     return \%r;
- };
- $XMLTV::Handlers{'credits'}->[1] = sub( $$$ ) {
-     my ($w, $e, $v) = @_; die if not defined $v;
-     my %h = %$v;
-     return if not %h; # don't write empty element
-     t 'writing credits: ' ;# . d \%h;
-     # TODO some 'do nothing' setting in XML::Writer to replace this
-     # convention of passing undef.
-     #
-     $w->startTag($e) if $w;
-     foreach ( qw[director actor writer adapter producer composer 
-                  editor presenter commentator guest] ) {
- 		next unless defined $h{$_};
- 		my @people = @{delete $h{$_}};
- 		foreach my $person (@people) {
- 	    die if not defined $person;
- 			
- 			# BEGIN modified code needed to support role attribute
- 			if (ref($person) eq 'ARRAY') {
- 				$w->dataElement($_, @{$person}[0], 'role' => @{$person}[1] ) if $w;
- 			} else {
- 				$w->dataElement($_, $person) if $w;
- 			}
- 			# END 
- 	}
-     }
-     XMLTV::warn_unknown_keys($e, \%h);
-     $w->endTag($e) if $w;
- };
- # #############################################################################
- # #############################################################################
- 
- 
- 
  # ------------------------------------------------------------------------------------------------------------------------------------- #
  # Grabber details
--- 42,45 ----
***************
*** 560,564 ****
  			if ($item{($role.'s')} && scalar @{$item{($role.'s')}} > 0) {
  				foreach my $showperson ( @{$item{$role.'s'}}) {
! 					if ($role eq 'actor') {
  						push @{$xmlprog{'credits'}{$role}}, [ @{$showperson}[0], @{$showperson}[1] ];
  					} else {
--- 489,493 ----
  			if ($item{($role.'s')} && scalar @{$item{($role.'s')}} > 0) {
  				foreach my $showperson ( @{$item{$role.'s'}}) {
! 					if (ref($showperson) eq 'ARRAY') { 
  						push @{$xmlprog{'credits'}{$role}}, [ @{$showperson}[0], @{$showperson}[1] ];
  					} else {


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&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.