diff --git a/mythtv/bindings/python/MythTV/methodheap.py b/mythtv/bindings/python/MythTV/methodheap.py index 43a673a..3ad22d4 100644 --- a/mythtv/bindings/python/MythTV/methodheap.py +++ b/mythtv/bindings/python/MythTV/methodheap.py @@ -995,6 +995,10 @@ class MythXML( XMLConnection ): find('InternetContent').findall('grabber'): yield InternetSource.fromEtree(grabber, self) + def getInternetContentUrl(self, grabber, videocode): + return "mythflash://%s:%s/Myth/GetInternetContent?Grabber=%s&videocode=%s" \ + % (self.host, self.port, grabber, videocode) + def getPreviewImage(self, chanid, starttime, width=None, \ height=None, secsin=None): starttime = datetime.duck(starttime) diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/vimeo.html b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/vimeo.html new file mode 100644 index 0000000..755379e --- /dev/null +++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/vimeo.html @@ -0,0 +1,91 @@ + + + + + + + + +
+ + diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/youtube.html b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/youtube.html index 49ffd8a..f6b9161 100644 --- a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/youtube.html +++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/youtube.html @@ -1,30 +1,83 @@ - - - - + + + + + + + +
+ diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/vimeo/vimeo_api.py b/mythtv/programs/scripts/internetcontent/nv_python_libs/vimeo/vimeo_api.py index 572e180..5fa3bad 100644 --- a/mythtv/programs/scripts/internetcontent/nv_python_libs/vimeo/vimeo_api.py +++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/vimeo/vimeo_api.py @@ -61,6 +61,7 @@ import pycurl import xml.etree.ElementTree as ET import inspect import oauth.oauth_api as oauth +from MythTV import MythXML from vimeo_exceptions import (VimeoUrlError, VimeoHttpError, VimeoResponseError, VimeoVideoNotFound, VimeoRequestTokenError, VimeoAuthorizeTokenError, VimeoVideosSearchError, VimeoAllChannelError, __errmsgs__) @@ -669,6 +670,7 @@ class Videos(object): """ self.config = {} + self.mythxml = MythXML() self.config['debug_enabled'] = debug # show debugging messages @@ -886,6 +888,10 @@ class Videos(object): # end initializeVimeo() + def processVideoUrl(self, url): + playerUrl = self.mythxml.getInternetContentUrl("nv_python_libs/configs/HTML/vimeo.html", \ + url.replace(u'http://vimeo.com/', '')) + return self.ampReplace(playerUrl) def searchTitle(self, title, pagenumber, pagelen): '''Key word video search of the vimeo.com web site @@ -980,7 +986,7 @@ class Videos(object): if url.get('type') == 'video': if url.text: # Make the link fullscreen and auto play if embed_flag: - v_details[url.tag] = self.ampReplace(url.text.strip().replace(u'http://vimeo.com/', u'http://vimeo.com/moogaloop.swf?clip_id=')+u'&autoplay=1') + v_details[url.tag] = self.processVideoUrl(url.text.strip()) else: v_details[url.tag] = self.ampReplace(url.text.strip()) else: @@ -1378,7 +1384,7 @@ class Videos(object): if url.get('type') == 'video': if url.text: # Make the link fullscreen and auto play if embed_flag: - v_details[url.tag] = self.ampReplace(url.text.strip().replace(u'http://vimeo.com/', u'http://vimeo.com/moogaloop.swf?clip_id=')+u'&autoplay=1') + v_details[url.tag] = self.processVideoUrl(url.text.strip()) else: v_details[url.tag] = self.ampReplace(url.text.strip()) else: diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/youtube/youtube_api.py b/mythtv/programs/scripts/internetcontent/nv_python_libs/youtube/youtube_api.py index 70d8a82..fe70938 100644 --- a/mythtv/programs/scripts/internetcontent/nv_python_libs/youtube/youtube_api.py +++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/youtube/youtube_api.py @@ -38,6 +38,7 @@ __version__="v0.2.5" import os, struct, sys, re, time import urllib, urllib2 import logging +from MythTV import MythXML try: import xml.etree.cElementTree as ElementTree @@ -148,6 +149,7 @@ class Videos(object): """ self.config = {} + self.mythxml = MythXML() if apikey is not None: self.config['apikey'] = apikey @@ -522,7 +524,7 @@ class Videos(object): continue if not elem.get(key) == '5': continue - item['video'] = self.ampReplace((elem.get('url')+'&autoplay=1')) + self.processVideoUrl(item, elem) flash = True continue if not item.has_key('video'): @@ -715,6 +717,18 @@ class Videos(object): return [[self.channel, dictionaries]] # end displayTreeView() + def processVideoUrl(self, item, elem): + '''Processes elem.get('url') to either use a custom HTML page served by + the backend, or include '&autoplay=1' + ''' + m = re.search('/v/([^?]+)', elem.get('url')) + if m: + url = self.mythxml.getInternetContentUrl("nv_python_libs/configs/HTML/youtube.html", \ + m.group(1)) + item['video'] = self.ampReplace(url) + else: + item['video'] = self.ampReplace((elem.get('url')+'&autoplay=1')) + def makeURL(self, URL): '''Form a URL to search for videos return a URL @@ -868,7 +882,7 @@ class Videos(object): if not elem.get(key) == '5': continue if elem.get('url'): - metadata['video'] = self.ampReplace((elem.get('url')+'&autoplay=1')) + self.processVideoUrl(metadata, elem) flash = True continue