mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
merged in getcollections
This commit is contained in:
commit
0b6b630e06
2 changed files with 64 additions and 26 deletions
|
@ -844,3 +844,39 @@ class LibrarySync():
|
|||
episode = item
|
||||
|
||||
return episode
|
||||
|
||||
|
||||
def getCollections(self):
|
||||
#Build a list of the user views
|
||||
userid = DownloadUtils().getUserId()
|
||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||
port = addon.getSetting('port')
|
||||
host = addon.getSetting('ipaddress')
|
||||
server = host + ":" + port
|
||||
|
||||
viewsUrl = server + "/mediabrowser/Users/" + userid + "/Views?format=json&ImageTypeLimit=1"
|
||||
jsonData = DownloadUtils().downloadUrl(viewsUrl, suppress=True, popup=0 )
|
||||
|
||||
if(jsonData != ""):
|
||||
views = json.loads(jsonData)
|
||||
views = views.get("Items")
|
||||
collections=[]
|
||||
for view in views:
|
||||
if(view.get("ChildCount") != 0):
|
||||
Name =(view.get("Name")).encode('utf-8')
|
||||
|
||||
total = str(view.get("ChildCount"))
|
||||
type = view.get("CollectionType")
|
||||
if type == None:
|
||||
type = "None" # User may not have declared the type
|
||||
if type == "movies" or type == "tvshows":
|
||||
collections.append( {'title' : Name,
|
||||
'type' : type,
|
||||
'id' : view.get("Id")})
|
||||
return collections
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -86,9 +86,15 @@ def addKodiSource(name, path, type):
|
|||
else:
|
||||
error = True
|
||||
|
||||
if error:
|
||||
# if adding to the database failed, manually add it to sources.xml
|
||||
# add it to sources.xml
|
||||
sourcesFile = xbmc.translatePath( "special://profile/sources.xml" )
|
||||
|
||||
# add an emply sources file to work with
|
||||
if xbmcvfs.exists(sourcesFile) == False:
|
||||
sources = Element("sources")
|
||||
video = SubElement(sources, "video")
|
||||
ET.ElementTree(sources).write(sourcesFile)
|
||||
|
||||
if xbmcvfs.exists(sourcesFile):
|
||||
tree = ET.ElementTree(file=sourcesFile)
|
||||
root = tree.getroot()
|
||||
|
@ -105,11 +111,7 @@ def addKodiSource(name, path, type):
|
|||
SubElement(source, "path").text = path
|
||||
tree.write(sourcesFile)
|
||||
#return bool that reboot is needed and manual add of path to kodi
|
||||
return True
|
||||
else:
|
||||
#return false that no reboot is needed
|
||||
return False
|
||||
|
||||
#return True
|
||||
|
||||
|
||||
def checkAuthentication():
|
||||
|
|
Loading…
Reference in a new issue