mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Initial attempt at tags
This commit is contained in:
parent
67bd818aad
commit
082ff2f9bc
1 changed files with 75 additions and 69 deletions
|
@ -51,7 +51,11 @@ class LibrarySync():
|
|||
|
||||
#process full movies sync
|
||||
allMovies = list()
|
||||
movieData = self.getMovies(True)
|
||||
|
||||
views = self.getCollections("movies")
|
||||
for view in views:
|
||||
|
||||
movieData = self.getMovies(view.get('id'), True)
|
||||
|
||||
if(self.ShouldStop()):
|
||||
return True
|
||||
|
@ -60,7 +64,7 @@ class LibrarySync():
|
|||
return False
|
||||
|
||||
if(pDialog != None):
|
||||
pDialog.update(0, "Sync DB : Processing Movies")
|
||||
pDialog.update(0, "Sync DB : Processing " + view.get('title'))
|
||||
total = len(movieData) + 1
|
||||
count = 1
|
||||
|
||||
|
@ -70,6 +74,7 @@ class LibrarySync():
|
|||
kodiItem = self.getKodiMovie(item["Id"])
|
||||
allMovies.append(item["Id"])
|
||||
progMessage = "Processing"
|
||||
item['Tag'] = view.get('title')
|
||||
if kodiItem == None:
|
||||
self.addMovieToKodiLibrary(item)
|
||||
updateNeeded = True
|
||||
|
@ -233,7 +238,9 @@ class LibrarySync():
|
|||
pDialog.create('Sync PlayCounts', 'Sync PlayCounts')
|
||||
|
||||
#process movies
|
||||
movieData = self.getMovies(False)
|
||||
views = self.getCollections("movies")
|
||||
for view in views:
|
||||
movieData = self.getMovies(view.get('id'),False)
|
||||
|
||||
if(self.ShouldStop()):
|
||||
return True
|
||||
|
@ -320,7 +327,7 @@ class LibrarySync():
|
|||
|
||||
return True
|
||||
|
||||
def getMovies(self, fullinfo = False):
|
||||
def getMovies(self, id, fullinfo = False):
|
||||
result = None
|
||||
|
||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||
|
@ -332,9 +339,9 @@ class LibrarySync():
|
|||
userid = downloadUtils.getUserId()
|
||||
|
||||
if fullinfo:
|
||||
url = server + '/mediabrowser/Users/' + userid + '/Items?&SortBy=SortName&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Movie&format=json&ImageTypeLimit=1'
|
||||
url = server + '/mediabrowser/Users/' + userid + '/items?ParentId=' + id + '&SortBy=SortName&Fields=Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,CommunityRating,OfficialRating,CumulativeRunTimeTicks,Metascore,AirTime,DateCreated,MediaStreams,People,Overview&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Movie&format=json&ImageTypeLimit=1'
|
||||
else:
|
||||
url = server + '/mediabrowser/Users/' + userid + '/Items?&SortBy=SortName&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Movie&format=json&ImageTypeLimit=1'
|
||||
url = server + '/mediabrowser/Users/' + userid + '/items?ParentId=' + id + '&SortBy=SortName&Fields=CumulativeRunTimeTicks&Recursive=true&SortOrder=Ascending&IncludeItemTypes=Movie&format=json&ImageTypeLimit=1'
|
||||
|
||||
jsonData = downloadUtils.downloadUrl(url, suppress=True, popup=0)
|
||||
if jsonData != None and jsonData != "":
|
||||
|
@ -475,7 +482,6 @@ class LibrarySync():
|
|||
self.updatePropertyArray(KodiItem,"director",people.get("Director"),"movie")
|
||||
self.updatePropertyArray(KodiItem,"genre",MBitem.get("Genres"),"movie")
|
||||
self.updatePropertyArray(KodiItem,"studio",studios,"movie")
|
||||
|
||||
# FIXME --> ProductionLocations not returned by MB3 server !?
|
||||
self.updatePropertyArray(KodiItem,"country",MBitem.get("ProductionLocations"),"movie")
|
||||
|
||||
|
@ -494,10 +500,9 @@ class LibrarySync():
|
|||
|
||||
self.createSTRM(MBitem)
|
||||
self.createNFO(MBitem)
|
||||
|
||||
#update playcounts
|
||||
if KodiItem['playcount'] != int(userData.get("PlayCount")):
|
||||
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "playcount": %i}, "id": 1 }' %(KodiItem['movieid'], int(userData.get("PlayCount"))))
|
||||
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "tag": "%s", "playcount": %i}, "id": 1 }' %(KodiItem['movieid'], MBitem.get("Tag"), int(userData.get("PlayCount"))))
|
||||
|
||||
def updateTVShowToKodiLibrary( self, MBitem, KodiItem ):
|
||||
|
||||
|
@ -741,7 +746,8 @@ class LibrarySync():
|
|||
xbmcvfs.mkdir(itemPath)
|
||||
root = Element(rootelement)
|
||||
SubElement(root, "id").text = item["Id"]
|
||||
#SubElement(root, "tag").text = # TODO --> use tags to assign user view
|
||||
if item.get("Tag") != None:
|
||||
SubElement(root, "tag").text = item.get("Tag")# TODO --> fix for TV etc
|
||||
SubElement(root, "thumb").text = API().getArtwork(item, "poster")
|
||||
SubElement(root, "fanart").text = API().getArtwork(item, "Backdrop")
|
||||
SubElement(root, "title").text = item["Name"].encode('utf-8').decode('utf-8')
|
||||
|
@ -984,7 +990,7 @@ class LibrarySync():
|
|||
return episode
|
||||
|
||||
|
||||
def getCollections(self):
|
||||
def getCollections(self, type):
|
||||
#Build a list of the user views
|
||||
userid = DownloadUtils().getUserId()
|
||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||
|
@ -1007,7 +1013,7 @@ class LibrarySync():
|
|||
type = view.get("CollectionType")
|
||||
if type == None:
|
||||
type = "None" # User may not have declared the type
|
||||
if type == "movies" or type == "tvshows":
|
||||
if type == type:
|
||||
collections.append( {'title' : Name,
|
||||
'type' : type,
|
||||
'id' : view.get("Id")})
|
||||
|
|
Loading…
Reference in a new issue