fixed filepath for episodes

This commit is contained in:
Marcel van der Veldt 2015-03-29 19:13:21 +02:00
parent bc207a7268
commit 1b34ce743a
3 changed files with 27 additions and 32 deletions

View file

@ -315,7 +315,9 @@ class LibrarySync():
for episode in latestMBEpisodes:
if episode["SeriesId"] in allKodiTvShowsIds:
#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)):
return False
@ -360,7 +362,9 @@ class LibrarySync():
for episode in latestMBEpisodes:
if episode["SeriesId"] in allKodiTvShowsIds:
#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)):
return False
@ -433,7 +437,9 @@ class LibrarySync():
for tvshow in allTVShows:
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:
@ -447,6 +453,7 @@ class LibrarySync():
count = 0
#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:
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False
@ -518,9 +525,9 @@ class LibrarySync():
# do episode updates
showCurrent = 1
for tvshow in allTVShows:
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)):
return False
@ -533,12 +540,12 @@ class LibrarySync():
#we have to compare the lists somehow
for item in episodeData:
#add episodeId to the list of all episodes for use later on the deletes
allMB3EpisodeIds.append(item["Id"])
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False
if kodiEpisodes != None:
KodiItem = kodiEpisodes.get(comparestring1, None)
if(KodiItem != None):
@ -558,7 +565,7 @@ class LibrarySync():
#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
show = ReadKodiDB().getKodiEpisodes(tvshow,False,False)
show = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,False)
if show != None:
for episode in show:
dict = {'episodeid': str(episode["uniqueid"]["unknown"]),'tvshowid': tvshow}
@ -879,7 +886,9 @@ class LibrarySync():
for item in tvshowData:
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(pDialog != None):

View file

@ -129,7 +129,7 @@ class ReadKodiDB():
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"}')
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'))
tvshows = None
@ -159,21 +159,13 @@ class ReadKodiDB():
tvshow = tvshows[0]
return tvshow
def getKodiEpisodes(self, id, fullInfo = True, returnmap = True):
def getKodiEpisodes(self, KodiTvShowId, fullInfo = True, returnmap = True):
xbmc.sleep(sleepVal)
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"}')
jsonobject = json.loads(json_response.decode('utf-8','replace'))
tvshow = None
if(jsonobject.has_key('result')):
result = jsonobject['result']
if(result.has_key('tvshows')):
tvshows = result['tvshows']
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'])
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}' %tvshow['tvshowid'])
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'))
episodes = None
if(jsonobject.has_key('result')):
@ -214,7 +206,6 @@ class ReadKodiDB():
#returns a single musicvideo from Kodi db selected on MB item ID
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"}')
print json_response
jsonobject = json.loads(json_response.decode('utf-8','replace'))
musicvideo = None

View file

@ -868,11 +868,6 @@ class WriteKodiDB():
oldFileName = utils.convertEncoding(oldFileName)
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
if oldFileName != newFileName: