More fixes to make 'getViewCollections' work

This commit is contained in:
xnappo 2015-05-03 10:39:30 -05:00
parent 08ea50bdca
commit c8e4312571
1 changed files with 33 additions and 23 deletions

View File

@ -226,29 +226,39 @@ 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 []
for view in views: result = result[u'Items']
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 == ""):
return []
newViews = newViews[u'Items'] newViews = newViews[u'Items']
print str(newViews)
for newView in newViews: for newView in newViews:
# There are multiple nodes in here like 'Latest', 'NextUp' - below we grab the full node. # There are multiple nodes in here like 'Latest', 'NextUp' - below we grab the full node.
if newView[u'CollectionType'] != None:
if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries": if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries":
view=newView view=newView
if (view[u'ChildCount'] != 0): if (view[u'ChildCount'] != 0):
Name = view[u'Name'] Name = view[u'Name']
total = str(view[u'ChildCount']) 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 == "MovieMovies":
itemtype = "movies"
if itemtype == "TvShowSeries":
itemtype = "tvshows"
if itemtype == type: if itemtype == type:
collections.append( {'title' : Name, collections.append( {'title' : Name,
'type' : type, 'type' : type,