mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
fixed filepath for episodes
This commit is contained in:
parent
bc207a7268
commit
1b34ce743a
3 changed files with 27 additions and 32 deletions
|
@ -315,7 +315,9 @@ class LibrarySync():
|
||||||
for episode in latestMBEpisodes:
|
for episode in latestMBEpisodes:
|
||||||
if episode["SeriesId"] in allKodiTvShowsIds:
|
if episode["SeriesId"] in allKodiTvShowsIds:
|
||||||
#only process tvshows that already exist in the db at incremental updates
|
#only process tvshows that already exist in the db at incremental updates
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(episode["SeriesId"],True,True)
|
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
||||||
|
kodishow = allKodiTVShows.get(episode["SeriesId"],None)
|
||||||
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],True,True)
|
||||||
|
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
return False
|
return False
|
||||||
|
@ -360,7 +362,9 @@ class LibrarySync():
|
||||||
for episode in latestMBEpisodes:
|
for episode in latestMBEpisodes:
|
||||||
if episode["SeriesId"] in allKodiTvShowsIds:
|
if episode["SeriesId"] in allKodiTvShowsIds:
|
||||||
#only process tvshows that already exist in the db at incremental updates
|
#only process tvshows that already exist in the db at incremental updates
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(episode["SeriesId"],True,True)
|
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
||||||
|
kodishow = allKodiTVShows.get(episode["SeriesId"],None)
|
||||||
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],True,True)
|
||||||
|
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
return False
|
return False
|
||||||
|
@ -433,7 +437,9 @@ class LibrarySync():
|
||||||
for tvshow in allTVShows:
|
for tvshow in allTVShows:
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow,True,True)
|
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
||||||
|
kodishow = allKodiTVShows.get(tvshow,None)
|
||||||
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],True,True)
|
||||||
|
|
||||||
if episodeData != None:
|
if episodeData != None:
|
||||||
|
|
||||||
|
@ -447,6 +453,7 @@ class LibrarySync():
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
#we have to compare the lists somehow
|
#we have to compare the lists somehow
|
||||||
|
# TODO --> instead of matching by season and episode number we can use the uniqueid
|
||||||
for item in episodeData:
|
for item in episodeData:
|
||||||
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
|
@ -518,9 +525,9 @@ class LibrarySync():
|
||||||
# do episode updates
|
# do episode updates
|
||||||
showCurrent = 1
|
showCurrent = 1
|
||||||
for tvshow in allTVShows:
|
for tvshow in allTVShows:
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(tvshow,True,True)
|
kodishow = allKodiTVShows.get(tvshow,None)
|
||||||
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],True,True)
|
||||||
|
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
return False
|
return False
|
||||||
|
@ -533,19 +540,19 @@ class LibrarySync():
|
||||||
|
|
||||||
#we have to compare the lists somehow
|
#we have to compare the lists somehow
|
||||||
for item in episodeData:
|
for item in episodeData:
|
||||||
|
|
||||||
#add episodeId to the list of all episodes for use later on the deletes
|
#add episodeId to the list of all episodes for use later on the deletes
|
||||||
allMB3EpisodeIds.append(item["Id"])
|
allMB3EpisodeIds.append(item["Id"])
|
||||||
|
|
||||||
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
|
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
KodiItem = kodiEpisodes.get(comparestring1, None)
|
KodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
if(KodiItem != None):
|
if(KodiItem != None):
|
||||||
updated = WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem)
|
updated = WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem)
|
||||||
if(updated):
|
if(updated):
|
||||||
totalItemsUpdated += 1
|
totalItemsUpdated += 1
|
||||||
|
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -558,7 +565,7 @@ class LibrarySync():
|
||||||
|
|
||||||
#add all kodi episodes to a list with episodes for use later on to delete episodes
|
#add all kodi episodes to a list with episodes for use later on to delete episodes
|
||||||
#the mediabrowser ID is set as uniqueID in the NFO... for some reason this has key 'unknown' in the json response
|
#the mediabrowser ID is set as uniqueID in the NFO... for some reason this has key 'unknown' in the json response
|
||||||
show = ReadKodiDB().getKodiEpisodes(tvshow,False,False)
|
show = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,False)
|
||||||
if show != None:
|
if show != None:
|
||||||
for episode in show:
|
for episode in show:
|
||||||
dict = {'episodeid': str(episode["uniqueid"]["unknown"]),'tvshowid': tvshow}
|
dict = {'episodeid': str(episode["uniqueid"]["unknown"]),'tvshowid': tvshow}
|
||||||
|
@ -879,7 +886,9 @@ class LibrarySync():
|
||||||
for item in tvshowData:
|
for item in tvshowData:
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
|
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(item["Id"],False,True)
|
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
||||||
|
kodishow = allKodiTVShows.get(item["Id"],None)
|
||||||
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True)
|
||||||
|
|
||||||
if (episodeData != None):
|
if (episodeData != None):
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
|
|
|
@ -129,7 +129,7 @@ class ReadKodiDB():
|
||||||
if fullInfo:
|
if fullInfo:
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "premiered", "rating", "thumbnail", "playcount", "lastplayed", "file", "fanart"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "premiered", "rating", "thumbnail", "playcount", "lastplayed", "file", "fanart"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
||||||
else:
|
else:
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["sorttitle", "title", "playcount", "lastplayed", imdbnumber, "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["sorttitle", "title", "playcount", "lastplayed", "imdbnumber", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||||
tvshows = None
|
tvshows = None
|
||||||
|
|
||||||
|
@ -159,27 +159,19 @@ class ReadKodiDB():
|
||||||
tvshow = tvshows[0]
|
tvshow = tvshows[0]
|
||||||
return tvshow
|
return tvshow
|
||||||
|
|
||||||
def getKodiEpisodes(self, id, fullInfo = True, returnmap = True):
|
def getKodiEpisodes(self, KodiTvShowId, fullInfo = True, returnmap = True):
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
episodes = None
|
episodes = None
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "contains", "field": "imdbnumber", "value": "' + id + '"}, "properties": ["title", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
if fullInfo:
|
||||||
|
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "file", "lastplayed", "rating", "resume", "art", "streamdetails", "firstaired", "runtime", "writer", "cast", "dateadded","uniqueid"], "sort": {"method": "episode"}}, "id": 1}' %KodiTvShowId)
|
||||||
|
else:
|
||||||
|
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "season", "episode", "lastplayed", "resume","file","uniqueid"], "sort": {"method": "episode"}}, "id": 1}' %KodiTvShowId)
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||||
tvshow = None
|
episodes = None
|
||||||
if(jsonobject.has_key('result')):
|
if(jsonobject.has_key('result')):
|
||||||
result = jsonobject['result']
|
result = jsonobject['result']
|
||||||
if(result.has_key('tvshows')):
|
if(result.has_key('episodes')):
|
||||||
tvshows = result['tvshows']
|
episodes = result['episodes']
|
||||||
tvshow = tvshows[0]
|
|
||||||
if fullInfo:
|
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "file", "lastplayed", "rating", "resume", "art", "streamdetails", "firstaired", "runtime", "writer", "cast", "dateadded","uniqueid"], "sort": {"method": "episode"}}, "id": 1}' %tvshow['tvshowid'])
|
|
||||||
else:
|
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "season", "episode", "lastplayed", "resume","file","uniqueid"], "sort": {"method": "episode"}}, "id": 1}' %tvshow['tvshowid'])
|
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
|
||||||
episodes = None
|
|
||||||
if(jsonobject.has_key('result')):
|
|
||||||
result = jsonobject['result']
|
|
||||||
if(result.has_key('episodes')):
|
|
||||||
episodes = result['episodes']
|
|
||||||
if returnmap:
|
if returnmap:
|
||||||
episodeMap = None
|
episodeMap = None
|
||||||
if(episodes != None):
|
if(episodes != None):
|
||||||
|
@ -214,7 +206,6 @@ class ReadKodiDB():
|
||||||
#returns a single musicvideo from Kodi db selected on MB item ID
|
#returns a single musicvideo from Kodi db selected on MB item ID
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties" : ["art", "thumbnail", "resume", "runtime", "year", "genre", "studio", "artist", "album", "track","plot", "director", "playcount", "lastplayed", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMusicVideos"}')
|
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties" : ["art", "thumbnail", "resume", "runtime", "year", "genre", "studio", "artist", "album", "track","plot", "director", "playcount", "lastplayed", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMusicVideos"}')
|
||||||
print json_response
|
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||||
musicvideo = None
|
musicvideo = None
|
||||||
|
|
||||||
|
|
|
@ -868,11 +868,6 @@ class WriteKodiDB():
|
||||||
oldFileName = utils.convertEncoding(oldFileName)
|
oldFileName = utils.convertEncoding(oldFileName)
|
||||||
newFileName = utils.convertEncoding(newFileName)
|
newFileName = utils.convertEncoding(newFileName)
|
||||||
|
|
||||||
print "setting filename for ID..." + str(id) + "...Type-->" + fileType
|
|
||||||
print oldFileName
|
|
||||||
print newFileName
|
|
||||||
|
|
||||||
|
|
||||||
# only perform changes if the path actually differs
|
# only perform changes if the path actually differs
|
||||||
if oldFileName != newFileName:
|
if oldFileName != newFileName:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue