xmltv/grab/is tv_grab_is,1.29,1.30
Geoff <[email protected]>
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/grab/is
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4789
Modified Files:
tv_grab_is
Log Message:
(minor) use Supplement handler for categories translation
Index: tv_grab_is
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/is/tv_grab_is,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** tv_grab_is 2 Apr 2014 14:59:12 -0000 1.29
--- tv_grab_is 9 May 2014 15:35:51 -0000 1.30
***************
*** 100,103 ****
--- 100,104 ----
use XMLTV::DST;
use XMLTV::Get_nice;
+ use XMLTV::Supplement qw/GetSupplement/;
use XMLTV::Date;
use XMLTV::Usage <<END
***************
*** 134,137 ****
--- 135,139 ----
sub process_skjarinn_is( $$$$$$ );
sub process_stod2_and_friends( $$$$$$ );
+ sub get_categories_map();
***************
*** 275,278 ****
--- 277,284 ----
# begin main program
+ # Fetch map of category number to names
+ my %categories;
+ get_categories_map();
+
my $now = parse_date('now');
die if not defined $now;
***************
*** 458,463 ****
# That's just too flaky so let's go "old school" for now (otherwise nightly validator fails)
# print STDERR "was: ".$node."\n";
! my %categories = ( '1'=>'children', '2'=>'series', '3'=>'news', '4'=>'educational', '5'=>'sports', '6'=>'misc', '7'=>'movie', '8'=>'culture', '9'=>'music', '11'=>'entertainment', '13'=>'news magazine' );
! my $category = $categories{$node->firstChild->data};
$node->removeChildNodes();
$node->appendText($category);
--- 464,471 ----
# That's just too flaky so let's go "old school" for now (otherwise nightly validator fails)
# print STDERR "was: ".$node."\n";
! ## Now done as a Supplement as of v1.30
! ## my %categories = ( '1'=>'children', '2'=>'series', '3'=>'news', '4'=>'educational', '5'=>'sports', '6'=>'misc', '7'=>'movie', '8'=>'culture', '9'=>'music', '11'=>'entertainment', '13'=>'news magazine' );
! # output the category name from the Supplement, else the category numeric value
! my $category = $categories{$node->firstChild->data} || $node->firstChild->data;
$node->removeChildNodes();
$node->appendText($category);
***************
*** 528,543 ****
</xsl:template>
! <!-- Two matches for <category>. With funky lookup as explained at http://www.ibm.com/developerworks/library/x-xsltip.html#h2 -->
! <xsl:template match="category[\@value >= 1 and \@value <= 9 or \@value = 11 or \@value = 13]">
<category>
<xsl:variable name="category_value"><xsl:value-of select="\@value" /></xsl:variable>
- <!-- ([bilbo] too flaky - see note above) xsl:value-of select="document('')/*/data:category/entry[\@key = \$category_value]"/-->
<xsl:value-of select="\$category_value"/>
</category>
</xsl:template>
! <xsl:template match="category">
! <!-- category is no good: <xsl:value-of select="\@value" /> -->
! </xsl:template>
<!-- Two matches for <episode> One to cut out "1 of 1", and one to change to "x:y" format -->
<xsl:template match="episode[\@number = 1 and \@number-of-episodes = 1]">
--- 536,566 ----
</xsl:template>
! EOF
!
! # [bilbo] following code removed in v1.30, ...
! #<!-- Two matches for <category>. With funky lookup as explained at http://www.ibm.com/developerworks/library/x-xsltip.html#h2 -->
! #<xsl:template match="category[\@value >= 1 and \@value <= 9 or \@value = 11 or \@value = 13]">
! # <category>
! # <xsl:variable name="category_value"><xsl:value-of select="\@value" /></xsl:variable>
! # <!-- ([bilbo] too flaky - see note above) xsl:value-of select="document('')/*/data:category/entry[\@key = \$category_value]"/-->
! # <xsl:value-of select="\$category_value"/>
! # </category>
! #</xsl:template>
! #<xsl:template match="category">
! # <!-- category is no good: <xsl:value-of select="\@value" /> -->
! #</xsl:template>
!
! # ..and replaced with:
!
! $xsl_transform .= <<"EOF";
! <xsl:template match="category">
<category>
<xsl:variable name="category_value"><xsl:value-of select="\@value" /></xsl:variable>
<xsl:value-of select="\$category_value"/>
</category>
</xsl:template>
! EOF
+ $xsl_transform .= <<"EOF";
<!-- Two matches for <episode> One to cut out "1 of 1", and one to change to "x:y" format -->
<xsl:template match="episode[\@number = 1 and \@number-of-episodes = 1]">
***************
*** 702,703 ****
--- 725,745 ----
return "";
}
+
+ # Fetch the map of category numbers from the Supplement server
+ sub get_categories_map () {
+ my $supplement = GetSupplement('tv_grab_is', 'category_map');
+ my @lines = split /[\r\n]+/, $supplement;
+ foreach my $line (@lines) {
+ chomp $line; chop($line) if ($line =~ m/\r$/); trim($line);
+ next if $line =~ /^#/ || $line eq '';
+
+ my ($cat_num, $cat_name, $trash) = $line =~ /^(.*)==(.*?)([\s\t]*#.*)?$/;
+ $categories{$cat_num} = $cat_name;
+ }
+ #use Data::Dumper; print Dumper (\%categorymap);
+ }
+
+ sub trim {
+ # Remove leading & trailing spaces
+ $_[0] =~ s/^\s+|\s+$//g;
+ }
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce