Change to use unicode
This commit is contained in:
parent
079fd4e8d9
commit
007cc8e4a9
1 changed files with 133 additions and 191 deletions
|
@ -5,22 +5,17 @@
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import json
|
|
||||||
|
|
||||||
from DownloadUtils import DownloadUtils
|
from DownloadUtils import DownloadUtils
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
|
||||||
class ReadEmbyDB():
|
class ReadEmbyDB():
|
||||||
|
|
||||||
def getMovies(self, id, fullinfo = False, fullSync = True, itemList = []):
|
def getMovies(self, id, fullinfo = False, fullSync = True, itemList = []):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
WINDOW = xbmcgui.Window(10000)
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
|
||||||
|
|
||||||
if fullSync:
|
if fullSync:
|
||||||
sortstring = "&SortBy=SortName"
|
sortstring = "&SortBy=SortName"
|
||||||
|
@ -32,35 +27,31 @@ class ReadEmbyDB():
|
||||||
sortstring = "&Limit=20&SortBy=DateCreated"
|
sortstring = "&Limit=20&SortBy=DateCreated"
|
||||||
|
|
||||||
if fullinfo:
|
if fullinfo:
|
||||||
url = "%s/mediabrowser/Users/%s/items?ParentId=%s%s&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (server, userid, id, sortstring)
|
url = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s%s&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (id, sortstring)
|
||||||
else:
|
else:
|
||||||
url = "%s/mediabrowser/Users/%s/items?ParentId=%s%s&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (server, userid, id, sortstring)
|
url = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s%s&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=Movie&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (id, sortstring)
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
jsonData = doUtils.downloadUrl(url)
|
||||||
if jsonData != None and jsonData != "":
|
if (jsonData == ""):
|
||||||
result = json.loads(jsonData)
|
return result
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
if (jsonData[u'Items'] != ""):
|
||||||
|
result = jsonData[u'Items']
|
||||||
|
|
||||||
# work around for now until ParetnId and Id work together
|
# work around for now until ParetnId and Id work together
|
||||||
if(result != None and len(result) > 0 and len(itemList) > 0):
|
if (result != None and len(result) > 0 and len(itemList) > 0):
|
||||||
newResult = []
|
newResult = []
|
||||||
for item in result:
|
for item in result:
|
||||||
if(item.get("Id") in itemList):
|
if (item[u'Id'] in itemList):
|
||||||
newResult.append(item)
|
newResult.append(item)
|
||||||
result = newResult
|
result = newResult
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getMusicVideos(self, fullinfo = False, fullSync = True):
|
def getMusicVideos(self, fullinfo = False, fullSync = True):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
WINDOW = xbmcgui.Window(10000)
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
|
||||||
|
|
||||||
if not fullSync:
|
if not fullSync:
|
||||||
sortstring = "&Limit=20&SortBy=DateCreated"
|
sortstring = "&Limit=20&SortBy=DateCreated"
|
||||||
|
@ -68,276 +59,227 @@ class ReadEmbyDB():
|
||||||
sortstring = "&SortBy=SortName"
|
sortstring = "&SortBy=SortName"
|
||||||
|
|
||||||
if fullinfo:
|
if fullinfo:
|
||||||
url = "%s/mediabrowser/Users/%s/items?%s&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&format=json&ImageTypeLimit=1" % (server, userid, sortstring)
|
url = "{server}/mediabrowser/Users/{UserId}/items?%s&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&format=json&ImageTypeLimit=1" % sortstring
|
||||||
else:
|
else:
|
||||||
url = "%s/mediabrowser/Users/%s/items?%s&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % (server, userid, sortstring)
|
url = "{server}/mediabrowser/Users/{UserId}/items?%s&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=MusicVideo&CollapseBoxSetItems=false&format=json&ImageTypeLimit=1" % sortstring
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
jsonData = doUtils.downloadUrl(url)
|
||||||
if jsonData != None and jsonData != "":
|
if (jsonData == ""):
|
||||||
result = json.loads(jsonData)
|
return result
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
if (jsonData[u'Items'] != ""):
|
||||||
|
result = jsonData[u'Items']
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getItem(self, id):
|
def getItem(self, id):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window(10000)
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
jsonData = doUtils.downloadUrl(url)
|
||||||
|
if (jsonData != ""):
|
||||||
url = "%s/mediabrowser/Users/%s/Items/%s?format=json&ImageTypeLimit=1" % (server, userid, id)
|
result = jsonData
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=1 )
|
|
||||||
if jsonData != None and jsonData != "":
|
|
||||||
result = json.loads(jsonData)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getFullItem(self, id):
|
def getFullItem(self, id):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window(10000)
|
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" % id
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
jsonData = doUtils.downloadUrl(url)
|
||||||
|
if (jsonData != ""):
|
||||||
url = "%s/mediabrowser/Users/%s/Items/%s?format=json&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview" % (server, userid, id)
|
result = jsonData
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=1 )
|
|
||||||
if jsonData != None and jsonData != "":
|
|
||||||
result = json.loads(jsonData)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getTVShows(self, id, fullinfo = False, fullSync = False):
|
def getTVShows(self, id, fullinfo = False, fullSync = False):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
WINDOW = xbmcgui.Window(10000)
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
|
||||||
|
|
||||||
if not fullSync:
|
if not fullSync:
|
||||||
sortstring = "&Limit=20&SortBy=DateCreated"
|
sortstring = "&Limit=20&SortBy=DateCreated"
|
||||||
else:
|
else:
|
||||||
sortstring = "&SortBy=SortName"
|
sortstring = "&SortBy=SortName"
|
||||||
|
|
||||||
|
|
||||||
if fullinfo:
|
if fullinfo:
|
||||||
url = "%s/mediabrowser/Users/%s/Items?ParentId=%s%s&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % (server, userid, id, sortstring)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s%s&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % (id, sortstring)
|
||||||
else:
|
else:
|
||||||
url = "%s/mediabrowser/Users/%s/Items?ParentId=%s%s&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % (server, userid, id, sortstring)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s%s&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=Series&format=json&ImageTypeLimit=1" % (id, sortstring)
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
jsonData = doUtils.downloadUrl(url)
|
||||||
if jsonData != None and jsonData != "":
|
if (jsonData == ""):
|
||||||
result = json.loads(jsonData)
|
return result
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
if (jsonData[u'Items'] != ""):
|
||||||
|
result = jsonData[u'Items']
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getTVShowSeasons(self, tvShowId):
|
def getTVShowSeasons(self, tvShowId):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window(10000)
|
url = "{server}/Shows/%s/Seasons?UserId={UserId}&format=json&ImageTypeLimit=1" % tvShowId
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
jsonData = doUtils.downloadUrl(url)
|
||||||
|
if (jsonData == ""):
|
||||||
|
return result
|
||||||
|
|
||||||
url = "%s/Shows/%s/Seasons?UserId=%s&format=json&ImageTypeLimit=1" % (server, tvShowId, userid)
|
if (jsonData[u'Items'] != ""):
|
||||||
|
result = jsonData[u'Items']
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
|
||||||
if jsonData != None and jsonData != "":
|
|
||||||
result = json.loads(jsonData)
|
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getEpisodes(self, showId, fullinfo = False):
|
def getEpisodes(self, showId, fullinfo = False):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
WINDOW = xbmcgui.Window(10000)
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
|
||||||
|
|
||||||
if fullinfo:
|
if fullinfo:
|
||||||
url = "%s/mediabrowser/Users/%s/Items?ParentId=%s&IsVirtualUnaired=false&IsMissing=False&SortBy=SortName&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % (server, userid, showId)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&IsVirtualUnaired=false&IsMissing=False&SortBy=SortName&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % showId
|
||||||
else:
|
else:
|
||||||
url = "%s/mediabrowser/Users/%s/Items?ParentId=%s&IsVirtualUnaired=false&IsMissing=False&SortBy=SortName&Fields=Name,SortName,CumulativeRunTimeTicks&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % (server, userid, showId)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&IsVirtualUnaired=false&IsMissing=False&SortBy=SortName&Fields=Name,SortName,CumulativeRunTimeTicks&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % showId
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
jsonData = doUtils.downloadUrl(url)
|
||||||
|
if (jsonData == ""):
|
||||||
|
return result
|
||||||
|
|
||||||
if jsonData != None and jsonData != "":
|
if (jsonData[u'Items'] != ""):
|
||||||
result = json.loads(jsonData)
|
result = jsonData[u'Items']
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getLatestEpisodes(self, fullinfo = False, itemList = []):
|
def getLatestEpisodes(self, fullinfo = False, itemList = []):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
WINDOW = xbmcgui.Window(10000)
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
|
||||||
|
|
||||||
limitString = "Limit=20&SortBy=DateCreated&"
|
limitString = "Limit=20&SortBy=DateCreated&"
|
||||||
if(len(itemList) > 0): # if we want a certain list specify it
|
if(len(itemList) > 0): # if we want a certain list specify it
|
||||||
limitString = "Ids=" + ",".join(itemList) + "&"
|
limitString = "Ids=" + ",".join(itemList) + "&"
|
||||||
|
|
||||||
if fullinfo:
|
if fullinfo:
|
||||||
url = "%s/mediabrowser/Users/%s/Items?%sIsVirtualUnaired=false&IsMissing=False&Fields=ParentId,Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Descending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % (server, userid, limitString)
|
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&Recursive=true&SortOrder=Descending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % limitString
|
||||||
else:
|
else:
|
||||||
url = "%s/mediabrowser/Users/%s/Items?%sIsVirtualUnaired=false&IsMissing=False&Fields=ParentId,Name,SortName,CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % (server, userid, limitString)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?%sIsVirtualUnaired=false&IsMissing=False&Fields=ParentId,Name,SortName,CumulativeRunTimeTicks&Recursive=true&SortOrder=Descending&IncludeItemTypes=Episode&format=json&ImageTypeLimit=1" % limitString
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
jsonData = doUtils.downloadUrl(url)
|
||||||
|
if (jsonData == ""):
|
||||||
|
return result
|
||||||
|
|
||||||
if jsonData != None and jsonData != "":
|
if (jsonData[u'Items'] != ""):
|
||||||
result = json.loads(jsonData)
|
result = jsonData[u'Items']
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getCollections(self, type):
|
def getCollections(self, type):
|
||||||
#Build a list of the user views
|
#Build a list of the user views
|
||||||
WINDOW = xbmcgui.Window(10000)
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = "%s/mediabrowser/Users/%s/Items/Root?format=json" % (server, userid)
|
url = "{server}/mediabrowser/Users/{UserId}/Items/Root?format=json"
|
||||||
jsonData = downloadUtils.downloadUrl(url)
|
result = downloadUtils.downloadUrl(url)
|
||||||
except Exception, msg:
|
except Exception, msg:
|
||||||
error = "Get connect : " + str(msg)
|
error = "Can't connect: %s" % msg
|
||||||
xbmc.log (error)
|
xbmc.log(error)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if(jsonData == ""):
|
if (result == ""):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
result = json.loads(jsonData)
|
parentid = result[u'Id']
|
||||||
|
|
||||||
parentid = result.get("Id")
|
url = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s&Sortby=SortName&format=json" % parentid
|
||||||
|
result = downloadUtils.downloadUrl(url)
|
||||||
htmlpath = "%s/mediabrowser/Users/%s/items?ParentId=%s&Sortby=SortName&format=json" % (server, userid, parentid)
|
|
||||||
jsonData = downloadUtils.downloadUrl(htmlpath)
|
|
||||||
collections=[]
|
collections=[]
|
||||||
|
|
||||||
if(jsonData == ""):
|
if (result == ""):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
result = json.loads(jsonData)
|
result = result[u'Items']
|
||||||
result = result.get("Items")
|
|
||||||
|
|
||||||
for item in result:
|
for item in result:
|
||||||
if(item.get("RecursiveItemCount") != 0):
|
if (item[u'RecursiveItemCount'] != 0):
|
||||||
Temp = item.get("Name")
|
Name = item[u'Name']
|
||||||
Name = Temp.encode('utf-8')
|
itemtype = item[u'CollectionType']
|
||||||
section = item.get("CollectionType")
|
|
||||||
itemtype = item.get("CollectionType")
|
|
||||||
if itemtype == None or itemtype == "":
|
if itemtype == None or itemtype == "":
|
||||||
itemtype = "movies" # User may not have declared the type
|
itemtype = "movies" # User may not have declared the type
|
||||||
if itemtype == type and item.get("Name") != "Collections":
|
if itemtype == type and Name != "Collections":
|
||||||
collections.append( {'title' : item.get("Name"),
|
collections.append({'title': Name,
|
||||||
'type' : itemtype,
|
'type' : itemtype,
|
||||||
'id' : item.get("Id")})
|
'id' : item[u'Id']})
|
||||||
return collections
|
return collections
|
||||||
|
|
||||||
def getViewCollections(self, type):
|
def getViewCollections(self, type):
|
||||||
#Build a list of the user views
|
#Build a list of the user views
|
||||||
WINDOW = xbmcgui.Window(10000)
|
doUtils = DownloadUtils()
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
viewsUrl = "%s/mediabrowser/Users/%s/Views?format=json&ImageTypeLimit=1" % (server, userid)
|
viewsUrl = "{server}/mediabrowser/Users/{UserId}/Views?format=json&ImageTypeLimit=1"
|
||||||
jsonData = DownloadUtils().downloadUrl(viewsUrl, suppress=False, popup=0 )
|
jsonData = doUtils.downloadUrl(viewsUrl)
|
||||||
collections=[]
|
collections=[]
|
||||||
|
|
||||||
if(jsonData != ""):
|
if (jsonData != ""):
|
||||||
views = json.loads(jsonData)
|
views = views[u'Items']
|
||||||
views = views.get("Items")
|
|
||||||
|
|
||||||
for view in views:
|
for view in views:
|
||||||
if view.get("Type") == 'UserView': # Need to grab the real main node
|
if (view[u'Type'] == 'UserView'): # Need to grab the real main node
|
||||||
newViewsUrl = "%s/mediabrowser/Users/%s/items?ParentId=%s&SortBy=SortName&SortOrder=Ascending&format=json&ImageTypeLimit=1" % (server, userid, view.get("Id"))
|
newViewsUrl = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s&SortBy=SortName&SortOrder=Ascending&format=json&ImageTypeLimit=1" % view[u'Id']
|
||||||
jsonData = DownloadUtils().downloadUrl(newViewsUrl, suppress=False, popup=0 )
|
jsonData = doUtils.downloadUrl(newViewsUrl)
|
||||||
if(jsonData != ""):
|
if (jsonData != ""):
|
||||||
newViews = json.loads(jsonData)
|
newViews = newViews[u'Items']
|
||||||
newViews = newViews.get("Items")
|
|
||||||
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.get("CollectionType") == "MovieMovies" or newView.get("CollectionType") == "TvShowSeries":
|
if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries":
|
||||||
view=newView
|
view=newView
|
||||||
if(view.get("ChildCount") != 0):
|
if (view[u'ChildCount'] != 0):
|
||||||
Name =(view.get("Name"))
|
Name = view[u'Name']
|
||||||
|
|
||||||
total = str(view.get("ChildCount"))
|
total = str(view[u'ChildCount'])
|
||||||
type = view.get("CollectionType")
|
type = view[u'CollectionType']
|
||||||
if type == None:
|
if type == None:
|
||||||
type = "None" # User may not have declared the type
|
type = "None" # User may not have declared the type
|
||||||
if type == type:
|
if type == type:
|
||||||
collections.append( {'title' : Name,
|
collections.append({'title': Name,
|
||||||
'type' : type,
|
'type' : type,
|
||||||
'id' : view.get("Id")})
|
'id' : view[u'Id']})
|
||||||
return collections
|
return collections
|
||||||
|
|
||||||
def getBoxSets(self):
|
def getBoxSets(self):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window(10000)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?SortBy=SortName&IsVirtualUnaired=false&IsMissing=False&Fields=Name,SortName,CumulativeRunTimeTicks&Recursive=true&SortOrder=Ascending&IncludeItemTypes=BoxSet&format=json&ImageTypeLimit=1"
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
jsonData = doUtils.downloadUrl(url)
|
||||||
|
if (jsonData == ""):
|
||||||
|
return result
|
||||||
|
|
||||||
url = "%s/mediabrowser/Users/%s/Items?SortBy=SortName&IsVirtualUnaired=false&IsMissing=False&Fields=Name,SortName,CumulativeRunTimeTicks&Recursive=true&SortOrder=Ascending&IncludeItemTypes=BoxSet&format=json&ImageTypeLimit=1" % (server, userid)
|
if (jsonData[u'Items'] != ""):
|
||||||
|
result = jsonData[u'Items']
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
|
||||||
|
|
||||||
if jsonData != None and jsonData != "":
|
|
||||||
result = json.loads(jsonData)
|
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getMoviesInBoxSet(self,boxsetId):
|
def getMoviesInBoxSet(self,boxsetId):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
|
doUtils = DownloadUtils()
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window(10000)
|
url = "{server}/mediabrowser/Users/{UserId}/Items?ParentId=%s&Fields=ItemCounts&format=json&ImageTypeLimit=1" % boxsetId
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
jsonData = doUtils.downloadUrl(url)
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
if (jsonData == ""):
|
||||||
|
return result
|
||||||
|
|
||||||
|
if (jsonData[u'Items'] != ""):
|
||||||
|
result = jsonData[u'Items']
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
|
||||||
|
|
||||||
url = "%s/mediabrowser/Users/%s/Items?ParentId=%s&Fields=ItemCounts&format=json&ImageTypeLimit=1" % (server, userid, boxsetId)
|
|
||||||
|
|
||||||
jsonData = downloadUtils.downloadUrl(url, suppress=False, popup=0)
|
|
||||||
|
|
||||||
if jsonData != None and jsonData != "":
|
|
||||||
result = json.loads(jsonData)
|
|
||||||
if(result.has_key('Items')):
|
|
||||||
result = result['Items']
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue