Skip to content

Commit

Permalink
Backport r27231 to .24-fixes.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.mythtv.org/svn/branches/release-0-24-fixes@27232 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
Robert McNamara committed Nov 15, 2010
1 parent ae750cc commit 5465898
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 70 deletions.
Expand Up @@ -349,24 +349,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]
Expand All @@ -388,7 +391,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)
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down
Expand Up @@ -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>
Expand Down
Expand Up @@ -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">
Expand Down

0 comments on commit 5465898

Please sign in to comment.