xmltv/filter tv_imdb,1.26,1.27

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

Modified Files:
	tv_imdb 
Log Message:
add IMDb data in same character encoding as the input xml file (Bug #440)

Index: tv_imdb
===================================================================
RCS file: /cvsroot/xmltv/xmltv/filter/tv_imdb,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** tv_imdb	16 Dec 2013 01:38:58 -0000	1.26
--- tv_imdb	19 Apr 2014 08:25:43 -0000	1.27
***************
*** 155,158 ****
--- 155,159 ----
  
  use XMLTV;
+ use XMLTV::Data::Recursive::Encode;
  use XMLTV::Usage <<END
  $0: augment listings with data from imdb.com
***************
*** 278,285 ****
  
  my $w;
  
  sub encoding_cb( $ ) {
      die if defined $w;
!     $w = new XMLTV::Writer(%w_args, encoding => shift);
  }
  
--- 279,288 ----
  
  my $w;
+ my $encoding;   # store encoding of input file
  
  sub encoding_cb( $ ) {
      die if defined $w;
!     $encoding = shift;    # callback returns the file's encoding
!     $w = new XMLTV::Writer(%w_args, encoding => $encoding);
  }
  
***************
*** 309,314 ****
--- 312,330 ----
      my $prog=shift;
      
+     # The database made by IMDB.pm is read as iso-8859-1. The xml file may be different (e.g. utf-8).
+     # IMDB::augmentProgram does not re-encode the data it adds, so the output file has invalid characters (bug #440).
+     
+     if (lc($encoding) ne 'iso-8859-1') {
+       # decode the incoming programme
+       $prog = XMLTV::Data::Recursive::Encode->decode($encoding, $prog);
+     }
+     
+     # augmentProgram will now add imdb data as iso-8859-1 
      my $nprog=$imdb->augmentProgram($prog, $opt_movies_only);
      if ( $nprog ) {
+       if (lc($encoding) ne 'iso-8859-1') {
+         # re-code the modified programme back to original encoding
+         $nprog = XMLTV::Data::Recursive::Encode->encode($encoding, $nprog);
+       }
  	$prog=$nprog;
      }


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
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.