mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +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,41 +51,46 @@ class LibrarySync():
|
||||||
|
|
||||||
#process full movies sync
|
#process full movies sync
|
||||||
allMovies = list()
|
allMovies = list()
|
||||||
movieData = self.getMovies(True)
|
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
views = self.getCollections("movies")
|
||||||
return True
|
for view in views:
|
||||||
|
|
||||||
|
movieData = self.getMovies(view.get('id'), True)
|
||||||
|
|
||||||
if(movieData == None):
|
if(self.ShouldStop()):
|
||||||
return False
|
return True
|
||||||
|
|
||||||
if(pDialog != None):
|
if(movieData == None):
|
||||||
pDialog.update(0, "Sync DB : Processing Movies")
|
return False
|
||||||
total = len(movieData) + 1
|
|
||||||
count = 1
|
if(pDialog != None):
|
||||||
|
pDialog.update(0, "Sync DB : Processing " + view.get('title'))
|
||||||
|
total = len(movieData) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
for item in movieData:
|
for item in movieData:
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
kodiItem = self.getKodiMovie(item["Id"])
|
kodiItem = self.getKodiMovie(item["Id"])
|
||||||
allMovies.append(item["Id"])
|
allMovies.append(item["Id"])
|
||||||
progMessage = "Processing"
|
progMessage = "Processing"
|
||||||
if kodiItem == None:
|
item['Tag'] = view.get('title')
|
||||||
self.addMovieToKodiLibrary(item)
|
if kodiItem == None:
|
||||||
updateNeeded = True
|
self.addMovieToKodiLibrary(item)
|
||||||
progMessage = "Adding"
|
updateNeeded = True
|
||||||
else:
|
progMessage = "Adding"
|
||||||
self.updateMovieToKodiLibrary(item, kodiItem)
|
else:
|
||||||
progMessage = "Updating"
|
self.updateMovieToKodiLibrary(item, kodiItem)
|
||||||
|
progMessage = "Updating"
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# update progress bar
|
# update progress bar
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
percentage = int(((float(count) / float(total)) * 100))
|
percentage = int(((float(count) / float(total)) * 100))
|
||||||
pDialog.update(percentage, message=progMessage + " Movie: " + str(count))
|
pDialog.update(percentage, message=progMessage + " Movie: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
#process full tv shows sync
|
#process full tv shows sync
|
||||||
allTVShows = list()
|
allTVShows = list()
|
||||||
|
@ -233,43 +238,45 @@ 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
|
||||||
|
|
||||||
if(movieData == None):
|
if(movieData == None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.update(0, "Sync PlayCounts: Processing Movies")
|
pDialog.update(0, "Sync PlayCounts: Processing Movies")
|
||||||
totalCount = len(movieData) + 1
|
totalCount = len(movieData) + 1
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
for item in movieData:
|
for item in movieData:
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
kodiItem = self.getKodiMovie(item["Id"])
|
kodiItem = self.getKodiMovie(item["Id"])
|
||||||
userData=API().getUserData(item)
|
userData=API().getUserData(item)
|
||||||
timeInfo = API().getTimeInfo(item)
|
timeInfo = API().getTimeInfo(item)
|
||||||
if kodiItem != None:
|
if kodiItem != None:
|
||||||
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, "playcount": %i}, "id": 1 }' %(kodiItem['movieid'], int(userData.get("PlayCount"))))
|
||||||
|
|
||||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
||||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||||
if kodiresume != resume:
|
if kodiresume != resume:
|
||||||
self.setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
self.setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# update progress bar
|
# update progress bar
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
percentage = int(((float(count) / float(totalCount)) * 100))
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
pDialog.update(percentage, message="Updating Movie: " + str(count))
|
pDialog.update(percentage, message="Updating Movie: " + str(count))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
#process Tv shows
|
#process Tv shows
|
||||||
tvshowData = self.getTVShows(False)
|
tvshowData = self.getTVShows(False)
|
||||||
|
@ -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")
|
||||||
|
|
||||||
|
@ -488,16 +494,15 @@ class LibrarySync():
|
||||||
trailerItem = json.loads(jsonData)
|
trailerItem = json.loads(jsonData)
|
||||||
trailerUrl = "plugin://plugin.video.mb3sync/?id=" + trailerItem[0].get("Id") + '&mode=play'
|
trailerUrl = "plugin://plugin.video.mb3sync/?id=" + trailerItem[0].get("Id") + '&mode=play'
|
||||||
self.updateProperty(KodiItem,"trailer",trailerUrl,"movie")
|
self.updateProperty(KodiItem,"trailer",trailerUrl,"movie")
|
||||||
|
|
||||||
#add actors
|
#add actors
|
||||||
self.AddActorsToMedia(KodiItem,MBitem.get("People"),"movie")
|
self.AddActorsToMedia(KodiItem,MBitem.get("People"),"movie")
|
||||||
|
|
||||||
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