From 934ed551b3636c883fb5ea85e90ea9cf08ca3c68 Mon Sep 17 00:00:00 2001 From: Sander Date: Thu, 28 Sep 2017 23:13:25 +0200 Subject: [PATCH] Add icon to bundle; check multiple thumbnails. --- Contents/Code/__init__.py | 46 +++++++++++++------ .../Services/URL/PBS Kids/ServiceCode.pys | 15 ++++-- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 2eda923..89517b0 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -49,12 +49,16 @@ def ShowPage(title, thumb): oc = ObjectContainer(title2=title) - oc.add(DirectoryObject(key=Callback(VideoPage, type='Episode', title=title), title='Full Episodes', - thumb=Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) + oc.add(DirectoryObject( + key = Callback(VideoPage, type='Episode', title=title), + title = 'Full Episodes', + thumb = Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) )) - oc.add(DirectoryObject(key=Callback(VideoPage, type='Clip', title=title), title='Clips', - thumb=Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) + oc.add(DirectoryObject( + key = Callback(VideoPage, type='Clip', title=title), + title = 'Clips', + thumb = Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) )) return oc @@ -76,22 +80,38 @@ def VideoPage(type, title, start=0): try: duration = item['videos']['iphone']['length'] except: duration = None - try: thumb = item['images']['originalres_16x9']['url'] - except: - try: thumb = item['images']['originalres_4x3']['url'] - except: thumb = '' + thumb = '' + images = ['kids-mezzannine-16x9', 'originalres_16x9', 'kids-mezzannine-4x3', 'originalres_4x3'] + + for img in images: + if img in item['images'] and 'url' in item['images'][img] and item['images'][img]['url']: + thumb = item['images'][img]['url'] + break if type == 'Clip': - oc.add(VideoClipObject(url=url, title=video_title, summary=summary, duration=duration, - thumb=Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) + oc.add(VideoClipObject( + url = url, + title = video_title, + summary = summary, + duration = duration, + thumb = Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) )) else: - oc.add(EpisodeObject(url=url, title=video_title, show=title, summary=summary, duration=duration, - thumb=Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) + oc.add(EpisodeObject( + url = url, + title = video_title, + show = title, + summary = summary, + duration = duration, + thumb = Resource.ContentsOfURLWithFallback(url=thumb, fallback=ICON) )) if int(json_obj['matched']) > end: - oc.add(NextPageObject(key=Callback(VideoPage, type=type, title=title, start=end), title='More ...')) + + oc.add(NextPageObject( + key = Callback(VideoPage, type=type, title=title, start=end), + title = 'More ...' + )) if len(oc) < 1: return ObjectContainer(header='Empty', message="There aren't any items") diff --git a/Contents/Services/URL/PBS Kids/ServiceCode.pys b/Contents/Services/URL/PBS Kids/ServiceCode.pys index 11985aa..69c7070 100644 --- a/Contents/Services/URL/PBS Kids/ServiceCode.pys +++ b/Contents/Services/URL/PBS Kids/ServiceCode.pys @@ -7,12 +7,17 @@ def MetadataObjectForURL(url): title = details['title'] summary = details['description'] - duration = details['videos']['ipad']['length'] - try: thumb = details['images']['originalres_16x9']['url'] - except: - try: thumb = details['images']['originalres_4x3']['url'] - except: thumb = '' + try: duration = details['videos']['iphone']['length'] + except: duration = None + + thumb = '' + images = ['kids-mezzannine-16x9', 'originalres_16x9', 'kids-mezzannine-4x3', 'originalres_4x3'] + + for img in images: + if img in details['images'] and 'url' in details['images'][img] and details['images'][img]['url']: + thumb = details['images'][img]['url'] + break if details['type'] =='Clip': return VideoClipObject(