def showShows(category_url):
"""Display all shows under a sub category
params:
category_url: a sub category is a unique id
"""
showListData = get_show_list(category_url)
if showListData is None:
xbmcplugin.endOfDirectory(thisPlugin)
return
for show_id, (title, thumbnail) in showListData.iteritems():
addDir(title, str(show_id), Mode.SHOW_INFO, thumbnail)
xbmcplugin.addSortMethod(thisPlugin, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
xbmcplugin.endOfDirectory(thisPlugin)
python类addSortMethod()的实例源码
def browse_topartists(self):
xbmcplugin.setContent(self.addon_handle, "artists")
result = self.sp.current_user_top_artists(limit=20, offset=0)
cachestr = "spotify.topartists.%s" % self.userid
checksum = self.cache_checksum(result["total"])
items = self.cache.get(cachestr, checksum=checksum)
if not items:
count = len(result["items"])
while result["total"] > count:
result["items"] += self.sp.current_user_top_artists(limit=20, offset=count)["items"]
count += 50
items = self.prepare_artist_listitems(result["items"])
self.cache.set(cachestr, items, checksum=checksum)
self.add_artist_listitems(items)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_artists:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
def browse_toptracks(self):
xbmcplugin.setContent(self.addon_handle, "songs")
results = self.sp.current_user_top_tracks(limit=20, offset=0)
cachestr = "spotify.toptracks.%s" % self.userid
checksum = self.cache_checksum(results["total"])
items = self.cache.get(cachestr, checksum=checksum)
if not items:
items = results["items"]
while results["next"]:
results = self.sp.next(results)
items.extend(results["items"])
items = self.prepare_track_listitems(tracks=items)
self.cache.set(cachestr, items, checksum=checksum)
self.add_track_listitems(items, True)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_songs:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
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)
def search_tracks(self):
xbmcplugin.setContent(self.addon_handle, "songs")
xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(134))
result = self.sp.search(
q="track:%s" %
self.trackid,
type='track',
limit=self.limit,
offset=self.offset,
market=self.usercountry)
tracks = self.prepare_track_listitems(tracks=result["tracks"]["items"])
self.add_track_listitems(tracks, True)
self.add_next_button(result['tracks']['total'])
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_songs:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
def search_albums(self):
xbmcplugin.setContent(self.addon_handle, "albums")
xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(132))
result = self.sp.search(
q="album:%s" %
self.albumid,
type='album',
limit=self.limit,
offset=self.offset,
market=self.usercountry)
albumids = []
for album in result['albums']['items']:
albumids.append(album["id"])
albums = self.prepare_album_listitems(albumids)
self.add_album_listitems(albums, True)
self.add_next_button(result['albums']['total'])
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_albums:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_albums)
def show_sport_selection(self):
"""Creates the KODI list items for the static sport selection"""
self.utils.log('Sport selection')
sports = self.constants.get_sports_list()
for sport in sports:
url = self.utils.build_url({'for': sport})
list_item = xbmcgui.ListItem(label=sports.get(sport).get('name'))
list_item = self.item_helper.set_art(
list_item=list_item,
sport=sport)
xbmcplugin.addDirectoryItem(
handle=self.plugin_handle,
url=url,
listitem=list_item,
isFolder=True)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_DATE)
xbmcplugin.endOfDirectory(self.plugin_handle)
def channeltypes(params,url,category):
logger.info("channelselector.channeltypes")
lista = getchanneltypes()
for item in lista:
addfolder(item.title,item.channel,item.action,category=item.category,thumbnailname=item.thumbnail)
if config.get_platform()=="kodi-krypton":
import plugintools
plugintools.set_view( plugintools.TV_SHOWS )
# Label (top-right)...
import xbmcplugin
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
if config.get_setting("forceview")=="true":
# Confluence - Thumbnail
import xbmc
xbmc.executebuiltin("Container.SetViewMode(500)")
def listchannels(params,url,category):
logger.info("channelselector.listchannels")
lista = filterchannels(category)
for channel in lista:
if config.is_xbmc() and (channel.type=="xbmc" or channel.type=="generic"):
addfolder(channel.title , channel.channel , "mainlist" , channel.channel)
elif config.get_platform()=="boxee" and channel.extra!="rtmp":
addfolder(channel.title , channel.channel , "mainlist" , channel.channel)
if config.get_platform()=="kodi-krypton":
import plugintools
plugintools.set_view( plugintools.TV_SHOWS )
# Label (top-right)...
import xbmcplugin
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
if config.get_setting("forceview")=="true":
# Confluence - Thumbnail
import xbmc
xbmc.executebuiltin("Container.SetViewMode(500)")
def MyRecordings(url,group):
net.set_cookies(cookie_jar)
url='http://www.filmon.com/my/recordings'
html = net.http_GET(url).content
link = html.encode('ascii', 'ignore')
match=re.compile('"stream_url":"(.+?),"stream_name":"(.+?)","id":".+?","title":"(.+?)","description":"(.+?)","channel_id":"(.+?)"').findall(link)
for a, playPath, name, description, channel in match:
url1=str(a).replace('\/','/')
url2=str(a).replace('\/','/').replace('"','')
regex = re.compile('rtmp://(.+?)/(.+?)/(.+?)/(.+?)/(.+?)/(.+?)/(.+?)"')
match1 = regex.search(url1)
try:
app = '%s/%s/%s/%s/%s/%s' %(match1.group(2), match1.group(3),match1.group(4),match1.group(5),match1.group(6),match1.group(7))
except:
app=''
tcUrl=str(url2)
iconimage='https://static.filmon.com/couch/channels/%s/big_logo.png' % str(channel)
swfUrl= 'http://www.filmon.com/tv/modules/FilmOnTV/files/flashapp/filmon/FilmonPlayer.swf'
pageUrl = 'http://www.filmon.com/my/recordings'
url= str(url2)+'/'+str(playPath)+' playpath='+str(playPath)+' app='+str(app)+' swfUrl='+str(swfUrl)+' tcUrl='+str(tcUrl)+' pageurl='+str(pageUrl)
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
addLink(name,url,iconimage,playPath,app,pageUrl,swfUrl,tcUrl,description)
setView('movies', 'epg')
def addDir(name,url,mode,iconimage,plot='',isFolder=True):
try:
PID = iconimage.split('productionId=')[1]
except:pass
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)
ok=True
liz=xbmcgui.ListItem(name,iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": plot,'Premiered' : '2012-01-01','Episode' : '7-1' } )
menu=[]
if mode == 2:
menu.append(('[COLOR yellow]Add To Favourites[/COLOR]','XBMC.RunPlugin(%s?mode=13&url=%s&name=%s&iconimage=%s)'% (sys.argv[0],url,name,PID)))
if mode == 204:
menu.append(('[COLOR yellow]Remove Favourite[/COLOR]','XBMC.RunPlugin(%s?mode=14&url=%s&name=%s&iconimage=%s)'% (sys.argv[0],url,name,iconimage)))
liz.addContextMenuItems(items=menu, replaceItems=False)
if mode==3:
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
if isFolder==False:
liz.setProperty("IsPlayable","true")
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isFolder)
return ok
def TG4_CATCHUP(name):
link= OPEN_URL('http://www.tg4.ie/wp-content/themes/tg4-starter/assets/json/tg4data.json')#.encode('utf8')
#print link.encode('ascii','ignore')
import json
data=json.loads(link)
uniques=[]
for field in data:
id= field['id']
iconimage=field['videoStillURL']
description=htmlcleaner.cleanUnicode(field['shortDescription'])
name=htmlcleaner.cleanUnicode(field['customFields']['seriestitle'])
if name not in uniques:
uniques.append(name)
try:addDir(name,'url',12,iconimage,description)
except:pass
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
def GetContent(url):
CHANNEL = url
xunity='http://vschedules.uktv.co.uk/mobile/v2/most_popular?channel=%s&carousel_limit=100&platform=ios&app_ver=4.1.0' % CHANNEL
response=OPEN_URL(xunity)
link=json.loads(response)
#data=link['brands']
for field in link:
name= field['brand_name'].encode("utf-8")
iconimage= field['brand_image'].encode("utf-8")
channel=field['channel'].encode("utf-8")
try:desc=field['teaser_text'].encode("utf-8")
except:desc=''
brand_id=field['brand_id']
if CHANNEL in channel:
addDir(name.strip(),str(brand_id),2,iconimage,desc)
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
setView('movies', 'default')
def GetCat(url):
xunity='http://vschedules.uktv.co.uk/mobile/v2/genres?platform=ios&app_ver=4.1.0'
response=OPEN_URL(xunity)
link=json.loads(response)
#data=link['data']
for field in link:
name= field['title'].encode("utf-8")
iconimage= field['image'].encode("utf-8")
brand_id=field['name']
addDir(name.strip(),str(brand_id),4,iconimage,'')
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
setView('movies', 'default')
def GetEpisodes(url):
xunity='http://vschedules.uktv.co.uk/mapi/branddata/?format=json&brand_id='+url
response=OPEN_URL(xunity)
link=json.loads(response)
data=link['videos']
for field in data:
name= 'S'+field['series_txt']+'E'+field['episode_txt']+' - '+field['brand_name'].encode("utf-8")
iconimage= field['episode_img_cached'].encode("utf-8")
channel=field['channel'].encode("utf-8")
desc=field['teaser_text'].encode("utf-8")
brightcove=field['brightcove_video_id']
addDir(name,str(brightcove),200,iconimage,desc)
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
setView('movies', 'default')
def FindSearch(url):
response=OPEN_URL(url)
link=json.loads(response)
link=link['brands']
for field in link:
count=field['video_count']
channel=field['channel'].encode("utf-8").title()
color='grey'
if 'Dave' in channel:
color='green'
if 'Drama' in channel:
color='red'
if 'Yesterday' in channel:
color='yellow'
if 'Really' in channel:
color='orange'
name= field['brand_name'].encode("utf-8") + ' (%s Episodes) - [COLOR %s]%s[/COLOR]' % (str(count),color,channel)
iconimage= field['brand_image'].encode("utf-8")
brand_id=field['brand_id']
addDir(name.strip(),str(brand_id),2,iconimage,'')
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
setView('movies', 'default')
def show_listing(self, list_items, sort=None):
listing = []
for title_item in list_items:
list_item = xbmcgui.ListItem(label=title_item.title)
url = self._url + '?' + urlencode(title_item.url_dictionary)
list_item.setProperty('IsPlayable', str(title_item.is_playable))
if title_item.thumbnail is not None:
list_item.setArt({'thumb': title_item.thumbnail})
list_item.setInfo('video', title_item.video_dictionary)
listing.append((url, list_item, not title_item.is_playable))
xbmcplugin.addDirectoryItems(self._handle, listing, len(listing))
if sort is not None:
kodi_sorts = {sortmethod.ALPHABET: xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE}
kodi_sortmethod = kodi_sorts.get(sort)
xbmcplugin.addSortMethod(self._handle, kodi_sortmethod)
xbmcplugin.endOfDirectory(self._handle)
def router(paramstring):
"""Decides what to do based on script parameters"""
check_settings()
params = dict(parse_qsl(paramstring))
# Nothing to do yet with those
if not params:
# Demo channel list
channels = map_channels(filter_channels(get_tv_channels()))
xbmcplugin.addDirectoryItems(plugin_handle, channels, len(channels))
xbmcplugin.addSortMethod(
plugin_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
xbmcplugin.endOfDirectory(plugin_handle)
elif params['action'] == 'play':
play_channel(params['channel'])
elif params['action'] == 'get_user_id':
get_user_id()
channelselector.py 文件源码
项目:plugin.video.streamondemand-pureita
作者: orione7
项目源码
文件源码
阅读 16
收藏 0
点赞 0
评论 0
def channeltypes(params,url,category):
logger.info("channelselector.mainlist channeltypes")
categoria=category.decode('latin1').encode('utf-8')
if config.get_localized_string(30119) in categoria:
lista = getchanneltypes()
for item in lista:
addfolder(item.title,item.channel,item.action,item.category,item.thumbnail,item.thumbnail)
# Label (top-right)...
import xbmcplugin
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
if config.get_setting("forceview")=="true":
# Confluence - Thumbnail
import xbmc
xbmc.executebuiltin("Container.SetViewMode(500)")
else:
listchannels({'action': 'listchannels', 'category': '%2a', 'channel': 'channelselector'},'','*')
def LIST_MOVIES(filter='', value=False, sortcol=False, sortaz=True, search=False, cmmode=0):
import movies as moviesDB
if 'year' in filter:
value = value.replace('0 -', '')
movies = moviesDB.loadMoviedb(movie_filter=filter, value=value, sortcol=sortcol)
count = 0
for moviedata in movies:
count += 1
ADD_MOVIE_ITEM(moviedata, cmmode=cmmode)
if not search:
if sortaz:
if 'year' not in filter:
xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_TITLE)
xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RUNTIME)
xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RATING)
xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_DURATION)
xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE)
common.SetView('movies')
return count
def LIST_TVSHOWS(filter='', value=False, sortcol=False, sortaz=True, search=False, cmmode=0):
import tv as tvDB
if 'year' in filter:
value = value.replace('0 -', '')
shows = tvDB.loadTVShowdb(filter=filter, value=value, sortcol=sortcol)
count = 0
for showdata in shows:
count += 1
ADD_SHOW_ITEM(showdata, cmmode=cmmode)
if not search:
if sortaz:
if 'year' not in filter:
xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RATING)
xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE)
common.SetView('tvshows')
return count
def list_categories():
listing=[]
list_item = xbmcgui.ListItem(label='??', thumbnailImage='')
url='{0}?action=game_list'.format(_url)
is_folder=True
listing.append((url, list_item, is_folder))
list_item = xbmcgui.ListItem(label='Lyingman', thumbnailImage='')
url='{0}?action=lyingman'.format(_url)
is_folder=True
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle,listing,len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
def game_list():
f = urllib2.urlopen('http://www.zhanqi.tv/api/static/game.lists/100-1.json?rand={ts}'.format(ts=time.time()))
obj = json.loads(f.read())
listing=[]
for game in obj['data']['games']:
list_item = xbmcgui.ListItem(label=game['name'], thumbnailImage=game['bpic'])
list_item.setProperty('fanart_image', game['bpic'])
url='{0}?action=room_list&game_id={1}'.format(_url, game['id'])
#xbmc.log(url, 1)
is_folder=True
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle,listing,len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
def room_list(game_id):
f = urllib2.urlopen('http://www.zhanqi.tv/api/static/game.lives/{game_id}/100-1.json?rand={ts}'.format(game_id=game_id, ts=time.time()))
obj = json.loads(f.read())
listing=[]
for room in obj['data']['rooms']:
list_item = xbmcgui.ListItem(label=room['title'], thumbnailImage=room['bpic'])
list_item.setProperty('fanart_image', room['bpic'])
url='{0}?action=play&room_id={1}'.format(_url, room['id'])
is_folder=False
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
def rootDir():
print sys.argv
nav = getNav()
#Livesender
liveChannelsDir()
#Navigation der Ipad App
for item in nav:
if item.attrib['hide'] == 'true' or item.tag == 'item':
continue
url = common.build_url({'action': 'listPage', 'id': item.attrib['id']})
addDir(item.attrib['label'], url)
li = xbmcgui.ListItem(item.attrib['label'])
#Merkliste
watchlistDir()
#Suchfunktion
url = common.build_url({'action': 'search'})
addDir('Suche', url)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
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 SelectHost():
for host in HostsList:
if ADDON.getSetting(host[0]) == 'true':
hostName = host[1].replace("https:",'').replace("http:",'').replace("/",'').replace("www.",'')
hostImage = '%s/icons/%s.png' % (ADDON.getSetting("kodiIPTVpath"), host[0])
list_item = xbmcgui.ListItem(label = hostName)
list_item.setArt({'thumb': hostImage,})
list_item.setInfo('video', {'title': hostName, 'genre': hostName})
url = get_url(action='startHost', host=host[0])
myLog(url)
is_folder = True
# Add our item to the Kodi virtual folder listing.
xbmcplugin.addDirectoryItem(ADDON_handle, url, list_item, is_folder)
# Add a sort method for the virtual folder items (alphabetically, ignore articles)
xbmcplugin.addSortMethod(ADDON_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(ADDON_handle)
return
def browse_main(self):
# main listing
xbmcplugin.setContent(self.addon_handle, "files")
items = []
items.append(
(self.addon.getLocalizedString(11013),
"plugin://plugin.audio.spotify/?action=browse_main_library",
"DefaultMusicCompilations.png", True))
items.append(
(self.addon.getLocalizedString(11014),
"plugin://plugin.audio.spotify/?action=browse_main_explore",
"DefaultMusicGenres.png", True))
items.append(
(xbmc.getLocalizedString(137),
"plugin://plugin.audio.spotify/?action=search",
"DefaultMusicSearch.png", True))
items.append(
("%s: %s" % (self.addon.getLocalizedString(11039), self.playername),
"plugin://plugin.audio.spotify/?action=browse_playback_devices",
"DefaultMusicPlugins.png", True))
if self.addon.getSetting("multi_account") == "true":
cur_user_label = self.sp.me()["display_name"]
if not cur_user_label:
cur_user_label = self.sp.me()["id"]
label = "%s: %s" % (self.addon.getLocalizedString(11047), cur_user_label)
items.append(
(label,
"plugin://plugin.audio.spotify/?action=switch_user",
"DefaultActor.png", False))
for item in items:
li = xbmcgui.ListItem(
item[0],
path=item[1],
iconImage=item[2]
)
li.setProperty('IsPlayable', 'false')
li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
li.addContextMenuItems([], True)
xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item[1], listitem=li, isFolder=item[3])
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
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 related_artists(self):
xbmcplugin.setContent(self.addon_handle, "artists")
xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11012))
cachestr = "spotify.relatedartists.%s" % self.artistid
checksum = self.cache_checksum()
artists = self.cache.get(cachestr, checksum=checksum)
if not artists:
artists = self.sp.artist_related_artists(self.artistid)
artists = self.prepare_artist_listitems(artists['artists'])
self.cache.set(cachestr, artists, checksum=checksum)
self.add_artist_listitems(artists)
xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.endOfDirectory(handle=self.addon_handle)
if self.defaultview_artists:
xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)