orginal nutzt nBox die Random Epsiode Funktion von Skin Widget. Da ich mich nicht wirklich mit Python, XBMC Addonsl und Skins auskenne und die Orginal Random Episode Funktion nicht brauche habe ich diese einfach geändert.
Die geänderte Random Episoden Funktion die nun Random Serien holt (request.py):
def episodes(self, request):
json_string = '{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetTVShows", "params": { "properties": ["title", "genre", "year", "rating", "plot", "studio", "mpaa", "cast", "playcount", "episode", "imdbnumber", "premiered", "votes", "lastplayed", "fanart", "thumbnail", "file", "art", "sorttitle", "episodeguide"], "limits": {"end": %d},' %LIMIT
if request == 'RecentEpisode' and RECENTITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
elif request == 'RecentEpisode':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}}}' %json_string)
elif request == 'RandomEpisode' and RANDOMITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
else:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }}}' %json_string)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
if json_query.has_key('result') and json_query['result'].has_key('tvshows'):
return json_query
else:
return False
Alles anzeigen
und die geänderte Random Episoden Funktion die die Daten für den Skin bereit stellt (properties.py):
def episodes(self, request, data):
if data:
season_folders = __addon__.getSetting("randomitems_seasonfolders")
clear_properties(request)
count = 0
for item in data['result']['tvshows']:
count += 1
'''
# This part is commented out because it takes 1.5second extra on my system to request these which doubles the total time.
# Hence the ugly path hack that will require users to have season folders.
data2 = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShowDetails", "params": {"properties": ["file", "studio"], "tvshowid":%s}, "id": 1}' %item['tvshowid'])
data2 = unicode(data2, 'utf-8', errors='ignore')
data2 = simplejson.loads(data2)
path = data2['result']['tvshowdetails']['file']
studio = data2['result']['tvshowdetails']['studio'][0]
'''
if season_folders == 'true':
path = os.path.split(media_path(item['file']))[0]
else:
path = media_path(item['file'])
rating = str(round(float(item['rating']),1))
if item['playcount'] >= 1:
watched = "true"
else:
watched = "false"
if not PLOT_ENABLE and watched == "false":
plot = __localize__(32014)
else:
plot = item['plot']
art = item['art']
path = media_path(item['file'])
#play = 'XBMC.ActivateWindow(videodb://tvshows/' + str(item.get('tvshowid')) + ')'
play = 'XBMC.RunScript(' + __addonid__ + ',tvshowid=' + str(item.get('tvshowid')) + ')'
WINDOW.setProperty("%s.%d.DBID" % (request, count), str(item.get('tvshowid')))
WINDOW.setProperty("%s.%d.Title" % (request, count), item['title'])
WINDOW.setProperty("%s.%d.Art(thumb)" % (request, count), art.get('thumb',''))
WINDOW.setProperty("%s.%d.Art(tvshow.fanart)" % (request, count), art.get('tvshow.fanart',''))
WINDOW.setProperty("%s.%d.Art(tvshow.poster)" % (request, count), art.get('tvshow.poster',''))
WINDOW.setProperty("%s.%d.Art(tvshow.poster)" % (request, count), art.get('poster',''))
WINDOW.setProperty("%s.%d.Art(tvshow.banner)" % (request, count), art.get('tvshow.banner',''))
WINDOW.setProperty("%s.%d.Art(tvshow.clearlogo)"% (request, count), art.get('tvshow.clearlogo',''))
WINDOW.setProperty("%s.%d.Art(tvshow.clearart)" % (request, count), art.get('tvshow.clearart',''))
WINDOW.setProperty("%s.%d.Art(tvshow.landscape)"% (request, count), art.get('tvshow.landscape',''))
WINDOW.setProperty("%s.%d.Art(tvshow.characterart)"% (request, count), art.get('tvshow.characterart',''))
WINDOW.setProperty("%s.%d.Watched" % (request, count), watched)
WINDOW.setProperty("%s.%d.File" % (request, count), item['file'])
WINDOW.setProperty("%s.%d.Path" % (request, count), path)
WINDOW.setProperty("%s.%d.Play" % (request, count), play)
del data
Alles anzeigen
Die Serienamen und Poster werden mir angezeigt. nur weiß ich halt nicht wie ich diese nun direkt öffne