summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert McNamara <rmcnamara@mythtv.org>2010-11-15 14:47:48 (GMT)
committer Robert McNamara <rmcnamara@mythtv.org>2010-11-15 14:47:48 (GMT)
commit2c2d496dff8b8e323ffa49053881718ff51b70f5 (patch)
tree7cced4863287154472df612b372514dc5748e886
parent262c98f3a7fda69bd69bb74d7cca49314ee8c251 (diff)
Update several internet content scripts to account for changes to BBC/trailer site RSS feed web sites.
git-svn-id: http://svn.mythtv.org/svn/trunk@27231 7dbf422c-18fa-0310-86e9-fd20926502f2
-rwxr-xr-xmythtv/programs/scripts/internetcontent/nv_python_libs/bbciplayer/bbciplayer_api.py21
-rwxr-xr-xmythtv/programs/scripts/internetcontent/nv_python_libs/common/common_api.py17
-rw-r--r--mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/bbc_config.xml5
-rw-r--r--mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/defaultUserPrefs/trailersMashup.xml2
-rw-r--r--mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XSLT/tributecaHTML_item.xsl100
-rwxr-xr-xmythtv/programs/scripts/internetcontent/nv_python_libs/xsltfunctions/tributeca_api.py39
6 files changed, 113 insertions, 71 deletions
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/bbciplayer/bbciplayer_api.py b/mythtv/programs/scripts/internetcontent/nv_python_libs/bbciplayer/bbciplayer_api.py
index 43a4c94..bc94019 100755
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/bbciplayer/bbciplayer_api.py
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/bbciplayer/bbciplayer_api.py
@@ -20,13 +20,14 @@ provided by BBC (http://www.bbc.co.uk). The specific BBC iPlayer RSS feeds that
"~/.mythtv/MythNetvision/userGrabberPrefs/bbciplayer.xml"
'''
-__version__="v0.1.2"
+__version__="v0.1.3"
# 0.1.0 Initial development
# 0.1.1 Changed the logger to only output to stderr rather than a file
# 0.1.2 Fixed incorrect URL creation for RSS feed Web pages
# Restricted custom HTML web pages to Video media only. Audio will only play from its Web page.
# Add the "customhtml" tag to search and treeviews
# Removed the need for python MythTV bindings and added "%SHAREDIR%" to icon directory path
+# 0.1.3 Fixed search due to BBC Web site changes
import os, struct, sys, re, time, datetime, shutil, urllib, re
import logging
@@ -349,16 +350,19 @@ class Videos(object):
urlType = u'fullscreen'
# Translate the search results into MNV RSS item format
- linkFilter = etree.XPath(u".//div[@class='episode-details']/a")
- titleFilter = etree.XPath(u".//div[@class='episode-details']/h3")
- descFilter = etree.XPath(u".//div[@class='episode-details']//p")
- thumbnailFilter = etree.XPath(u".//div[@class='episode-thumbnail']//img")
+ audioFilter = etree.XPath('./@class="audio"')
+ linkFilter = etree.XPath(u".//div[@class='episode-info']//a")
+ titleFilter = etree.XPath(u".//div[@class='episode-info']//a")
+ descFilter = etree.XPath(u".//div[@class='episode-info']//p[@class='episode-synopsis']")
+ thumbnailFilter = etree.XPath(u".//div[@class='episode-image']//img")
itemDict = {}
for result in searchResults:
tmpLink = linkFilter(result)
if not len(tmpLink): # Make sure that this result actually has a video
continue
bbciplayerItem = etree.XML(self.common.mnvItem)
+ # Is this an Audio or Video item (true/false)
+ audioTF = audioFilter(result)
# Extract and massage data
link = tmpLink[0].attrib['href']
if urlType == 'bigscreen':
@@ -366,7 +370,7 @@ class Videos(object):
elif urlType == 'bbcweb':
link = u'http://www.bbc.co.uk'+ link
else:
- if tmpLink[0].attrib['class'].find('cta-video') != -1:
+ if not audioTF:
link = link.replace(u'/iplayer/episode/', u'')
index = link.find(u'/')
link = link[:index]
@@ -388,7 +392,10 @@ class Videos(object):
bbciplayerItem.xpath('.//media:thumbnail', namespaces=self.common.namespaces)[0].attrib['url'] = self.common.ampReplace(thumbnailFilter(result)[0].attrib['src'])
bbciplayerItem.xpath('.//media:content', namespaces=self.common.namespaces)[0].attrib['url'] = link
# Videos are only viewable in the UK so add a country indicator if this is a video
- countCode = self.setCountry(result)
+ if audioTF:
+ countCode = None
+ else:
+ countCode = u'uk'
if countCode:
etree.SubElement(bbciplayerItem, "{http://www.mythtv.org/wiki/MythNetvision_Grabber_Script_Format}country").text = countCode
s_e = self.getSeasonEpisode(title)
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/common/common_api.py b/mythtv/programs/scripts/internetcontent/nv_python_libs/common/common_api.py
index 746988e..643fcb1 100755
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/common/common_api.py
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/common/common_api.py
@@ -18,7 +18,7 @@ MythNetvision Grabber scripts that run as a Web application and global functions
MNV grabbers.
'''
-__version__="v0.2.2"
+__version__="v0.2.3"
# 0.0.1 Initial development
# 0.1.0 Alpha release
# 0.1.1 Added the ability to have a mashup name independant of the mashup title
@@ -50,6 +50,7 @@ __version__="v0.2.2"
# when new custom HTML pages were added.
# 0.2.1 Add the ability for a parameters to be passed to a XSLT style sheet
# 0.2.2 Added a common XPath extention to test if a string starts or ends with a substring
+# 0.2.3 Fixed Error messages that were not unicode strings
import os, struct, sys, re, datetime, time, subprocess, string
import urllib
@@ -964,7 +965,7 @@ class getURL(Thread):
def run(self):
if self.debug:
- print "getURL href(%s)" % (self.urlDictionary[self.urlKey]['href'], )
+ print u"getURL href(%s)" % (self.urlDictionary[self.urlKey]['href'], )
print
# Input the data from a url
@@ -985,9 +986,9 @@ class getURL(Thread):
try:
self.urlDictionary[self.urlKey]['tmp'] = self.urlDictionary[self.urlKey]['tree'].xpath(self.urlDictionary[self.urlKey]['filter'][index], namespaces=self.urlDictionary[self.urlKey]['namespaces'])
except AssertionError, e:
- sys.stderr.write("No filter results for Name(%s)\n" % self.urlKey)
- sys.stderr.write("No filter results for url(%s)\n" % self.urlDictionary[self.urlKey]['href'])
- sys.stderr.write("! Error:(%s)\n" % e)
+ sys.stderr.write(u"No filter results for Name(%s)\n" % self.urlKey)
+ sys.stderr.write(u"No filter results for url(%s)\n" % self.urlDictionary[self.urlKey]['href'])
+ sys.stderr.write(u"! Error:(%s)\n" % e)
if len(self.urlDictionary[self.urlKey]['filter']) == index-1:
return
else:
@@ -1003,15 +1004,15 @@ self.urlDictionary[self.urlKey]['parameter']) )
else:
self.urlDictionary[self.urlKey]['tmp'] = self.urlDictionary[self.urlKey]['xslt'][index](self.urlDictionary[self.urlKey]['tree'])
except Exception, e:
- sys.stderr.write("! XSLT Error:(%s) Key(%s)\n" % (e, self.urlKey))
+ sys.stderr.write(u"! XSLT Error:(%s) Key(%s)\n" % (e, self.urlKey))
if len(self.urlDictionary[self.urlKey]['filter']) == index-1:
return
else:
continue
# Was any data found?
if self.urlDictionary[self.urlKey]['tmp'].getroot() == None:
- sys.stderr.write("No Xslt results for Name(%s)\n" % self.urlKey)
- sys.stderr.write("No Xslt results for url(%s)\n" % self.urlDictionary[self.urlKey]['href'])
+ sys.stderr.write(u"No Xslt results for Name(%s)\n" % self.urlKey)
+ sys.stderr.write(u"No Xslt results for url(%s)\n" % self.urlDictionary[self.urlKey]['href'])
if len(self.urlDictionary[self.urlKey]['filter']) == index-1:
return
else:
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/bbc_config.xml b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/bbc_config.xml
index 1650552..d2f7d57 100644
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/bbc_config.xml
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/bbc_config.xml
@@ -19,9 +19,8 @@
<url>
<name>BBC iPlayer Search</name>
<href>http://www.bbc.co.uk/iplayer/search</href>
- <filter>//div[@class='search result-wrapper']//ul</filter>
- <filter>//div[@id='results-container']//ul</filter>
- <pageFilter>//a/@class[starts-with(.,'last page')]/..</pageFilter>
+ <filter>//ul[@class='result-list listview episodelist']/li</filter>
+ <pageFilter>//a/@title[starts-with(.,'Next page')]/..</pageFilter>
<parserType>html</parserType>
</url>
</urls>
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/defaultUserPrefs/trailersMashup.xml b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/defaultUserPrefs/trailersMashup.xml
index 26bf1a1..67debc5 100644
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/defaultUserPrefs/trailersMashup.xml
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XML/defaultUserPrefs/trailersMashup.xml
@@ -46,7 +46,7 @@
</subDirectory>
<subDirectory name="Tribute.ca">
- <sourceURL enabled="true" name="Tribute.ca" xsltFile="tributecaHTML_item" type="html" url="http://www.tribute.ca/trailers/"/>
+ <sourceURL enabled="true" name="Tribute.ca" xsltFile="tributecaHTML_item" type="html" url="http://www.tribute.ca/movietrailers/"/>
</subDirectory>
<subDirectory name="TrailerAddict.com">
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XSLT/tributecaHTML_item.xsl b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XSLT/tributecaHTML_item.xsl
index 31f3445..46469a8 100644
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XSLT/tributecaHTML_item.xsl
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/XSLT/tributecaHTML_item.xsl
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Tribute.ca items conversion to MythNetvision item format
--->
+-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:media="http://search.yahoo.com/mrss/"
@@ -11,7 +11,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8" omit-xml-declaration="yes"/>
-
+
<!--
This template calls all other templates which allows for multiple sources to be processed
within a single Xslt file
@@ -27,11 +27,15 @@
</xml>
</xsl:if>
</xsl:template>
-
- <xsl:template name="featured">
+
+ <xsl:template name="featured">
<xsl:element name="directory">
- <xsl:attribute name="name"><xsl:value-of select="string('Featured movie Trailers')"/></xsl:attribute>
- <xsl:attribute name="thumbnail"><xsl:value-of select="string('http://www.tribute.ca/images/tribute_title.gif')"/></xsl:attribute>
+ <xsl:attribute name="name">
+ <xsl:value-of select="string('Featured movie Trailers')"/>
+ </xsl:attribute>
+ <xsl:attribute name="thumbnail">
+ <xsl:value-of select="string('http://www.tribute.ca/images/tribute_title.gif')"/>
+ </xsl:attribute>
<xsl:for-each select="//a[@class]/img[@src]/..">
<dataSet>
<directoryThumbnail>http://www.tribute.ca/images/tribute_title.gif</directoryThumbnail>
@@ -42,8 +46,8 @@
<xsl:otherwise>
<xsl:element name="item">
<title><xsl:value-of select="normalize-space(string(.))"/></title>
- <author>Tribute.ca</author>
- <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
+ <author>Tribute.ca</author>
+ <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
<description><xsl:value-of select="normalize-space(img/@alt)"/></description>
<link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //a[@class]/img[@src]/..)"/></link>
<xsl:if test="mnvXpath:tributecaIsCustomHTML(('dummy'))">
@@ -62,19 +66,20 @@
<xsl:attribute name="lang">en</xsl:attribute>
</xsl:element>
</xsl:element>
- </xsl:element>
+ </xsl:element>
</xsl:otherwise>
</xsl:choose>
</dataSet>
</xsl:for-each>
- </xsl:element>
+ </xsl:element>
</xsl:template>
- <xsl:template name="nowplaying">
+ <xsl:template name="nowplaying">
<xsl:element name="directory">
<xsl:attribute name="name"><xsl:value-of select="string('Movie Trailers Now Playing')"/></xsl:attribute>
<xsl:attribute name="thumbnail"><xsl:value-of select="string('http://www.tribute.ca/images/tribute_title.gif')"/></xsl:attribute>
- <xsl:for-each select="//h3[string(span)='Movie Trailers Now Playing']/..//a">
+ <!-- ul = 1 for 'Movie Trailers Now Playing'-->
+ <xsl:for-each select="mnvXpath:tributecaGetAnchors(//ul[@class='clump'], 1)">
<dataSet>
<directoryThumbnail>http://www.tribute.ca/images/tribute_title.gif</directoryThumbnail>
<xsl:choose>
@@ -84,10 +89,10 @@
<xsl:otherwise>
<xsl:element name="item">
<title><xsl:value-of select="normalize-space(string(.))"/></title>
- <author>Tribute.ca</author>
- <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
+ <author>Tribute.ca</author>
+ <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
<description><xsl:value-of select="normalize-space(./@title)"/></description>
- <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Movie Trailers Now Playing']/..//a)"/></link>
+ <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ../..//a)"/></link>
<xsl:if test="mnvXpath:tributecaIsCustomHTML(('dummy'))">
<mythtv:customhtml>true</mythtv:customhtml>
</xsl:if>
@@ -96,7 +101,7 @@
<xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaThumbnailLink(string(.))"/></xsl:attribute>
</xsl:element>
<xsl:element name="media:content">
- <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Movie Trailers Now Playing']/..//a)"/></xsl:attribute>
+ <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ../..//a)"/></xsl:attribute>
<xsl:attribute name="duration"></xsl:attribute>
<xsl:attribute name="width"></xsl:attribute>
<xsl:attribute name="height"></xsl:attribute>
@@ -104,19 +109,20 @@
<xsl:attribute name="lang">en</xsl:attribute>
</xsl:element>
</xsl:element>
- </xsl:element>
+ </xsl:element>
</xsl:otherwise>
</xsl:choose>
</dataSet>
</xsl:for-each>
- </xsl:element>
+ </xsl:element>
</xsl:template>
- <xsl:template name="comingsoon">
+ <xsl:template name="comingsoon">
<xsl:element name="directory">
- <xsl:attribute name="name"><xsl:value-of select="string('Coming Soon Movie Trailers')"/></xsl:attribute>
+ <xsl:attribute name="name"><xsl:value-of select="string('Coming Soon Movie Trailers')"/></xsl:attribute>
<xsl:attribute name="thumbnail"><xsl:value-of select="string('http://www.tribute.ca/images/tribute_title.gif')"/></xsl:attribute>
- <xsl:for-each select="//h3[string(span)='Coming Soon Movie Trailers']/..//a">
+ <!-- ul = 3 for 'Coming Soon Movie Trailers'-->
+ <xsl:for-each select="mnvXpath:tributecaGetAnchors(//ul[@class='clump'], 3)">
<dataSet>
<directoryThumbnail>http://www.tribute.ca/images/tribute_title.gif</directoryThumbnail>
<xsl:choose>
@@ -126,10 +132,10 @@
<xsl:otherwise>
<xsl:element name="item">
<title><xsl:value-of select="normalize-space(string(.))"/></title>
- <author>Tribute.ca</author>
- <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
- <description><xsl:value-of select="concat(normalize-space(string(.)), ' coming ', normalize-space(string(../small/i)))"/></description>
- <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Coming Soon Movie Trailers']/..//a)"/></link>
+ <author>Tribute.ca</author>
+ <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
+ <description><xsl:value-of select="concat(normalize-space(string(.)), ' coming ', normalize-space(string(../small/i)))"/></description>
+ <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ../..//a)"/></link>
<xsl:if test="mnvXpath:tributecaIsCustomHTML(('dummy'))">
<mythtv:customhtml>true</mythtv:customhtml>
</xsl:if>
@@ -138,7 +144,7 @@
<xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaThumbnailLink(string(.))"/></xsl:attribute>
</xsl:element>
<xsl:element name="media:content">
- <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Coming Soon Movie Trailers']/..//a)"/></xsl:attribute>
+ <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ../..//a)"/></xsl:attribute>
<xsl:attribute name="duration"></xsl:attribute>
<xsl:attribute name="width"></xsl:attribute>
<xsl:attribute name="height"></xsl:attribute>
@@ -146,19 +152,20 @@
<xsl:attribute name="lang">en</xsl:attribute>
</xsl:element>
</xsl:element>
- </xsl:element>
+ </xsl:element>
</xsl:otherwise>
</xsl:choose>
</dataSet>
</xsl:for-each>
- </xsl:element>
+ </xsl:element>
</xsl:template>
- <xsl:template name="topupcoming">
+ <xsl:template name="topupcoming">
<xsl:element name="directory">
<xsl:attribute name="name"><xsl:value-of select="string('Top 10 Upcoming Trailers')"/></xsl:attribute>
<xsl:attribute name="thumbnail"><xsl:value-of select="string('http://www.tribute.ca/images/tribute_title.gif')"/></xsl:attribute>
- <xsl:for-each select="//h3[string(span)='Top 10 Upcoming Trailers']/..//a">
+ <!-- ul = 2 for 'Top 10 Upcoming Trailers'-->
+ <xsl:for-each select="mnvXpath:tributecaGetAnchors(//ul[@class='clump'], 2)">
<dataSet>
<directoryThumbnail>http://www.tribute.ca/images/tribute_title.gif</directoryThumbnail>
<xsl:choose>
@@ -168,10 +175,10 @@
<xsl:otherwise>
<xsl:element name="item">
<title><xsl:value-of select="normalize-space(string(.))"/></title>
- <author>Tribute.ca</author>
- <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
- <description><xsl:value-of select="normalize-space(./@title)"/></description>
- <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Top 10 Upcoming Trailers']/..//a)"/></link>
+ <author>Tribute.ca</author>
+ <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
+ <description><xsl:value-of select="normalize-space(./@title)"/></description>
+ <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ../..//a)"/></link>
<xsl:if test="mnvXpath:tributecaIsCustomHTML(('dummy'))">
<mythtv:customhtml>true</mythtv:customhtml>
</xsl:if>
@@ -180,7 +187,7 @@
<xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaThumbnailLink(string(.))"/></xsl:attribute>
</xsl:element>
<xsl:element name="media:content">
- <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Top 10 Upcoming Trailers']/..//a)"/></xsl:attribute>
+ <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ../..//a)"/></xsl:attribute>
<xsl:attribute name="duration"></xsl:attribute>
<xsl:attribute name="width"></xsl:attribute>
<xsl:attribute name="height"></xsl:attribute>
@@ -188,19 +195,20 @@
<xsl:attribute name="lang">en</xsl:attribute>
</xsl:element>
</xsl:element>
- </xsl:element>
+ </xsl:element>
</xsl:otherwise>
</xsl:choose>
</dataSet>
</xsl:for-each>
- </xsl:element>
+ </xsl:element>
</xsl:template>
- <xsl:template name="topboxoffice">
+ <xsl:template name="topboxoffice">
<xsl:element name="directory">
<xsl:attribute name="name"><xsl:value-of select="string('Top Box Office Movie Trailers')"/></xsl:attribute>
<xsl:attribute name="thumbnail"><xsl:value-of select="string('http://www.tribute.ca/images/tribute_title.gif')"/></xsl:attribute>
- <xsl:for-each select="//h3[string(span)='Top Box Office Movie Trailers']/..//a">
+ <!-- ul = 0 for 'Top Box Office Movie Trailers'-->
+ <xsl:for-each select="mnvXpath:tributecaGetAnchors(//ul[@class='clump'], 0)">
<dataSet>
<directoryThumbnail>http://www.tribute.ca/images/tribute_title.gif</directoryThumbnail>
<xsl:choose>
@@ -210,10 +218,10 @@
<xsl:otherwise>
<xsl:element name="item">
<title><xsl:value-of select="normalize-space(mnvXpath:tributecaTopTenTitle(string(..)))"/></title>
- <author>Tribute.ca</author>
- <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
- <description><xsl:value-of select="normalize-space(./@title)"/></description>
- <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Top Box Office Movie Trailers']/..//a)"/></link>
+ <author>Tribute.ca</author>
+ <pubDate><xsl:value-of select="mnvXpath:pubDate('Now')"/></pubDate>
+ <description><xsl:value-of select="normalize-space(./@title)"/></description>
+ <link><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ..//a)"/></link>
<xsl:if test="mnvXpath:tributecaIsCustomHTML(('dummy'))">
<mythtv:customhtml>true</mythtv:customhtml>
</xsl:if>
@@ -222,7 +230,7 @@
<xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaThumbnailLink(string(.))"/></xsl:attribute>
</xsl:element>
<xsl:element name="media:content">
- <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), //h3[string(span)='Top Box Office Movie Trailers']/..//a)"/></xsl:attribute>
+ <xsl:attribute name="url"><xsl:value-of select="mnvXpath:tributecaLinkGeneration(position(), ..//a)"/></xsl:attribute>
<xsl:attribute name="duration"></xsl:attribute>
<xsl:attribute name="width"></xsl:attribute>
<xsl:attribute name="height"></xsl:attribute>
@@ -230,12 +238,12 @@
<xsl:attribute name="lang">en</xsl:attribute>
</xsl:element>
</xsl:element>
- </xsl:element>
+ </xsl:element>
</xsl:otherwise>
</xsl:choose>
</dataSet>
</xsl:for-each>
- </xsl:element>
+ </xsl:element>
</xsl:template>
</xsl:stylesheet>
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/xsltfunctions/tributeca_api.py b/mythtv/programs/scripts/internetcontent/nv_python_libs/xsltfunctions/tributeca_api.py
index 0fc5369..a7376e0 100755
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/xsltfunctions/tributeca_api.py
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/xsltfunctions/tributeca_api.py
@@ -21,8 +21,9 @@ See this link for the specifications:
http://www.mythtv.org/wiki/MythNetvision_Grabber_Script_Format
'''
-__version__="v0.1.0"
+__version__="v0.1.1"
# 0.1.0 Initial development
+# 0.1.1 Changes to due to Web site modifications
# Specify the class names that have XPath extention functions
@@ -91,8 +92,9 @@ class xpathFunctions(object):
"""Functions specific extending XPath
"""
def __init__(self):
- self.functList = ['tributecaLinkGeneration', 'tributecaThumbnailLink', 'tributecaTopTenTitle', 'tributecaIsCustomHTML', 'tributecaCheckIfDBItem', ]
+ self.functList = ['tributecaLinkGeneration', 'tributecaThumbnailLink', 'tributecaTopTenTitle', 'tributecaIsCustomHTML', 'tributecaCheckIfDBItem', 'tributecaDebug', 'tributecaGetAnchors', ]
self.TextTail = etree.XPath("string()")
+ self.anchorList = etree.XPath(".//a", namespaces=common.namespaces)
self.persistence = {}
# end __init__()
@@ -104,12 +106,13 @@ class xpathFunctions(object):
def tributecaLinkGeneration(self, context, *args):
'''Generate a link for the Tribute.ca site. Sigificant massaging of the title is required.
- Call example: 'mnvXpath:tributecaLinkGeneration(string(.), string(preceding-sibling::a[1]))'
+ Call example: 'mnvXpath:tributecaLinkGeneration(position(), ..//a)'
return the url link
'''
downloadURL = u'http://www.tribute.ca/streamingflash/%s.flv'
position = int(args[0])-1
webURL = u'http://www.tribute.ca%s' % args[1][position].attrib['href'].strip()
+
# If this is for the download then just return what was found for the "link" element
if self.persistence.has_key('tributecaLinkGeneration'):
if self.persistence['tributecaLinkGeneration'] != None:
@@ -151,7 +154,6 @@ class xpathFunctions(object):
trailer2 = u'tr2'
if currentTitle.find(': An IMAX') != -1:
trailer2 = u'tr2'
-
titleArray[0] = titleArray[0].replace(u'&', u'and')
self.persistence['tributecaThumbnailLink'] = urllib.quote_plus(titleArray[0].lower().replace(u' ', u'_').replace(u"'", u'').replace(u'-', u'_').replace(u'?', u'').replace(u'.', u'').encode("utf-8"))
titleArray[0] = urllib.quote_plus(re.sub('[%s]' % re.escape(string.punctuation), '', titleArray[0].lower().replace(u' ', u'').encode("utf-8")))
@@ -159,7 +161,6 @@ class xpathFunctions(object):
# Verify that the FLV file url really exits. If it does not then use the Web page link.
videocode = u'%s%s' % (titleArray[0], trailer2)
flvURL = downloadURL % videocode
-
resultCheckUrl = common.checkURL(flvURL)
if not resultCheckUrl[0] or resultCheckUrl[1]['Content-Type'] != u'video/x-flv':
if trailer2 != u'':
@@ -183,7 +184,6 @@ class xpathFunctions(object):
flvURL = webURL
else:
flvURL = webURL
-
if flvURL != webURL:
self.persistence['tributecaLinkGeneration'] = videocode
return common.linkWebPage(u'dummycontext', 'tributeca')+videocode
@@ -252,6 +252,33 @@ class xpathFunctions(object):
return common.checkIfDBItem('dummy', {'feedtitle': 'Movie Trailers', 'title': arg[0].replace('Trailer', u'').strip(), 'author': arg[1], 'description': arg[2]})
# end tributecaCheckIfDBItem()
+ def tributecaGetAnchors(self, context, *arg):
+ ''' Routine used to get specific anchor elements.
+ Unfortunitely position dependant.
+ Call: mnvXpath:tributecaGetAnchors(//ul[@class='clump'], 3)
+ '''
+ return self.anchorList(arg[0][int(arg[1])])
+ # end tributecaGetAnchors()
+
+ def tributecaDebug(self, context, *arg):
+ ''' Routine only used for debugging. Prints out the node
+ passed as an argument. Not to be used in production.
+ Call example: mnvXpath:tributecaDebug(//a)
+ '''
+ testpath = etree.XPath(".//a", namespaces=common.namespaces)
+ print arg
+ count = 0
+ for x in arg:
+ sys.stdout.write(u'\nElement Count (%s):\n' % count)
+# for y in testpath(x):
+# sys.stdout.write(etree.tostring(y, encoding='UTF-8', pretty_print=True))
+ print "testpath(%s)" % testpath(x)
+ count+=1
+ print
+# sys.stdout.write(etree.tostring(arg[0], encoding='UTF-8', pretty_print=True))
+ return u"========tributecaDebug Called========="
+ # end tributecaDebug()
+
######################################################################################################
#
# End of XPath extension functions