2015-08-03 19:45:23 +10:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2015-03-18 04:51:45 +11:00
|
|
|
#################################################################################################
|
|
|
|
# ReadEmbyDB
|
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
from DownloadUtils import DownloadUtils
|
|
|
|
|
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
class ReadEmbyDB():
|
|
|
|
|
|
|
|
doUtils = DownloadUtils()
|
2015-08-04 14:04:34 +10:00
|
|
|
urllimit = 50
|
|
|
|
|
|
|
|
def filterbyId(self, result, itemList = []):
|
|
|
|
|
|
|
|
newResult = []
|
|
|
|
for item in result:
|
|
|
|
if item['Id'] in itemList:
|
|
|
|
newResult.append(item)
|
|
|
|
|
|
|
|
return newResult
|
2015-04-22 09:12:09 +10:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
def getMovies(self, parentId, itemList = []):
|
2015-08-04 14:04:34 +10:00
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
# Only get basic info for our sync-compares
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&SortBy=SortName&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&ImageTypeLimit=1&format=json" % parentId
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
|
|
|
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-04 14:04:34 +10:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
2015-08-04 14:04:34 +10:00
|
|
|
except: pass
|
|
|
|
else: # If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-08-03 19:45:23 +10:00
|
|
|
|
2015-03-18 04:51:45 +11:00
|
|
|
return result
|
2015-03-22 00:31:30 +11:00
|
|
|
|
2015-05-03 06:02:06 +10:00
|
|
|
def getMusicVideos(self, itemList = []):
|
2015-03-22 00:31:30 +11:00
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
# Only get basic info for our sync-compares
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/items?&SortBy=SortName&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&CollapseBoxSetItems=false&ImageTypeLimit=1&format=json"
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
2015-03-22 00:31:30 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-04 14:04:34 +10:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
2015-08-04 14:04:34 +10:00
|
|
|
except: pass
|
|
|
|
else: # If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-03-22 00:31:30 +11:00
|
|
|
|
|
|
|
return result
|
2015-05-08 08:04:40 +10:00
|
|
|
|
|
|
|
def getMusicArtists(self, itemList = []):
|
|
|
|
|
2015-05-08 09:13:29 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
# Only get basic info for our sync-compares
|
2015-07-31 05:23:50 +10:00
|
|
|
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"
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
2015-05-08 08:04:40 +10:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-04 14:04:34 +10:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
2015-08-04 14:04:34 +10:00
|
|
|
except: pass
|
|
|
|
else: # If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-05-08 08:04:40 +10:00
|
|
|
|
|
|
|
return result
|
2015-08-04 17:12:58 +10:00
|
|
|
|
|
|
|
def getMusicArtistsTotal(self):
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
url = "{server}/Artists?Limit=1&Recursive=true&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&UserId={UserId}&format=json"
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
|
|
|
|
total = jsondata['TotalRecordCount']
|
|
|
|
index = 1
|
|
|
|
jump = 200
|
|
|
|
|
|
|
|
while index < total:
|
|
|
|
url = "{server}/Artists?StartIndex=%s&Limit=%s&Recursive=true&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&UserId={UserId}&format=json" % (index, jump)
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
result.extend(jsondata['Items'])
|
|
|
|
index += jump
|
|
|
|
|
|
|
|
return result
|
2015-05-08 08:04:40 +10:00
|
|
|
|
|
|
|
def getMusicSongs(self, itemList = []):
|
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
# Only get basic info for our sync-compares
|
2015-07-31 05:23:50 +10:00
|
|
|
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"
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
2015-05-08 08:04:40 +10:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-04 14:04:34 +10:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
2015-08-04 14:04:34 +10:00
|
|
|
except: pass
|
|
|
|
else: # If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-05-08 08:04:40 +10:00
|
|
|
|
|
|
|
return result
|
2015-08-04 16:07:39 +10:00
|
|
|
|
|
|
|
def getMusicSongsTotal(self):
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?Index=1&Limit=1&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=Audio&format=json"
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
|
|
|
|
total = jsondata['TotalRecordCount']
|
|
|
|
index = 1
|
|
|
|
jump = 200
|
|
|
|
|
|
|
|
while index < total:
|
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?StartIndex=%s&Limit=%s&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=Audio&format=json" % (index, jump)
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
result.extend(jsondata['Items'])
|
2015-08-04 17:12:58 +10:00
|
|
|
index += jump
|
2015-08-04 16:07:39 +10:00
|
|
|
|
|
|
|
return result
|
2015-05-08 08:04:40 +10:00
|
|
|
|
|
|
|
def getMusicAlbums(self, itemList = []):
|
2015-03-22 00:31:30 +11:00
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
# Only get basic info for our sync-compares
|
2015-07-31 05:23:50 +10:00
|
|
|
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"
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
2015-05-08 08:04:40 +10:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
try:
|
|
|
|
result = jsondata['Items']
|
|
|
|
except: pass
|
|
|
|
else:
|
2015-05-08 10:44:32 +10:00
|
|
|
tempresult = []
|
2015-08-03 19:45:23 +10:00
|
|
|
# Only return valid albums - which have artists
|
2015-05-08 10:44:32 +10:00
|
|
|
for item in result:
|
2015-08-03 19:45:23 +10:00
|
|
|
if item['AlbumArtists']:
|
2015-05-08 10:44:32 +10:00
|
|
|
tempresult.append(item)
|
|
|
|
result = tempresult
|
2015-08-04 14:04:34 +10:00
|
|
|
# If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-03-26 01:00:08 +11:00
|
|
|
|
|
|
|
return result
|
|
|
|
|
2015-08-04 17:12:58 +10:00
|
|
|
def getMusicAlbumsTotal(self):
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?Limit=1&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&IncludeItemTypes=MusicAlbum&format=json"
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
|
|
|
|
total = jsondata['TotalRecordCount']
|
|
|
|
index = 1
|
|
|
|
jump = 200
|
|
|
|
|
|
|
|
while index < total:
|
2015-08-04 18:45:23 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?StartIndex=%s&Limit=%s&Fields=Etag,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&SortBy=DateCreated&Recursive=true&IncludeItemTypes=MusicAlbum&format=json" % (index, jump)
|
2015-08-04 17:12:58 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
|
|
|
|
tempresult = []
|
|
|
|
# Only return valid albums - which have artists
|
|
|
|
for item in jsondata['Items']:
|
|
|
|
if item['AlbumArtists']:
|
|
|
|
tempresult.append(item)
|
|
|
|
|
|
|
|
result.extend(tempresult)
|
|
|
|
index += jump
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
def getTvShows(self, parentId, itemList = []):
|
2015-03-18 04:51:45 +11:00
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
# Only get basic info for our sync-compares
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&SortBy=SortName&Fields=CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % parentId
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
|
|
|
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-04 14:04:34 +10:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
2015-08-04 14:04:34 +10:00
|
|
|
except: pass
|
|
|
|
else: # If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-03-20 08:31:06 +11:00
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
def getTVShowSeasons(self, tvShowId):
|
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-04-22 09:12:09 +10:00
|
|
|
url = "{server}/Shows/%s/Seasons?UserId={UserId}&format=json&ImageTypeLimit=1" % tvShowId
|
2015-03-20 08:31:06 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
if jsondata:
|
|
|
|
result = jsondata['Items']
|
2015-03-18 04:51:45 +11:00
|
|
|
|
|
|
|
return result
|
2015-04-12 18:34:00 +10:00
|
|
|
|
2015-05-02 19:56:31 +10:00
|
|
|
def getEpisodes(self, showId, itemList = []):
|
2015-03-18 04:51:45 +11:00
|
|
|
|
2015-06-12 18:02:11 +10:00
|
|
|
result = []
|
2015-08-04 14:04:34 +10:00
|
|
|
lenlist = len(itemList) < self.urllimit
|
|
|
|
|
2015-05-03 07:14:04 +10:00
|
|
|
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
|
2015-08-04 14:04:34 +10:00
|
|
|
if itemList and lenlist:
|
2015-08-03 19:45:23 +10:00
|
|
|
url = "%s&Ids=%s" % (url, ",".join(itemList))
|
|
|
|
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-04 14:04:34 +10:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
2015-08-04 14:04:34 +10:00
|
|
|
except: pass
|
|
|
|
else: # If list was longer than 49 items, we pulled the entire list so we need to sort
|
|
|
|
if not lenlist:
|
|
|
|
result = self.filterbyId(result, itemList)
|
2015-04-22 09:12:09 +10:00
|
|
|
|
2015-03-18 04:51:45 +11:00
|
|
|
return result
|
|
|
|
|
2015-04-03 13:12:09 +11:00
|
|
|
def getLatestEpisodes(self, fullinfo = False, itemList = []):
|
2015-03-19 04:00:38 +11:00
|
|
|
|
2015-08-04 14:04:34 +10:00
|
|
|
result = []
|
2015-03-19 04:00:38 +11:00
|
|
|
|
2015-04-03 13:12:09 +11:00
|
|
|
limitString = "Limit=20&SortBy=DateCreated&"
|
2015-08-03 19:45:23 +10:00
|
|
|
if itemList: # if we want a certain list specify it
|
|
|
|
limitString = "Ids=%s&" % ",".join(itemList)
|
2015-04-03 13:12:09 +11:00
|
|
|
|
2015-03-19 04:00:38 +11:00
|
|
|
if fullinfo:
|
2015-05-03 07:14:04 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?%sIsVirtualUnaired=false&IsMissing=False&Fields=ParentId,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % limitString
|
2015-03-19 04:00:38 +11:00
|
|
|
else:
|
2015-05-03 07:14:04 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?%sIsVirtualUnaired=false&IsMissing=False&Fields=ParentId,Name,SortName,CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Descending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % limitString
|
2015-03-19 04:00:38 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
if jsondata:
|
|
|
|
result = jsondata['Items']
|
2015-04-22 09:12:09 +10:00
|
|
|
|
2015-03-19 04:00:38 +11:00
|
|
|
return result
|
2015-08-04 14:04:34 +10:00
|
|
|
|
|
|
|
def getItem(self, id):
|
|
|
|
|
|
|
|
result = {}
|
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1&Fields=Etag" % id
|
|
|
|
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
if jsondata:
|
|
|
|
result = jsondata
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
def getFullItem(self, id):
|
|
|
|
|
|
|
|
result = {}
|
2015-09-16 03:03:52 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview,CriticRating,CriticRatingSummary" % id
|
2015-08-04 14:04:34 +10:00
|
|
|
|
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
if jsondata:
|
|
|
|
result = jsondata
|
|
|
|
|
|
|
|
return result
|
2015-03-19 04:00:38 +11:00
|
|
|
|
2015-03-18 04:51:45 +11:00
|
|
|
def getCollections(self, type):
|
2015-08-03 19:45:23 +10:00
|
|
|
# Build a list of the user views
|
|
|
|
collections = []
|
|
|
|
|
2015-10-02 17:08:21 +10:00
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Views?format=json" #Items?Sortby=SortName&format=json"
|
2015-08-04 14:04:34 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
2015-08-03 19:45:23 +10:00
|
|
|
|
2015-03-23 08:22:03 +11:00
|
|
|
try:
|
2015-08-03 19:45:23 +10:00
|
|
|
result = jsondata['Items']
|
|
|
|
except: pass
|
|
|
|
else:
|
|
|
|
for item in result:
|
2015-10-02 17:08:21 +10:00
|
|
|
|
|
|
|
name = item['Name']
|
2015-10-18 10:22:41 +11:00
|
|
|
contentType = item['Type']
|
2015-10-02 17:08:21 +10:00
|
|
|
itemtype = item.get('CollectionType')
|
|
|
|
content = itemtype
|
|
|
|
|
2015-10-18 10:22:41 +11:00
|
|
|
if contentType == "Channel":
|
|
|
|
# Ignore channel type otherwise, they get processed as mixed content
|
|
|
|
continue
|
|
|
|
|
2015-10-13 04:44:20 +11:00
|
|
|
if itemtype is None and type in ("movies", "tvshows"):
|
2015-10-02 17:08:21 +10:00
|
|
|
# Mixed content or rich presentation is disabled
|
|
|
|
itemtype = type
|
|
|
|
content = "mixed"
|
|
|
|
|
2015-10-13 04:44:20 +11:00
|
|
|
if itemtype == type and name not in ("Collections", "Trailers"):
|
2015-10-02 17:08:21 +10:00
|
|
|
collections.append({
|
|
|
|
|
|
|
|
'title': name,
|
|
|
|
'type': itemtype,
|
|
|
|
'id': item['Id'],
|
|
|
|
'content': content
|
|
|
|
})
|
2015-04-22 09:12:09 +10:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
return collections
|
|
|
|
|
|
|
|
def getBoxSets(self):
|
2015-03-23 08:22:03 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
result = []
|
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?SortBy=SortName&IsVirtualUnaired=false&IsMissing=False&Fields=Name,SortName,CumulativeRunTimeTicks,Etag&Recursive=true&SortOrder=Ascending&IncludeItemTypes=BoxSet&format=json&ImageTypeLimit=1"
|
2015-03-23 08:22:03 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
if jsondata:
|
|
|
|
result = jsondata['Items']
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
def getMoviesInBoxSet(self, boxsetId):
|
2015-03-23 08:22:03 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
result = []
|
|
|
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&Fields=ItemCounts,Etag&format=json&ImageTypeLimit=1" % boxsetId
|
2015-03-23 08:22:03 +11:00
|
|
|
|
2015-08-03 19:45:23 +10:00
|
|
|
jsondata = self.doUtils.downloadUrl(url)
|
|
|
|
if jsondata:
|
|
|
|
result = jsondata['Items']
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
# This is not being used.
|
|
|
|
# To be removed?
|
|
|
|
|
2015-03-23 08:22:03 +11:00
|
|
|
def getViewCollections(self, type):
|
|
|
|
#Build a list of the user views
|
2015-04-22 09:12:09 +10:00
|
|
|
doUtils = DownloadUtils()
|
|
|
|
|
|
|
|
viewsUrl = "{server}/mediabrowser/Users/{UserId}/Views?format=json&ImageTypeLimit=1"
|
2015-05-04 01:39:30 +10:00
|
|
|
result = doUtils.downloadUrl(viewsUrl)
|
2015-03-18 13:45:15 +11:00
|
|
|
collections=[]
|
2015-03-18 04:51:45 +11:00
|
|
|
|
2015-05-04 01:39:30 +10:00
|
|
|
if (result == ""):
|
|
|
|
return []
|
|
|
|
|
|
|
|
result = result[u'Items']
|
2015-03-18 13:45:15 +11:00
|
|
|
|
2015-05-04 01:39:30 +10:00
|
|
|
for view in result:
|
|
|
|
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']
|
|
|
|
newViews = doUtils.downloadUrl(newViewsUrl)
|
|
|
|
if (result == ""):
|
|
|
|
return []
|
|
|
|
newViews = newViews[u'Items']
|
|
|
|
for newView in newViews:
|
|
|
|
# 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":
|
|
|
|
view=newView
|
|
|
|
if (view[u'ChildCount'] != 0):
|
|
|
|
Name = view[u'Name']
|
|
|
|
|
|
|
|
total = str(view[u'ChildCount'])
|
|
|
|
try:
|
2015-05-04 00:42:37 +10:00
|
|
|
itemtype = view[u'CollectionType']
|
2015-05-04 01:39:30 +10:00
|
|
|
except:
|
|
|
|
itemtype = "movies"
|
|
|
|
if itemtype == "MovieMovies":
|
|
|
|
itemtype = "movies"
|
|
|
|
if itemtype == "TvShowSeries":
|
|
|
|
itemtype = "tvshows"
|
|
|
|
if itemtype == type:
|
|
|
|
collections.append( {'title' : Name,
|
|
|
|
'type' : type,
|
|
|
|
'id' : view[u'Id']})
|
2015-08-03 19:45:23 +10:00
|
|
|
return collections
|