Skip to content

Commit

Permalink
- Add support channels banners
Browse files Browse the repository at this point in the history
- New icons
  • Loading branch information
KOL committed Dec 22, 2015
1 parent 5298cd3 commit 13f9171
Show file tree
Hide file tree
Showing 40 changed files with 65 additions and 56 deletions.
116 changes: 64 additions & 52 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@
YT_VERSION = 'v3'

ICONS = {
'likes': R('q_ic_drawer_likes_playlist_normal.png'),
'favorites': R('q_ic_drawer_favorites_normal.png'),
'uploads': R('q_ic_drawer_uploads_normal.png'),
'watchHistory': R('q_ic_drawer_watch_history_normal.png'),
'watchLater': R('q_ic_drawer_watch_later_normal.png'),
'subscriptions': R('q_ic_drawer_subscriptions_normal.png'),
'browseChannels': R('q_ic_drawer_browse_channels_normal.png'),
'playlists': R('q_ic_drawer_playlists_normal.png'),
'whatToWhatch': R('q_ic_drawer_what_to_watch_normal.png'),
'account': R('ic_account_switcher_sign_in.png'),
'categories': R('q_ic_drawer_mix_normal.png'),
'options': R('api_ic_options.png'),
'suggestions': R('ic_edit_suggestion.png'),
'remove': R('ic_offline_dialog_remove.png'),
'next': R('q_ic_drawer_expand_normal.png'),
'offline': R('ic_offline_disabled.png'),
'search': R('ic_search.png'),
'likes': R('heart-full.png'),
'favorites': R('star-2.png'),
'uploads': R('outbox-2.png'),
'watchHistory': R('revert.png'),
'watchLater': R('clock.png'),
'subscriptions': R('podcast-2.png'),
'browseChannels': R('grid-2.png'),
'playlists': R('list.png'),
'whatToWhatch': R('home.png'),
'account': R('user-2.png'),
'categories': R('store.png'),
'options': R('settings.png'),
'suggestions': R('tag.png'),
'remove': R('bin.png'),
'next': R('arrow-right.png'),
'offline': R('power.png'),
'search': R('search.png'),
}

YT_EDITABLE = {
Expand Down Expand Up @@ -109,7 +109,6 @@ def ValidatePrefs():

@handler(PREFIX, TITLE, thumb=ICON)
def MainMenu(complete=False, offline=False):

oc = ObjectContainer(title2=TITLE, no_cache=True, replace_parent=False)
if offline:
ResetToken()
Expand Down Expand Up @@ -157,7 +156,7 @@ def MainMenu(complete=False, offline=False):
title=u'%s' % L('My channel'),
thumb=ICONS['account'],
))
AddSystemPlaylists(oc, 'me', ('watchLater', 'watchHistory', 'likes'))
FillChannelInfo(oc, 'me', ('watchLater', 'watchHistory', 'likes'))
oc.add(InputDirectoryObject(
key=Callback(
Search,
Expand Down Expand Up @@ -250,7 +249,6 @@ def VideoView(vid):

@route(PREFIX + '/video/info')
def VideoInfo(vid, pl_item_id=None):

oc = ObjectContainer()
res = ApiGetVideos(ids=[vid])

Expand Down Expand Up @@ -353,13 +351,12 @@ def Channels(oid, title, offset=None):

@route(PREFIX + '/channel')
def Channel(oid, title):

oc = ObjectContainer(
title2=u'%s' % title
)

# Add standart menu
AddSystemPlaylists(oc, oid)
FillChannelInfo(oc, oid)
if oid == 'me':
oc.add(DirectoryObject(
key=Callback(MainMenu, offline=True),
Expand Down Expand Up @@ -489,7 +486,7 @@ def Playlists(uid, title, offset=None):
)

if not offset and uid == 'me':
AddSystemPlaylists(oc, uid, ('watchLater', 'likes', 'favorites'))
FillChannelInfo(oc, uid, ('watchLater', 'likes', 'favorites'))
oc.add(InputDirectoryObject(
key=Callback(
Search,
Expand Down Expand Up @@ -555,7 +552,7 @@ def Playlist(oid, title, can_edit=False, offset=None):
@route(PREFIX + '/playlist/add')
def PlaylistAdd(aid, key=None, oid=None, a_type='video'):
if key is not None:
items = ApiGetSystemPlayLists('me')
items = ApiGetChannelInfo('me')['playlists']
if key in items:
oid = items[key]

Expand Down Expand Up @@ -633,34 +630,42 @@ def AddVideos(oc, res, title=None, extended=False, pl_map={}):
return oc


def AddSystemPlaylists(oc, uid, types=None):
def FillChannelInfo(oc, uid, pl_types=None):
info = ApiGetChannelInfo(uid)

items = ApiGetSystemPlayLists(uid)
if info['banner'] is not None:
oc.art = info['banner']

if items:
if types is not None:
items = dict(filter(lambda v: v[0] in types, items.items()))
if not info['playlists']:
return oc

for key in sorted(
items,
key=lambda v: v != 'uploads'
):
oc.add(DirectoryObject(
key=Callback(
Playlist,
oid=items[key],
title=L(key),
can_edit=uid == 'me' and key in YT_EDITABLE
),
title=u'%s' % L(key),
thumb=ICONS[key] if key in ICONS else None,
))
if pl_types is not None:
items = dict(filter(
lambda v: v[0] in pl_types,
info['playlists'].items()
))
else:
items = info['playlists']

for key in sorted(
items,
key=lambda v: v != 'uploads'
):
oc.add(DirectoryObject(
key=Callback(
Playlist,
oid=items[key],
title=L(key),
can_edit=uid == 'me' and key in YT_EDITABLE
),
title=u'%s' % L(key),
thumb=ICONS[key] if key in ICONS else None,
))

return oc


def AddPlaylists(oc, uid, offset=None):

res = ApiRequest('playlists', ApiGetParams(
uid=uid,
limit=GetLimitForOC(oc),
Expand Down Expand Up @@ -705,7 +710,6 @@ def AddPlaylists(oc, uid, offset=None):


def AddSubscriptions(oc, uid, offset=None):

res = ApiRequest('subscriptions', ApiGetParams(
uid=uid,
limit=GetLimitForOC(oc),
Expand Down Expand Up @@ -795,7 +799,6 @@ def AddItemsFromDescription(oc, description):


def Search(query=None, title=L('Search'), s_type='video', offset=0, **kwargs):

if not query and not kwargs:
return NoContents()

Expand Down Expand Up @@ -862,7 +865,6 @@ def Search(query=None, title=L('Search'), s_type='video', offset=0, **kwargs):

@route(PREFIX + '/authorization')
def Authorization():

code = None
if CheckAccessData('device_code'):
code = Dict['user_code']
Expand Down Expand Up @@ -961,18 +963,29 @@ def ApiGetVideos(ids=[], title=None, extended=False, **kwargs):
))


def ApiGetSystemPlayLists(uid):
def ApiGetChannelInfo(uid):
res = ApiRequest('channels', ApiGetParams(
part='contentDetails',
part='contentDetails,brandingSettings',
hl=GetLanguage(),
uid=uid,
id=uid if uid != 'me' else None
))

ret = {
'playlists': {},
'banner': None
}

if res and res['items']:
return res['items'][0]['contentDetails']['relatedPlaylists']
res = res['items'][0]
Log.Debug(res)
ret['playlists'] = res['contentDetails']['relatedPlaylists']
try:
ret['banner'] = res['brandingSettings']['image']['bannerTvHighImageUrl']
except:
pass

return {}
return ret


def ApiRequest(method, params, data=None, rmethod=None):
Expand Down Expand Up @@ -1035,7 +1048,6 @@ def ApiGetParams(part='snippet', offset=None, limit=None, uid=None, **kwargs):


def CheckToken():

if CheckAccessData('access_token'):
return True

Expand Down
2 changes: 0 additions & 2 deletions Contents/Code/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Updater:
update = None

def __init__(self, prefix, oc):

if self.InitBundleInfo() and self.IsUpdateAvailable():
Route.Connect(prefix, self.DoUpdate)
oc.add(DirectoryObject(
Expand All @@ -69,7 +68,6 @@ def NormalizeVersion(self, version):
return version

def ParseVersion(self, version):

try:
return tuple(map(int, (version.split('.'))))
except:
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>3.10</string>
<string>4.0</string>

<key>PlexPluginVersionUrl</key>
<string>http://bit.ly/1FuE3dz</string>
Expand Down
Binary file removed Contents/Resources/api_ic_options.png
Binary file not shown.
Binary file added Contents/Resources/arrow-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Contents/Resources/art-default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/bin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/grid-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/heart-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Contents/Resources/ic_account_switcher_sign_in.png
Binary file not shown.
Binary file removed Contents/Resources/ic_edit_suggestion.png
Binary file not shown.
Binary file removed Contents/Resources/ic_offline_dialog_remove.png
Binary file not shown.
Binary file removed Contents/Resources/ic_offline_disabled.png
Binary file not shown.
Binary file removed Contents/Resources/ic_search.png
Binary file not shown.
Binary file removed Contents/Resources/info_card_link.png
Binary file not shown.
Binary file added Contents/Resources/list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/outbox-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/podcast-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Contents/Resources/power.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed Contents/Resources/q_ic_drawer_expand_normal.png
Binary file not shown.
Binary file removed Contents/Resources/q_ic_drawer_favorites_normal.png
Binary file not shown.
Binary file not shown.
Binary file removed Contents/Resources/q_ic_drawer_mix_normal.png
Binary file not shown.
Binary file removed Contents/Resources/q_ic_drawer_playlists_normal.png
Binary file not shown.
Binary file removed Contents/Resources/q_ic_drawer_subscriptions_normal.png
Binary file not shown.
Binary file removed Contents/Resources/q_ic_drawer_uploads_normal.png
Diff not rendered.
Binary file removed Contents/Resources/q_ic_drawer_watch_history_normal.png
Diff not rendered.
Binary file removed Contents/Resources/q_ic_drawer_watch_later_normal.png
Diff not rendered.
Binary file removed Contents/Resources/q_ic_drawer_what_to_watch_normal.png
Diff not rendered.
Binary file added Contents/Resources/revert.png
Binary file added Contents/Resources/search.png
Binary file added Contents/Resources/settings-3.png
Binary file added Contents/Resources/star-2.png
Binary file added Contents/Resources/store.png
Binary file added Contents/Resources/tag.png
Binary file added Contents/Resources/user-2.png
1 change: 0 additions & 1 deletion Contents/Services/URL/YouTubeTV/ServiceCode.pys
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def MetadataObjectForURL(url):


def MediaObjectsForURL(url, definition='hd'):

definitions = Video.DEFINITIONS[definition]
if Prefs['play_highest']:
definitions = (Video.MAX_RESOLUTION,)
Expand Down

0 comments on commit 13f9171

Please sign in to comment.