Use query by Id list for <50 items

This commit is contained in:
xnappo 2015-08-01 12:03:17 -05:00
parent 084d1fb493
commit 59b7080b33

View file

@ -21,7 +21,14 @@ class ReadEmbyDB():
#only get basic info for our sync-compares #only get basic info for our sync-compares
sortstring = "&SortBy=SortName" sortstring = "&SortBy=SortName"
url = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s%s&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (id, sortstring) url = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s%s&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (id, sortstring)
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -31,7 +38,7 @@ class ReadEmbyDB():
result = jsonData[u'Items'] result = jsonData[u'Items']
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):
@ -48,6 +55,12 @@ class ReadEmbyDB():
#only get basic info for our sync-compares #only get basic info for our sync-compares
sortstring = "&SortBy=SortName" sortstring = "&SortBy=SortName"
url = "{server}/mediabrowser/Users/{UserId}/items?%s&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % sortstring url = "{server}/mediabrowser/Users/{UserId}/items?%s&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % sortstring
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -57,7 +70,7 @@ class ReadEmbyDB():
result = jsonData[u'Items'] result = jsonData[u'Items']
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):
@ -73,6 +86,12 @@ class ReadEmbyDB():
#only get basic info for our sync-compares #only get basic info for our sync-compares
url = "{server}/Artists?Recursive=true&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&UserId={UserId}&format=json" url = "{server}/Artists?Recursive=true&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&UserId={UserId}&format=json"
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -82,7 +101,7 @@ class ReadEmbyDB():
result = jsonData[u'Items'] result = jsonData[u'Items']
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):
@ -98,6 +117,13 @@ class ReadEmbyDB():
#only get basic info for our sync-compares #only get basic info for our sync-compares
url = "{server}/mediabrowser/Users/{UserId}/Items?Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=Audio&format=json" url = "{server}/mediabrowser/Users/{UserId}/Items?Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=Audio&format=json"
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -107,7 +133,7 @@ class ReadEmbyDB():
result = jsonData[u'Items'] result = jsonData[u'Items']
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):
@ -123,6 +149,12 @@ class ReadEmbyDB():
#only get basic info for our sync-compares #only get basic info for our sync-compares
url = "{server}/mediabrowser/Users/{UserId}/Items?Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=MusicAlbum&format=json" url = "{server}/mediabrowser/Users/{UserId}/Items?Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=MusicAlbum&format=json"
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -141,7 +173,7 @@ class ReadEmbyDB():
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):
@ -184,6 +216,12 @@ class ReadEmbyDB():
#only get basic info for our sync-compares #only get basic info for our sync-compares
sortstring = "&SortBy=SortName" sortstring = "&SortBy=SortName"
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s%s&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % (id, sortstring) url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s%s&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % (id, sortstring)
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -193,7 +231,7 @@ class ReadEmbyDB():
result = jsonData[u'Items'] result = jsonData[u'Items']
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):
@ -224,6 +262,12 @@ class ReadEmbyDB():
doUtils = DownloadUtils() doUtils = DownloadUtils()
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&IsVirtualUnaired=false&IsMissing=False&SortBy=SortName&Fields=Name,SortName,CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % showId url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&IsVirtualUnaired=false&IsMissing=False&SortBy=SortName&Fields=Name,SortName,CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % showId
if itemList != [] and len(itemList) < 50:
if len(itemList) == 1:
Ids=itemList[0]
else:
Ids=",".join(itemList)
url = url + "&Ids=" + Ids
jsonData = doUtils.downloadUrl(url) jsonData = doUtils.downloadUrl(url)
if (jsonData == ""): if (jsonData == ""):
@ -233,7 +277,7 @@ class ReadEmbyDB():
result = jsonData[u'Items'] result = jsonData[u'Items']
# Work around to only return items from the given list # Work around to only return items from the given list
if (result != None and len(result) > 0 and len(itemList) > 0): if (result != None and len(result) > 0 and len(itemList) > 0 and len(itemList) >= 50):
newResult = [] newResult = []
for item in result: for item in result:
if (item[u'Id'] in itemList): if (item[u'Id'] in itemList):