Merge branch 'database_changes' of https://github.com/MediaBrowser/Emby.Kodi into database_changes

This commit is contained in:
Marcel van der Veldt 2015-05-03 17:40:43 +02:00
commit d349207781

View file

@ -226,33 +226,43 @@ class ReadEmbyDB():
doUtils = DownloadUtils() doUtils = DownloadUtils()
viewsUrl = "{server}/mediabrowser/Users/{UserId}/Views?format=json&ImageTypeLimit=1" viewsUrl = "{server}/mediabrowser/Users/{UserId}/Views?format=json&ImageTypeLimit=1"
jsonData = doUtils.downloadUrl(viewsUrl) result = doUtils.downloadUrl(viewsUrl)
collections=[] collections=[]
if (jsonData != ""): if (result == ""):
views = views[u'Items'] return []
result = result[u'Items']
for view in views: for view in result:
if (view[u'Type'] == 'UserView'): # Need to grab the real main node if (view[u'Type'] == 'UserView'): # Need to grab the real main node
newViewsUrl = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s&SortBy=SortName&SortOrder=Ascending&format=json&ImageTypeLimit=1" % view[u'Id'] newViewsUrl = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s&SortBy=SortName&SortOrder=Ascending&format=json&ImageTypeLimit=1" % view[u'Id']
jsonData = doUtils.downloadUrl(newViewsUrl) newViews = doUtils.downloadUrl(newViewsUrl)
if (jsonData != ""): if (result == ""):
newViews = newViews[u'Items'] return []
for newView in newViews: newViews = newViews[u'Items']
# There are multiple nodes in here like 'Latest', 'NextUp' - below we grab the full node. print str(newViews)
if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries": for newView in newViews:
view=newView # There are multiple nodes in here like 'Latest', 'NextUp' - below we grab the full node.
if (view[u'ChildCount'] != 0): if newView[u'CollectionType'] != None:
Name = view[u'Name'] if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries":
view=newView
total = str(view[u'ChildCount']) if (view[u'ChildCount'] != 0):
Name = view[u'Name']
total = str(view[u'ChildCount'])
try:
itemtype = view[u'CollectionType'] itemtype = view[u'CollectionType']
if itemtype == None: except:
itemtype = "movies" # User may not have declared the type itemtype = "movies"
if itemtype == type: if itemtype == "MovieMovies":
collections.append( {'title' : Name, itemtype = "movies"
'type' : type, if itemtype == "TvShowSeries":
'id' : view[u'Id']}) itemtype = "tvshows"
if itemtype == type:
collections.append( {'title' : Name,
'type' : type,
'id' : view[u'Id']})
return collections return collections
def getBoxSets(self): def getBoxSets(self):