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
|
#process full movies sync
|
||||||
allMovies = list()
|
allMovies = list()
|
||||||
movieData = self.getMovies(True)
|
|
||||||
|
views = self.getCollections("movies")
|
||||||
|
for view in views:
|
||||||
|
|
||||||
|
movieData = self.getMovies(view.get('id'), True)
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
@ -60,7 +64,7 @@ class LibrarySync():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, "Sync DB : Processing Movies")
|
pDialog.update(0, "Sync DB : Processing " + view.get('title'))
|
||||||
total = len(movieData) + 1
|
total = len(movieData) + 1
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
|
@ -70,6 +74,7 @@ class LibrarySync():
|
||||||
kodiItem = self.getKodiMovie(item["Id"])
|
kodiItem = self.getKodiMovie(item["Id"])
|
||||||
allMovies.append(item["Id"])
|
allMovies.append(item["Id"])
|
||||||
progMessage = "Processing"
|
progMessage = "Processing"
|
||||||
|
item['Tag'] = view.get('title')
|
||||||
if kodiItem == None:
|
if kodiItem == None:
|
||||||
self.addMovieToKodiLibrary(item)
|
self.addMovieToKodiLibrary(item)
|
||||||
updateNeeded = True
|
updateNeeded = True
|
||||||
|
@ -233,7 +238,9 @@ class LibrarySync():
|
||||||
pDialog.create('Sync PlayCounts', 'Sync PlayCounts')
|
pDialog.create('Sync PlayCounts', 'Sync PlayCounts')
|
||||||
|
|
||||||
#process movies
|
#process movies
|
||||||
movieData = self.getMovies(False)
|
views = self.getCollections("movies")
|
||||||
|
for view in views:
|
||||||
|
movieData = self.getMovies(view.get('id'),False)
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
@ -320,7 +327,7 @@ class LibrarySync():
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getMovies(self, fullinfo = False):
|
def getMovies(self, id, fullinfo = False):
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
|
@ -332,9 +339,9 @@ class LibrarySync():
|
||||||
userid = downloadUtils.getUserId()
|
userid = downloadUtils.getUserId()
|
||||||
|
|
||||||
if fullinfo:
|
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:
|
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)
|
jsonData = downloadUtils.downloadUrl(url, suppress=True, popup=0)
|
||||||
if jsonData != None and jsonData != "":
|
if jsonData != None and jsonData != "":
|
||||||
|
@ -475,7 +482,6 @@ class LibrarySync():
|
||||||
self.updatePropertyArray(KodiItem,"director",people.get("Director"),"movie")
|
self.updatePropertyArray(KodiItem,"director",people.get("Director"),"movie")
|
||||||
self.updatePropertyArray(KodiItem,"genre",MBitem.get("Genres"),"movie")
|
self.updatePropertyArray(KodiItem,"genre",MBitem.get("Genres"),"movie")
|
||||||
self.updatePropertyArray(KodiItem,"studio",studios,"movie")
|
self.updatePropertyArray(KodiItem,"studio",studios,"movie")
|
||||||
|
|
||||||
# FIXME --> ProductionLocations not returned by MB3 server !?
|
# FIXME --> ProductionLocations not returned by MB3 server !?
|
||||||
self.updatePropertyArray(KodiItem,"country",MBitem.get("ProductionLocations"),"movie")
|
self.updatePropertyArray(KodiItem,"country",MBitem.get("ProductionLocations"),"movie")
|
||||||
|
|
||||||
|
@ -494,10 +500,9 @@ class LibrarySync():
|
||||||
|
|
||||||
self.createSTRM(MBitem)
|
self.createSTRM(MBitem)
|
||||||
self.createNFO(MBitem)
|
self.createNFO(MBitem)
|
||||||
|
|
||||||
#update playcounts
|
#update playcounts
|
||||||
if KodiItem['playcount'] != int(userData.get("PlayCount")):
|
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 ):
|
def updateTVShowToKodiLibrary( self, MBitem, KodiItem ):
|
||||||
|
|
||||||
|
@ -741,7 +746,8 @@ class LibrarySync():
|
||||||
xbmcvfs.mkdir(itemPath)
|
xbmcvfs.mkdir(itemPath)
|
||||||
root = Element(rootelement)
|
root = Element(rootelement)
|
||||||
SubElement(root, "id").text = item["Id"]
|
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, "thumb").text = API().getArtwork(item, "poster")
|
||||||
SubElement(root, "fanart").text = API().getArtwork(item, "Backdrop")
|
SubElement(root, "fanart").text = API().getArtwork(item, "Backdrop")
|
||||||
SubElement(root, "title").text = item["Name"].encode('utf-8').decode('utf-8')
|
SubElement(root, "title").text = item["Name"].encode('utf-8').decode('utf-8')
|
||||||
|
@ -984,7 +990,7 @@ class LibrarySync():
|
||||||
return episode
|
return episode
|
||||||
|
|
||||||
|
|
||||||
def getCollections(self):
|
def getCollections(self, type):
|
||||||
#Build a list of the user views
|
#Build a list of the user views
|
||||||
userid = DownloadUtils().getUserId()
|
userid = DownloadUtils().getUserId()
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
|
@ -1007,7 +1013,7 @@ class LibrarySync():
|
||||||
type = view.get("CollectionType")
|
type = view.get("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 == "movies" or type == "tvshows":
|
if type == type:
|
||||||
collections.append( {'title' : Name,
|
collections.append( {'title' : Name,
|
||||||
'type' : type,
|
'type' : type,
|
||||||
'id' : view.get("Id")})
|
'id' : view.get("Id")})
|
||||||
|
|
Loading…
Reference in a new issue