def browse_album(self):
xbmcplugin.setContent(self.addon_handle, "songs")
album = self.sp.album(self.albumid, market=self.usercountry)
xbmcplugin.setProperty(self.addon_handle, 'FolderName', album["name"])
tracks = self.get_album_tracks(album)
if album.get("album_type") == "compilation":
self.add_track_listitems(tracks, True)
else:
self.add_track_listitems(tracks)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TRACKNUM)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_SONG_RATING)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_ARTIST)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_songs:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
python类SORT_METHOD_TITLE的实例源码
def listSeasonsFromSeries(series_id):
url = skygo.baseUrl + '/sg/multiplatform/web/json/details/series/' + str(series_id) + '_global.json'
r = requests.get(url)
data = r.json()['serieRecap']['serie']
xbmcplugin.setContent(addon_handle, 'seasons')
for season in data['seasons']['season']:
url = common.build_url({'action': 'listSeason', 'id': season['id'], 'series_id': data['id']})
label = '%s - Staffel %02d' % (data['title'], season['nr'])
li = xbmcgui.ListItem(label=label)
li.setProperty('IsPlayable', 'false')
li.setArt({'poster': skygo.baseUrl + season['path'],
'fanart': getHeroImage(data)})
li.setInfo('video', {'plot': data['synopsis'].replace('\n', '').strip()})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=True)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
def artist_toptracks(self):
xbmcplugin.setContent(self.addon_handle, "songs")
xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11011))
tracks = self.sp.artist_top_tracks(self.artistid, country=self.usercountry)
tracks = self.prepare_track_listitems(tracks=tracks["tracks"])
self.add_track_listitems(tracks)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TRACKNUM)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_SONG_RATING)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_songs:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
def browse_savedartists(self):
xbmcplugin.setContent(self.addon_handle, "artists")
xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(133))
artists = self.get_savedartists()
self.add_artist_listitems(artists)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_artists:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
def listEpisodesFromSeason(series_id, season_id):
url = skygo.baseUrl + '/sg/multiplatform/web/json/details/series/' + str(series_id) + '_global.json'
r = requests.get(url)
data = r.json()['serieRecap']['serie']
xbmcplugin.setContent(addon_handle, 'episodes')
for season in data['seasons']['season']:
if str(season['id']) == str(season_id):
for episode in season['episodes']['episode']:
#Check Altersfreigabe / Jugendschutzeinstellungen
if 'parental_rating' in episode:
if js_showall == 'false':
if not skygo.parentalCheck(episode['parental_rating']['value'], play=False):
continue
url = common.build_url({'action': 'playVod', 'vod_id': episode['id']})
li = xbmcgui.ListItem()
li.setProperty('IsPlayable', 'true')
li.addContextMenuItems(getWatchlistContextItem({'type': 'Episode', 'data': episode}), replaceItems=False)
info, episode = getInfoLabel('Episode', episode)
li.setInfo('video', info)
li.setLabel('%02d. %s' % (info['episode'], info['title']))
li.setArt({'poster': skygo.baseUrl + season['path'],
'fanart': getHeroImage(data),
'thumb': skygo.baseUrl + episode['webplayer_config']['assetThumbnail']})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=False)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_EPISODE)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
def setView(content, viewType):
''' Why recode whats allready written and works well,
Thanks go to Eldrado for it '''
if content:
xbmcplugin.setContent(int(sys.argv[1]), content)
if ADDON.getSetting('auto-view') == 'true':
print ADDON.getSetting(viewType)
if ADDON.getSetting(viewType) == 'Info':
VT = '504'
elif ADDON.getSetting(viewType) == 'Info2':
VT = '503'
elif ADDON.getSetting(viewType) == 'Info3':
VT = '515'
elif ADDON.getSetting(viewType) == 'Fanart':
VT = '508'
elif ADDON.getSetting(viewType) == 'Poster Wrap':
VT = '501'
elif ADDON.getSetting(viewType) == 'Big List':
VT = '51'
elif ADDON.getSetting(viewType) == 'Low List':
VT = '724'
elif ADDON.getSetting(viewType) == 'List':
VT = '50'
elif ADDON.getSetting(viewType) == 'Default Menu View':
VT = ADDON.getSetting('default-view1')
elif ADDON.getSetting(viewType) == 'Default TV Shows View':
VT = ADDON.getSetting('default-view2')
elif ADDON.getSetting(viewType) == 'Default Episodes View':
VT = ADDON.getSetting('default-view3')
elif ADDON.getSetting(viewType) == 'Default Movies View':
VT = ADDON.getSetting('default-view4')
elif ADDON.getSetting(viewType) == 'Default Docs View':
VT = ADDON.getSetting('default-view5')
elif ADDON.getSetting(viewType) == 'Default Cartoons View':
VT = ADDON.getSetting('default-view6')
elif ADDON.getSetting(viewType) == 'Default Anime View':
VT = ADDON.getSetting('default-view7')
xbmc.executebuiltin("Container.SetViewMode(%s)" % ( int(VT) ) )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_TITLE )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_TITLE )
def build_season_listing(self, seasons_sorted, build_url):
"""Builds the season list screen for a show
Parameters
----------
seasons_sorted : :obj:`list` of :obj:`dict` of :obj:`str`
Sorted list of season entries
build_url : :obj:`fn`
Function to build the subsequent routes
Returns
-------
bool
List could be build
"""
for season in seasons_sorted:
li = xbmcgui.ListItem(label=season['text'])
# add some art to the item
li = self._generate_art_info(entry=season, li=li)
# add list item info
li, infos = self._generate_entry_info(
entry=season,
li=li,
base_info={'mediatype': 'season'})
li = self._generate_context_menu_items(entry=season, li=li)
params = {'action': 'episode_list', 'season_id': season['id']}
if 'tvshowtitle' in infos:
title = infos.get('tvshowtitle', '').encode('utf-8')
params['tvshowtitle'] = base64.urlsafe_b64encode(title)
url = build_url(params)
xbmcplugin.addDirectoryItem(
handle=self.plugin_handle,
url=url,
listitem=li,
isFolder=True)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_LASTPLAYED)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.endOfDirectory(self.plugin_handle)
self.set_custom_view(VIEW_SEASON)
return True
def listAssets(asset_list, isWatchlist=False):
for item in asset_list:
isPlayable = False
li = xbmcgui.ListItem(label=item['label'], iconImage=icon_file)
if item['type'] in ['Film', 'Episode', 'Sport', 'Clip', 'Series', 'live', 'searchresult']:
isPlayable = True
#Check Altersfreigabe / Jugendschutzeinstellungen
if 'parental_rating' in item['data']:
if js_showall == 'false':
if not skygo.parentalCheck(item['data']['parental_rating']['value'], play=False):
continue
info, item['data'] = getInfoLabel(item['type'], item['data'])
# xbmc.log( "Debug_Info Current item Element: %s" % (item) )
li.setInfo('video', info)
li.setLabel(info['title'])
li.setArt({'poster': getPoster(item['data']), 'fanart': getHeroImage(item['data'])})
if item['type'] in ['Film']:
xbmcplugin.setContent(addon_handle, 'movies')
if xbmcaddon.Addon().getSetting('lookup_tmdb_data') == 'true' and 'TMDb_poster_path' in item['data']:
poster_path = item['data']['TMDb_poster_path']
else:
poster_path = getPoster(item['data'])
# xbmc.log('Debug-Info: Current Poster in item: %s' % getPoster(item['data']) )
# xbmc.log('Debug-Info: Current Poster in info: %s' % item['data']['TMDb_poster_path'] )
li.setArt({'poster': poster_path})
elif item['type'] in ['Series']:
xbmcplugin.setContent(addon_handle, 'tvshows')
isPlayable = False
elif item['type'] in ['Episode']:
xbmcplugin.setContent(addon_handle, 'episodes')
elif item['type'] in ['Sport', 'Clip']:
xbmcplugin.setContent(addon_handle, 'files')
li.setArt({'thumb': getHeroImage(item['data'])})
elif item['type'] == 'searchresult':
xbmcplugin.setContent(addon_handle, 'movies')
elif item['type'] == ('live'):
xbmcplugin.setContent(addon_handle, 'files')
if 'TMDb_poster_path' in item['data']:
poster = item['data']['TMDb_poster_path']
elif 'mediainfo' in item['data']:
poster = getPoster(item['data']['mediainfo'])
else:
poster = getPoster(item['data']['channel'])
fanart = skygo.baseUrl + item['data']['event']['image'] if item['data']['channel']['name'].find('News') == -1 else skygo.baseUrl + '/bin/Picture/817/C_1_Picture_7179_content_4.jpg'
thumb = skygo.baseUrl + item['data']['event']['image'] if item['data']['channel']['name'].find('News') == -1 else getChannelLogo(item['data']['channel'])
li.setArt({'poster': poster, 'fanart': fanart, 'thumb': thumb})
#add contextmenu item for watchlist to playable content - not for live and clip content
if isPlayable and not item['type'] in ['live', 'Clip']:
li.addContextMenuItems(getWatchlistContextItem(item, isWatchlist), replaceItems=False)
li.setProperty('IsPlayable', str(isPlayable).lower())
xbmcplugin.addDirectoryItem(handle=addon_handle, url=item['url'],
listitem=li, isFolder=(not isPlayable))
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION)
xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)