Skip to content

Commit

Permalink
- Add support locale settings for video preview
Browse files Browse the repository at this point in the history
- Fix processing some kinds of videos
  • Loading branch information
KOL committed Jun 2, 2015
1 parent cb4d848 commit 53e11e4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def MySubscriptions(offset=None):
@route(PREFIX + '/video/view')
def VideoView(vid):
return URLService.MetadataObjectForURL(
url=Video.GetServiceURL(vid, Dict['access_token']),
url=Video.GetServiceURL(vid, Dict['access_token'], GetLanguage()),
in_container=True
)

Expand Down
2 changes: 1 addition & 1 deletion Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<key>CFBundleSignature</key>
<string>hook</string>
<key>CFBundleVersion</key>
<string>2.8</string>
<string>2.9</string>

<key>PlexPluginVersionUrl</key>
<string>https://api.github.com/repos/kolsys/YouTubeTV.bundle/releases/latest</string>
Expand Down
16 changes: 13 additions & 3 deletions Contents/Services/Shared Code/video.pys
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ USER_AGENT = (
)


def GetServiceURL(vid, token=''):
return 'http://tv.youtube.plugins.plex.com/%s%s%s' % (
def GetServiceURL(vid, token='', hl=''):
return 'http://tv.youtube.plugins.plex.com/%s%s%s%s%s' % (
vid,
'&access_token=' if token else '',
token
token,
'&hl=' if hl else '',
hl
)


Expand Down Expand Up @@ -144,6 +146,14 @@ def GetUrlFromStream(item):
return ret


def GetFromMainContent(item, key):
try:
cont = item['video_main_content']['contents'][0]
return cont[key]['runs'][0]['text']
except:
return ''


def CalculateOffset(position):
'''
Workaround for YT bug
Expand Down
16 changes: 12 additions & 4 deletions Contents/Services/URL/YouTubeTV/ServiceCode.pys
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,21 @@ def MetadataObjectForURL(url):
if thumb[0] == '/':
thumb = 'http:%s' % thumb

try:
summary = u'%s\n%s' % (
item['video']['public_name'],
item['video']['description']
)
except:
summary = u'%s\n%s' % (
Video.GetFromMainContent(item, 'short_byline_text'),
Video.GetFromMainContent(item, 'description'),
)

return VideoClipObject(
title=u'%s' % item['video']['title'],
rating_key=url.split('&')[0],
summary=u'%s\n%s' % (
item['video']['public_name'],
item['video']['description']
),
summary=summary,
thumb=thumb,
rating=(float(meta['avg_rating'])*2),
tags=meta['keywords'].split(','),
Expand Down

0 comments on commit 53e11e4

Please sign in to comment.