Mapping YouTube API responses to the internal simpler format recognized by OMXPlayer plugin
This commit is contained in:
parent
679cad53b5
commit
b7603ba166
1 changed files with 11 additions and 1 deletions
|
@ -440,7 +440,7 @@ class VideoOmxplayerPlugin(Plugin):
|
|||
self.logger.info('Searching YouTube for "{}"'.format(query))
|
||||
|
||||
try:
|
||||
return get_plugin('google.youtube').search(query=query)
|
||||
return self._youtube_search_api(query=query)
|
||||
except Exception as e:
|
||||
self.logger.warning('Unable to load the YouTube plugin, falling ' +
|
||||
'back to HTML parse method: {}'.format(str(e)))
|
||||
|
@ -448,6 +448,16 @@ class VideoOmxplayerPlugin(Plugin):
|
|||
return self._youtube_search_html_parse(query=query)
|
||||
|
||||
|
||||
def _youtube_search_api(self, query):
|
||||
return [
|
||||
{
|
||||
'url': 'https://www.youtube.com/watch?v=' + item['id']['videoId'],
|
||||
'title' item.get('snippet', {}).get('title', '<No Title>'),
|
||||
}
|
||||
for item in get_plugin('google.youtube').search(query=query).output
|
||||
if item.get('id', {}).get('kind') == 'youtube#video'
|
||||
]
|
||||
|
||||
def _youtube_search_html_parse(self, query):
|
||||
query = urllib.parse.quote(query)
|
||||
url = "https://www.youtube.com/results?search_query=" + query
|
||||
|
|
Loading…
Reference in a new issue