fixed tv show deletions

This commit is contained in:
Marcel van der Veldt 2015-03-21 11:32:21 +01:00
parent 78bc187c1f
commit 9287706ced
2 changed files with 26 additions and 8 deletions

View file

@ -503,13 +503,14 @@ class LibrarySync():
cleanNeeded = False cleanNeeded = False
# DELETES -- EPISODES
# process any deletes only at fullsync # process any deletes only at fullsync
allMB3EpisodeIds = set(allMB3EpisodeIds) allMB3EpisodeIds = set(allMB3EpisodeIds)
for episode in allKodiEpisodeIds: for episode in allKodiEpisodeIds:
if episode.get('mbid') not in allMB3EpisodeIds: if episode.get('mbid') not in allMB3EpisodeIds:
WriteKodiDB().deleteEpisodeFromKodiLibrary(episode.get('kodiid')) WriteKodiDB().deleteEpisodeFromKodiLibrary(episode.get('kodiid'))
# TODO --> process deletes for episodes !!! # DELETES -- TV SHOWS
if fullsync: if fullsync:
allLocaldirs, filesTVShows = xbmcvfs.listdir(tvLibrary) allLocaldirs, filesTVShows = xbmcvfs.listdir(tvLibrary)
allMB3TVShows = set(allTVShows) allMB3TVShows = set(allTVShows)

View file

@ -635,16 +635,25 @@ class WriteKodiDB():
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveMovie", "params": { "movieid": %i}, "id": 1 }' %(kodiItem["movieid"])) xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveMovie", "params": { "movieid": %i}, "id": 1 }' %(kodiItem["movieid"]))
path = os.path.join(movieLibrary,id) path = os.path.join(movieLibrary,id)
allDirs, allFiles = xbmcvfs.listdir(path)
for dir in allDirs:
xbmcvfs.rmdir(dir)
for file in allFiles:
xbmcvfs.delete(file)
xbmcvfs.rmdir(path) xbmcvfs.rmdir(path)
def deleteEpisodeFromKodiLibrary(self, episodeid ): def deleteEpisodeFromKodiLibrary(self, episodeid ):
utils.logMsg("deleting episode from Kodi library",episodeid) utils.logMsg("deleting episode from Kodi library",episodeid)
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": { "episodeid": %i}, "properties" : ["file","episodeid"] }, "id": 1}' %(int(episodeid))) json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": { "episodeid": %s}, "properties": ["file","originaltitle"] }, "id": 1}' %(str(episodeid)))
print "episodedetails --> " + json_response
if json_response != None and json_response != "" and json_response != []: if json_response != None and json_response != "" and json_response != []:
jsonobject = json.loads(json_response.decode('utf-8','replace')) jsonobject = json.loads(json_response.decode('utf-8','replace'))
print jsonobject print "episodedetails --> " + jsonobject
if(jsonobject.has_key('result')): if(jsonobject.has_key('result')):
result = jsonobject['result'] result = jsonobject['result']
if(result.has_key('episodedetails')): if(result.has_key('episodedetails')):
@ -652,6 +661,8 @@ class WriteKodiDB():
strmfile = episodedetails["file"] strmfile = episodedetails["file"]
nfofile = strmfile.replace(".strm",".nfo") nfofile = strmfile.replace(".strm",".nfo")
print "strmfile -->" + strmfile
print "nfofile -->" + nfofile
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveEpisode", "params": { "episodeid": %i}, "id": 1 }' %(int(episodeid))) xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveEpisode", "params": { "episodeid": %i}, "id": 1 }' %(int(episodeid)))
@ -677,11 +688,17 @@ class WriteKodiDB():
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
kodiItem = ReadKodiDB().getKodiTVShow(id) kodiItem = ReadKodiDB().getKodiTVShow(id)
utils.logMsg("deleting tvshow from Kodi library",id) utils.logMsg("deleting tvshow from Kodi library",id)
if kodiItem != None: if kodiItem != None:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveTVShow", "params": { "tvshowid": %i}, "id": 1 }' %(kodiItem["tvshowid"])) xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveTVShow", "params": { "tvshowid": %i}, "id": 1 }' %(kodiItem["tvshowid"]))
path = os.path.join(tvLibrary,id)
xbmcvfs.rmdir(path)
path = os.path.join(tvLibrary,id)
allDirs, allFiles = xbmcvfs.listdir(path)
for dir in allDirs:
xbmcvfs.rmdir(os.path.join(path,dir))
for file in allFiles:
xbmcvfs.delete(os.path.join(path,file))
xbmcvfs.rmdir(path)
def updateSeasonArtwork(self,MBitem, KodiItem): def updateSeasonArtwork(self,MBitem, KodiItem):
#use sqlite to set the season artwork because no method in API available for this #use sqlite to set the season artwork because no method in API available for this