xmltv/grab/ar tv_grab_ar,1.12,1.13
Mariano Cosentino <[email protected]>
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/grab/ar In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8728/xmltv/grab/ar Modified Files: tv_grab_ar Log Message: added function to handle character conversion to utf-8 solved issue with descriptions additional handling due to some changes on source format Index: tv_grab_ar =================================================================== RCS file: /cvsroot/xmltv/xmltv/grab/ar/tv_grab_ar,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tv_grab_ar 22 Jun 2011 05:56:34 -0000 1.12 --- tv_grab_ar 12 Jul 2013 19:54:10 -0000 1.13 *************** *** 71,74 **** --- 71,77 ---- =head1 AUTHOR + 1.14 Mariano S. Cosentino, [email protected] + 1.13 Mariano S. Cosentino, [email protected] + 1.12 rmeden 1.10 Mariano S. Cosentino, [email protected] 1.9 Mariano S. Cosentino, [email protected] *************** *** 90,97 **** # Author's Updates # 1.10 Mariano Cosentino # * fixed prototype warning # * Removed default value for location, as the old channel ids are no compatible with the site's new format. - # Author's Updates # 1.9 Mariano Cosentino # * The source website changed, I've adapted the script to the new format --- 93,105 ---- # Author's Updates + # 1.14 Mariano Cosentino + # * added function to handle character conversion to utf-8 + # 1.13 Mariano Cosentino + # * solved issue with descriptions + # 1.12 rmeden + # apply Karl's patches to remove switch statements # 1.10 Mariano Cosentino # * fixed prototype warning # * Removed default value for location, as the old channel ids are no compatible with the site's new format. # 1.9 Mariano Cosentino # * The source website changed, I've adapted the script to the new format *************** *** 146,151 **** use HTML::Entities; # parse entities use IO::File; ! use Encode qw(from_to is_utf8 _utf8_off encode); use utf8; --- 154,160 ---- use HTML::Entities; # parse entities use IO::File; + use Switch; ! use Encode qw(from_to is_utf8 _utf8_off encode decode); use utf8; *************** *** 323,327 **** $w_args{OUTPUT} = $fh; } ! $w_args{encoding} = 'utf-8'; my $writer = new XMLTV::Writer(%w_args); $writer->start($HEAD); --- 332,336 ---- $w_args{OUTPUT} = $fh; } ! $w_args{encoding} = 'ISO-8859-15'; my $writer = new XMLTV::Writer(%w_args); $writer->start($HEAD); *************** *** 686,690 **** my ($channel_num) = ($opt->attr('onclick') =~ /.*sintonia=(\d+).*/i); $channels{$channel_id}=$channel_name; ! my $coded_chan_name=encode("UTF-8",$channel_name); # print $coded_chan_name; push @ch_all, { --- 695,699 ---- my ($channel_num) = ($opt->attr('onclick') =~ /.*sintonia=(\d+).*/i); $channels{$channel_id}=$channel_name; ! my $coded_chan_name=encodeco("utf-8",$channel_name); # print $coded_chan_name; push @ch_all, { *************** *** 834,840 **** # <a href="ficha.php?verFicha=224193" rel="#overlay_ficha" class="programaSemana" title="Parental Control" style="height:34px; top:-1px"> ! my $title= encode("UTF-8",trim($celda->attr('title'))); if (! (defined $title)) { ! $title= encode("UTF-8",trim($celda->as_text)); } my ($top)=($celda->attr('style') =~ /top:\s*(-{0,1}\d+)\s*(px|)/i); --- 843,849 ---- # <a href="ficha.php?verFicha=224193" rel="#overlay_ficha" class="programaSemana" title="Parental Control" style="height:34px; top:-1px"> ! my $title= encodeco("UTF-8",trim($celda->attr('title'))); if (! (defined $title)) { ! $title= encodeco("UTF-8",trim($celda->as_text)); } my ($top)=($celda->attr('style') =~ /top:\s*(-{0,1}\d+)\s*(px|)/i); *************** *** 867,871 **** if ($opt_get_details) { my %TempDesc; ! my ($progindex)=($celda->attr('href') =~ /ficha\.php\?verFicha.(\d+)/i); if (exists $Descriptions{$progindex}) { #original format --- 876,880 ---- if ($opt_get_details) { my %TempDesc; ! my ($progindex)=($celda->attr('rev') =~ /ficha\.php\?verFicha.(\d+)/i); if (exists $Descriptions{$progindex}) { #original format *************** *** 888,892 **** my $Categoria = ($ficha_tree->look_down('_tag','h1')); if (defined $Categoria) { ! $Categoria = encode("UTF-8",trim($Categoria->as_text)); } else { $Categoria = ""; --- 897,906 ---- my $Categoria = ($ficha_tree->look_down('_tag','h1')); if (defined $Categoria) { ! $Categoria = encodeco("UTF-8",trim($Categoria->as_text)); ! # $valor =~ s/, /,/g; ! ! # my @algo =split(',', $Categoria); ! # $Categoria = \@algo ! } else { $Categoria = ""; *************** *** 903,907 **** my $TituloEsp = ($ficha_tree->look_down('_tag','h2')); if (defined $TituloEsp) { ! $TituloEsp = encode("UTF-8",trim($TituloEsp->as_text)); } else { $TituloEsp = $title; --- 917,921 ---- my $TituloEsp = ($ficha_tree->look_down('_tag','h2')); if (defined $TituloEsp) { ! $TituloEsp = encodeco("UTF-8",trim($TituloEsp->as_text)); } else { $TituloEsp = $title; *************** *** 916,920 **** my $sinopsis= ($SinopsisBox->look_down('_tag','p')) if (defined $SinopsisBox); if (defined $sinopsis) { ! $sinopsis=encode("UTF-8",trim($sinopsis->as_text)); } else { $sinopsis = ""; --- 930,934 ---- my $sinopsis= ($SinopsisBox->look_down('_tag','p')) if (defined $SinopsisBox); if (defined $sinopsis) { ! $sinopsis=encodeco("UTF-8",trim($sinopsis->as_text)); } else { $sinopsis = ""; *************** *** 932,983 **** else { my $valor; ! $valor=encode("UTF-8",trim($Propiedad->as_text)); ! if ($PropertyField =~ m/Protagonista((s)?)/i ) { ! $valor =~ s/, /,/g; ! my @algo =split(',', $valor); ! $credits{actor} = \@algo ! } ! elsif ($PropertyField =~ m/Director((es)?)/i) { ! $valor =~ s/, /,/g; ! my @algo =split(',', $valor); ! $credits{director} = \@algo ! } ! elsif ($PropertyField =~ m/Conductor((es)?)/i) { ! $valor =~ s/, /,/g; ! my @algo =split(',', $valor); ! $credits{presenter} = \@algo ! } ! elsif ($PropertyField =~ m/G.nero/i) { ! $ret{category} = $valor; ! } ! elsif ($PropertyField =~ m/(Duración|Duración)/) { # html, utf-8 bytes, missing unicode chars ! $valor =~ /(\d*)\s(.*)(\n|\r)?/i; ! my $TempLength=$1; ! my $tempunit=$2; ! $tempunit=~ s/^\s//; ! $tempunit=~ s/\s$//; ! # $tempunit=~ s/minutos?/minutes/; ! # $tempunit=~ s/horas?/hours/; ! # $tempunit=~ s/segundos?/seconds/; ! # if ($tempunit=~ s/minutos?/i) { $TempLength = ($TempLength *60) } ! # if ($tempunit=~ s/horas?/i) { $TempLength = ($TempLength *60) } ! $ret{length} = ($TempLength *60); ! } ! elsif ($PropertyField =~ m/Pa.s/i) { ! $ret{country} = $valor; ! } ! elsif ($PropertyField =~ m/(Año|Ano)/) { ! $ret{date} = $valor; ! } ! elsif ($PropertyField eq 'Título original') { ! $ret{title2} = $valor; ! } ! elsif ($PropertyField =~ m/Clasificaci.n/i) { ! $ret{rating} = $valor; ! } ! else { ! print STDERR "ignoring useless data ... [$PropertyField]\n"; } ! $PropertyField = ''; } } --- 946,1001 ---- else { my $valor; ! $valor=encodeco("UTF-8",trim($Propiedad->as_text)); ! switch ($PropertyField) { ! case (m/Protagonista((s)?)/i) { ! $valor =~ s/, /,/g; ! my @algo =split(',', $valor); ! $credits{actor} = \@algo ! } ! case (m/Director((es)?)/i) { ! $valor =~ s/, /,/g; ! my @algo =split(',', $valor); ! $credits{director} = \@algo ! } ! case (m/Conductor((es)?)/i) { ! $valor =~ s/, /,/g; ! my @algo =split(',', $valor); ! $credits{presenter} = \@algo ! } ! case (m/G.nero/i) { ! $ret{category} = $valor; ! } ! case (['Duración','Duración']) { ! $valor =~ /(\d*)\s(.*)(\n|\r)?/i; ! my $TempLength=$1; ! my $tempunit=$2; ! $tempunit=~ s/^\s//; ! $tempunit=~ s/\s$//; ! # $tempunit=~ s/minutos?/minutes/; ! # $tempunit=~ s/horas?/hours/; ! # $tempunit=~ s/segundos?/seconds/; ! # if ($tempunit=~ s/minutos?/i) { $TempLength = ($TempLength *60) } ! # if ($tempunit=~ s/horas?/i) { $TempLength = ($TempLength *60) } ! $ret{length} = ($TempLength *60); ! } ! case (m/Pa.s/i) { ! $ret{country} = $valor; ! } ! case (['Año','Ano']) { ! $ret{date} = $valor; ! } ! case ('Título original') { ! $ret{title2} = $valor; ! } ! case ([m/Clasificaci.n/i]) { ! $ret{rating} = $valor; ! } ! case "" { ! # print "ignoring useless data ... [$PropertyField]\n" ;; ! # %ret->{''} = $valor; ! } ! else {} } ! $PropertyField =""; } } *************** *** 1035,1039 **** --- 1053,1069 ---- + sub encodeco { + my($tempdummy,$temptexto)=@_; + # print "$temptexto\n"; + # # decode the qouted-printable input + # #$body = decode_qp( $body ); + # # decode to Perl's internal format + # $temptexto = decode( 'iso-8859-1', $temptexto ); + # # encode to UTF-8 + # $temptexto = encode( 'utf-8', $temptexto ); + # print "$temptexto\n"; + return $temptexto; + } *************** *** 1064,1077 **** sub Clean_amp { my ($texto)=@_; ! Encode::from_to($texto, "iso-8859-1", "utf8"); ! my $textoold=$texto; ! $texto =~ s/&/&/g; ! $texto =~ s/´/á/g; ! $texto =~ s/á/á/g; ! $texto =~ s/é/é/g; ! $texto =~ s/í/í/g; ! $texto =~ s/ó/ó/g; ! $texto =~ s/ú/ú/g; ! $texto =~ s/ñ/ñ/g; --- 1094,1108 ---- sub Clean_amp { my ($texto)=@_; ! # Encode::from_to($texto, "iso-8859-1", "utf8"); ! $texto=encodeco("utf-8",$texto); ! # my $textoold=$texto; ! # $texto =~ s/&/&/g; ! # $texto =~ s/´/á/g; ! # $texto =~ s/á/á/g; ! # $texto =~ s/é/é/g; ! # $texto =~ s/í/í/g; ! # $texto =~ s/ó/ó/g; ! # $texto =~ s/ú/ú/g; ! # $texto =~ s/ñ/ñ/g; ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ xmltv-commit mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/xmltv-commit