/usr/bin/tv_extractinfo_ar is in xmltv-util 0.5.69-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | #!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
=pod
=head1 NAME
tv_extractinfo_ar - read Spanish (Argentinean) language listings and extract info
from programme descriptions.
=head1 SYNOPSIS
tv_extractinfo_ar [--help] [--output FILE] [FILE...]
=head1 DESCRIPTION
Read XMLTV data and attempt to extract information from
Spanish-language programme descriptions, putting it into
machine-readable form. For example the human-readable text '(Repeticion)'
in a programme description might be replaced by the XML element
<previously-shown>.
B<--output FILE> write to FILE rather than standard output
This tool also attempts to split multipart programmes into their
constituents, by looking for a description that seems to contain lots
of times and titles. But this depends on the description following
one particular style and is useful only for some listings sources
(Ananova).
If some text is marked with the 'lang' attribute as being some
language other than Spanish ('es'), it is ignored.
=head1 SEE ALSO
L<xmltv(5)>.
=head1 AUTHOR
Mariano Cosentino, Mok@marianok.com.ar
=head1 BUGS
Trying to parse human-readable text is always error-prone, more so
with the simple regexp-based approach used here. But because TV
listing descriptions usually conform to one of a few set styles,
tv_extractinfo_en does reasonably well. It is fairly conservative,
trying to avoid false positives (extracting 'information' which
isnE<39>t really there) even though this means some false negatives
(failing to extract information and leaving it in the human-readable
text).
However, the leftover bits of text after extracting information may
not form a meaningful Spanish sentence, or the punctuation may be
wrong.
On the two listings sources currently supported by the XMLTV package,
this program does a reasonably good job. But it has not been tested
with every source of anglophone TV listings.
This Spanish Version is heavily customized for the XML results from
tv_grab_ar (developed by Christian A. Rodriguez and postriorily
updated by Mariano S. Cosentino).
This file should probably be called tv_extractinfo_es, but I have not
tested it with any other spanish grabbers, so I don't want to be
presumptious.
=cut
use strict;
sub MSC_Extract();
use XMLTV;
use XMLTV::Usage <<END
$0: read Spanish-language listings and extract info from programme descriptions
usage: $0 [--help] [--output FILE] [FILE...]
END
;
use XML::LibXML;
use XMLTV::Version '$Id: tv_extractinfo_ar,v 1.3 2015/07/12 00:46:37 knowledgejunkie Exp $ ';
use Getopt::Long;
my ($opt_help, $opt_output);
GetOptions('help' => \$opt_help, 'output=s' => \$opt_output) or usage(0);
usage(1) if $opt_help;
@ARGV = ('-') if not @ARGV;
my $parser = XML::LibXML->new;
my $archivo = @ARGV;
my $doc = $parser->parse_file("@ARGV")
or die "can't parse xmltv file: $@";
my $root = $doc->documentElement();
MSC_Extract();
if (defined $opt_output) {
my $status = $doc->toFile("$opt_output");
die "cannot write to $opt_output\n" if not $status;
} else {
print $doc->toString;
}
sub MSC_Extract() {
my @nodeList = $doc->getElementsByTagName('programme');
foreach my $programa (@nodeList) {
my @oldTitle = $programa->getChildrenByTagName('title');
my @oldDesc = $programa->getChildrenByTagName('desc');
my $oldDesc=$oldDesc[0]->textContent;
my $curProgname = $oldTitle[0]->textContent;
# my $parentNode=$programa->parent;
$curProgname =~ s/^\s+//;
$curProgname =~ s/\s+$//;
my $Progname = $curProgname;
# $curProgname =~ s/^Disney.s\s//i;
$curProgname =~ s/^Disney.\s//i;
$curProgname =~ s/^\s+//;
$curProgname =~ s/\s+$//;
if ($curProgname eq "") {
$curProgname=$Progname;
}
# else {
# $Progname = $curProgname;
# }
my $progTitle="";
my $progsubtitle="";
my $episodio="";
my $Temporada="";
my $newNodo="";
my $newNodo_PS="";
my $newNodo_EN="";
my $bChanged=0;
# print "$Progname\n";
if ($curProgname =~ /(.*)\(Repetici.n\)$/) {
$newNodo_PS = XML::LibXML::Element->new('previously-shown');
$curProgname =$1; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(Repetici.n\)(.*)/) {
$newNodo_PS = XML::LibXML::Element->new('previously-shown');
$curProgname =$1 . $3; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(diferido\)$/) {
$curProgname =$1; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(diferido\)(.*)/) {
$curProgname =$1 . $3; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(grabado\)$/) {
$curProgname =$1; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(grabado\)(.*)/) {
$curProgname =$1 . $3; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(vivo\)$/) {
$curProgname =$1; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(vivo\)(.*)/) {
$curProgname =$1 . $3; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(doblad.\)$/) {
$curProgname =$1; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(doblad.\)(.*)/) {
$curProgname =$1 . $3; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(subtitulad..?\)$/) {
$curProgname =$1; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)\(subtitulad..?\)(.*)/) {
$curProgname =$1 . $3; # =~ s,$1,,;
$curProgname =~ s/\(\)//g;
}
if ($curProgname =~ /(.*)?(.?\sEpisodio\s(\d+))(.*)?/) {
$episodio=$3; #$2;
$curProgname =$1 . $4; # =~ s,$1,,;
$curProgname =~ s/^\s+//;
$curProgname =~ s/\s+$//;
$curProgname =~ s/ //g;
$curProgname =~ s/\.\./\./g;
} else {
$episodio="";
}
if ($curProgname =~ /(.*)?(.?\sTemporada\s(\d+))(.*)?/) {
$Temporada=$3; #$2;
$curProgname = $1 . $4; # =~ s,'$1',,;
$curProgname =~ s/^\s+//;
$curProgname =~ s/\s+$//;
$curProgname =~ s/ //g;
$curProgname =~ s/\.\./\./g;
} else {
$Temporada="";
}
if ("$Temporada.$episodio" ne ".") {
$newNodo_EN = XML::LibXML::Element->new('episode-num');
$newNodo_EN->addChild ( $doc->createTextNode( "$Temporada.$episodio." ) );
$newNodo_EN->addChild( $doc->createAttribute('system','xmltv_ns') );
$newNodo="";
}
if ($curProgname =~ /([^.]*)\. (.*)/) {
$progTitle = $1;
$progsubtitle = $2;
} else {
$progTitle = $curProgname;
$progsubtitle = "";
}
if ($progTitle ne "") {
$progTitle =~ s/^\s+//;
$progTitle =~ s/\s+$//;
$progTitle =~ s/ //g;
$progTitle =~ s/\.\./\./g;
$progTitle =~ s/\.+$//g;
}
if ($progsubtitle ne "") {
$progsubtitle =~ s/^\s+//;
$progsubtitle =~ s/\s+$//;
$progsubtitle =~ s/ //g;
$progsubtitle =~ s/\.\./\./g;
$progsubtitle =~ s/\.+$//g;
}
#title+
if ($Progname ne $progTitle) {
if ($progTitle ne "") {
$newNodo = XML::LibXML::Element->new('title');
$newNodo->addChild ( $doc->createTextNode( $progTitle ) );
$newNodo->addChild( $doc->createAttribute('lang','es') );
$programa->replaceChild ( $newNodo, $oldTitle[0]);
$bChanged=1;
$newNodo="";
}
}
my @TempList;
my $TempItem;
#TÃtulo original: Drive
if ($oldDesc =~ /Título original:\s(.*)(\n|\r)?/i) {
$TempItem=$1;
my $TempOtherTitle="";
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$bChanged=1;
if ($TempItem =~ /(.*)\s\(A.?K.?A.?\s(.*)\)/i) {
$TempItem=$1;
$TempOtherTitle=$2;
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$TempOtherTitle=~ s/^\s//;
$TempOtherTitle=~ s/\s$//;
}
$newNodo = XML::LibXML::Element->new('title');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$newNodo->addChild( $doc->createAttribute('lang','en') );
$programa->addChild ( $newNodo );
$newNodo="";
if ($TempOtherTitle ne "") {
$newNodo = XML::LibXML::Element->new('title');
$newNodo->addChild ( $doc->createTextNode( "$TempOtherTitle" ) );
$newNodo->addChild( $doc->createAttribute('lang','en') );
$programa->addChild ( $newNodo );
$newNodo="";
}
}
#sub-title*
if ($progsubtitle ne "") {
$bChanged=1;
my $itemnodo = $programa->addNewChild('', 'sub-title');
$itemnodo->addChild( $doc->createTextNode($progsubtitle) );
}
# desc*
if ($bChanged) {
foreach my $tempNode_desc (@oldDesc) {
$programa->removeChild($tempNode_desc);
$programa->addChild ( $tempNode_desc );
}
}
my $bCredits=0;
my $CreditsNodo = XML::LibXML::Element->new('credits');
# <desc lang="es">Directores: Ed Friedman, Mark Glamack
if ($oldDesc =~ /Director(es)?:\s(.*)(\n|\r)?/i) {
@TempList=split(",",$2);
if (scalar(@TempList)<2) {
@TempList=$2;
}
foreach $TempItem (@TempList) {
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$newNodo = XML::LibXML::Element->new('director');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$bCredits=1;
$CreditsNodo->addChild ( $newNodo );
$newNodo="";
}
}
# <desc lang="es">Protagonista: Kiefer Sutherland
# <desc lang="es">Protagonistas: Antonio Aguilar, Elda Peralta, Chela Pastor, AgustÃn Isunza
if ($oldDesc =~ /Protagonistas?:\s(.*)(\n|\r)?/i) {
@TempList=split(",",$1);
if (scalar(@TempList)<2) {
@TempList=$1;
}
foreach $TempItem (@TempList) {
# warn "\nP: $TempItem";
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$newNodo = XML::LibXML::Element->new('actor');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$bCredits=1;
$CreditsNodo->addChild ( $newNodo );
}
$newNodo="";
}
# Conductor: Adriana Betancour
# Conductores: Adam Corrolla, Jimmy Kimmel
# Conductor: Fernando Merino
if ($oldDesc =~ /Conductor(es)?:\s(.*)(\n|\r)?/i) {
@TempList=split(",",$2);
if (scalar(@TempList)<2) {
@TempList=$2;
}
foreach $TempItem (@TempList) {
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$newNodo = XML::LibXML::Element->new('presenter');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$bCredits=1;
$CreditsNodo->addChild ( $newNodo );
$newNodo="";
}
}
# credits?
if ($bCredits ) {
$programa->addChild ( $CreditsNodo );
}
$CreditsNodo="";
# date?
# Año: 1934
if ($oldDesc =~ /año:\s(.*)(\n|\r)?/i) {
$TempItem= $1;
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$newNodo = XML::LibXML::Element->new('date');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$programa->addChild ( $newNodo );
$newNodo="";
}
# category*
# <desc lang="es">Género: Agro</desc>
if ($oldDesc =~ /Género:\s(.*)(\n|\r)?/i) {
@TempList=split(",",$1);
if (scalar(@TempList)<2) {
@TempList=$1;
}
foreach $TempItem (@TempList) {
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
# warn "Género: $TempItem\n";
$newNodo = XML::LibXML::Element->new('category');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$programa->addChild ( $newNodo );
$newNodo="";
}
}
# language?
# orig-language?
# length?
# Duración: 102 minutos
if ($oldDesc =~ /Duración:\s(\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/;
$newNodo = XML::LibXML::Element->new('length');
$newNodo->addChild ( $doc->createTextNode( "$TempLength" ) );
$newNodo->addChild( $doc->createAttribute('units',"$tempunit") );
$programa->addChild ( $newNodo );
$newNodo="";
}
# icon*
# url*
# country*
#PaÃs: Argentina
if ($oldDesc =~ /País(es)?:\s(.*)(\n|\r)?/i) {
@TempList=split("-",$2);
if (scalar(@TempList)<2) {
@TempList=$2;
}
foreach $TempItem (@TempList) {
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$newNodo = XML::LibXML::Element->new('country');
$newNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$newNodo->addChild( $doc->createAttribute('lang','es') );
$programa->addChild ( $newNodo );
$newNodo="";
}
}
# episode-num*
if ($newNodo_EN ne "") {
$programa->addChild ($newNodo_EN );
}
# my $TempLength="";
# my $tempunit="";
# video?
# audio?
# previously-shown?
if ($newNodo_PS ne "") {
$programa->addChild ($newNodo_PS );
}
# premiere?
# last-chance?
# new?
# subtitles*
# rating*
# Clasificación: Apta para todo público</desc>
# Clasificación: Sólo apta para mayores de 13 años</desc>
# Clasificación: Sólo apta para mayores de 16 años</desc>
# Clasificación: Sólo apta para mayores de 18 años</desc>
if ($oldDesc =~ /Clasificación:\s(.*)(\n|\r)?/i) {
$TempItem=$1;
$TempItem=~ s/^\s//;
$TempItem=~ s/\s$//;
$newNodo = XML::LibXML::Element->new('rating');
$newNodo->addChild( $doc->createAttribute('system',"Argentina") );
my $newSubNodo = XML::LibXML::Element->new('value');
$newSubNodo->addChild ( $doc->createTextNode( "$TempItem" ) );
$newNodo->addChild( $newSubNodo);
$programa->addChild ( $newNodo );
$newNodo="";
}
# star-rating*
}
}
#/(.*)\. (.*)/) {
# print "o: $curProgname\n";
# print "T:$1\n";
# print "St:$2\n";
# $progName = $curProgname;
## my $itemnodo = $programa->addNewChild('', 'title');
## $itemnodo->addChild( $doc->createTextNode($progTitle) );
## $itemnodo->addChild( $doc->createAttribute('lang','es') );
# my $itemnodo = $programa->addNewChild('', 'title');
# $itemnodo->addChild( $doc->createTextNode($progTitle) );
# $itemnodo->addChild( $doc->createAttribute('lang','es') );
#find($programa->nodePath . "/title");
# print $oldNodo[0]->nodePath;
# print $programa->nodePath;
## $programa = $progTitle;
#->textContent
# print "$progName [$progsubtitle - $Temporada.$episodio]\n"; # pretty print
#sub addSubElm($$$) {
# my ($pet, $name, $body) = @_;
# my $subElm = $pet->addNewChild('', $name);
# $subElm->addChild( $doc->createTextNode($body) );
#}
#sub addField($$$$) {
# my ($type, $name, $dob, $price) = @_;
# # addNewChild is non-compliant; could use addSibling instead
# my $pet = $root->addNewChild('', $type);
# addSubElm ( $pet, 'name', $name );
# addSubElm ( $pet, 'dob', $dob );
# addSubElm ( $pet, 'price', $price );
#}
# my $newPrice = sprintf "%6.2f", $curPrice * 1.2;
# my $parent = $programa->parentNode;
# my $newNodo = XML::LibXML::Element->new('programme');
# $newNodo->addChild ( $doc->createTextNode( $newPrice ) );
# $parent->replaceChild ( $newPriceNode, $priceNode );
#print $doc->toString(1); # pretty print
#mv /home/notroot/xmltv2tivo/20080430.slice.gz /home/notroot/TivoEmulator/tivo-service/static/listings/BA01235_13999-14006.slice.gz
|