Permalink
Browse files

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
  • Loading branch information...
1 parent 262c98f commit 2c2d496dff8b8e323ffa49053881718ff51b70f5 Robert McNamara committed Nov 15, 2010
@@ -20,13 +20,14 @@
"~/.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,24 +350,27 @@ def searchTitle(self, title, pagenumber, pagelen):
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':
link = u'http://www.bbc.co.uk/iplayer/bigscreen%s' % link.replace(u'/iplayer',u'')
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 @@ def searchTitle(self, title, pagenumber, pagelen):
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)
@@ -18,7 +18,7 @@
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 @@
# 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 @@ def __init__ (self, urlKey, debug):
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 @@ def run(self):
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 @@ def run(self):
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:
@@ -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>
@@ -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">
Oops, something went wrong. Retry.

0 comments on commit 2c2d496

Please sign in to comment.