mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
finished episode deletions
This commit is contained in:
parent
9287706ced
commit
62dda17680
3 changed files with 31 additions and 55 deletions
|
@ -489,7 +489,7 @@ class LibrarySync():
|
||||||
show = ReadKodiDB().getKodiEpisodes(tvshow,False,False)
|
show = ReadKodiDB().getKodiEpisodes(tvshow,False,False)
|
||||||
if show != None:
|
if show != None:
|
||||||
for episode in show:
|
for episode in show:
|
||||||
dict = {'mbid': str(episode["uniqueid"]["unknown"]),'kodiid': str(episode["episodeid"])}
|
dict = {'episodeid': str(episode["uniqueid"]["unknown"]),'tvshowid': tvshow}
|
||||||
allKodiEpisodeIds.append(dict)
|
allKodiEpisodeIds.append(dict)
|
||||||
|
|
||||||
showCurrent += 1
|
showCurrent += 1
|
||||||
|
@ -507,8 +507,8 @@ class LibrarySync():
|
||||||
# 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('episodeid') not in allMB3EpisodeIds:
|
||||||
WriteKodiDB().deleteEpisodeFromKodiLibrary(episode.get('kodiid'))
|
WriteKodiDB().deleteEpisodeFromKodiLibrary(episode.get('episodeid'),episode.get('tvshowid'))
|
||||||
|
|
||||||
# DELETES -- TV SHOWS
|
# DELETES -- TV SHOWS
|
||||||
if fullsync:
|
if fullsync:
|
||||||
|
@ -727,7 +727,7 @@ class LibrarySync():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
MB3Episode = ReadEmbyDB().getItem(itemID)
|
MB3Episode = ReadEmbyDB().getItem(itemID)
|
||||||
kodiItem = ReadKodiDB().getKodiEpisodeByMbItem(MB3Episode)
|
kodiItem = ReadKodiDB().getKodiEpisodeByMbItem(MB3Episode["Id"], MB3Episode["SeriesId"])
|
||||||
if (MB3Episode != None):
|
if (MB3Episode != None):
|
||||||
userData=API().getUserData(MB3Episode)
|
userData=API().getUserData(MB3Episode)
|
||||||
timeInfo = API().getTimeInfo(MB3Episode)
|
timeInfo = API().getTimeInfo(MB3Episode)
|
||||||
|
|
|
@ -166,31 +166,21 @@ class ReadKodiDB():
|
||||||
else:
|
else:
|
||||||
return episodes
|
return episodes
|
||||||
|
|
||||||
def getKodiEpisodeByMbItem(self, MBitem):
|
def getKodiEpisodeByMbItem(self, episodeid, tvshowid):
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "is", "field": "title", "value": "' + MBitem.get("SeriesName").encode('utf-8') + '"} }, "id": "libTvShows"}')
|
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
|
||||||
episode = None
|
episode = None
|
||||||
if(jsonobject.has_key('result')):
|
tvshow = self.getKodiTVShow(tvshowid)
|
||||||
result = jsonobject['result']
|
|
||||||
if(result.has_key('tvshows')):
|
|
||||||
tvshows = result['tvshows']
|
|
||||||
tvshow = tvshows[0]
|
|
||||||
|
|
||||||
# find the episode by combination of season and episode
|
if tvshow != None:
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["playcount","season", "resume", "episode"], "sort": {"method": "episode"}}, "id": 1}' %tvshow['tvshowid'])
|
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": ' + str(tvshow['tvshowid']) + ', "properties": ["playcount","season", "resume", "episode", "uniqueid", "file"], "sort": {"method": "episode"}}, "id": 1}')
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||||
episodes = None
|
if(jsonobject.has_key('result')):
|
||||||
if(jsonobject.has_key('result')):
|
result = jsonobject['result']
|
||||||
result = jsonobject['result']
|
if(result.has_key('episodes')):
|
||||||
if(result.has_key('episodes')):
|
episodes = result['episodes']
|
||||||
episodes = result['episodes']
|
for ep in episodes:
|
||||||
|
if ep["uniqueid"]["unknown"] == episodeid:
|
||||||
comparestring1 = str(MBitem.get("ParentIndexNumber")) + "-" + str(MBitem.get("IndexNumber"))
|
episode = ep
|
||||||
for item in episodes:
|
break
|
||||||
comparestring2 = str(item["season"]) + "-" + str(item["episode"])
|
|
||||||
if comparestring1 == comparestring2:
|
|
||||||
episode = item
|
|
||||||
|
|
||||||
return episode
|
return episode
|
||||||
|
|
||||||
|
|
|
@ -637,37 +637,21 @@ class WriteKodiDB():
|
||||||
path = os.path.join(movieLibrary,id)
|
path = os.path.join(movieLibrary,id)
|
||||||
allDirs, allFiles = xbmcvfs.listdir(path)
|
allDirs, allFiles = xbmcvfs.listdir(path)
|
||||||
for dir in allDirs:
|
for dir in allDirs:
|
||||||
xbmcvfs.rmdir(dir)
|
xbmcvfs.rmdir(os.path.join(path,dir))
|
||||||
for file in allFiles:
|
for file in allFiles:
|
||||||
xbmcvfs.delete(file)
|
xbmcvfs.delete(os.path.join(path,file))
|
||||||
xbmcvfs.rmdir(path)
|
xbmcvfs.rmdir(path)
|
||||||
|
|
||||||
|
|
||||||
def deleteEpisodeFromKodiLibrary(self, episodeid ):
|
def deleteEpisodeFromKodiLibrary(self, episodeid, tvshowid ):
|
||||||
utils.logMsg("deleting episode from Kodi library",episodeid)
|
utils.logMsg("deleting episode from Kodi library",episodeid)
|
||||||
|
episode = ReadKodiDB().getKodiEpisodeByMbItem(episodeid, tvshowid)
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": { "episodeid": %s}, "properties": ["file","originaltitle"] }, "id": 1}' %(str(episodeid)))
|
if episode != None:
|
||||||
|
strmfile = episode["file"]
|
||||||
print "episodedetails --> " + json_response
|
nfofile = strmfile.replace(".strm",".nfo")
|
||||||
|
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveEpisode", "params": { "episodeid": %i}, "id": 1 }' %(episode["episodeid"]))
|
||||||
if json_response != None and json_response != "" and json_response != []:
|
xbmcvfs.delete(strmfile)
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
xbmcvfs.delete(nfofile)
|
||||||
|
|
||||||
print "episodedetails --> " + jsonobject
|
|
||||||
if(jsonobject.has_key('result')):
|
|
||||||
result = jsonobject['result']
|
|
||||||
if(result.has_key('episodedetails')):
|
|
||||||
episodedetails = result['episodedetails']
|
|
||||||
|
|
||||||
strmfile = episodedetails["file"]
|
|
||||||
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)))
|
|
||||||
|
|
||||||
xbmcvfs.delete(strmfile)
|
|
||||||
xbmcvfs.delete(nfofile)
|
|
||||||
|
|
||||||
def addTVShowToKodiLibrary( self, item ):
|
def addTVShowToKodiLibrary( self, item ):
|
||||||
itemPath = os.path.join(tvLibrary,item["Id"])
|
itemPath = os.path.join(tvLibrary,item["Id"])
|
||||||
|
@ -698,7 +682,9 @@ class WriteKodiDB():
|
||||||
xbmcvfs.rmdir(os.path.join(path,dir))
|
xbmcvfs.rmdir(os.path.join(path,dir))
|
||||||
for file in allFiles:
|
for file in allFiles:
|
||||||
xbmcvfs.delete(os.path.join(path,file))
|
xbmcvfs.delete(os.path.join(path,file))
|
||||||
xbmcvfs.rmdir(path)
|
succes = xbmcvfs.rmdir(path)
|
||||||
|
if not succes:
|
||||||
|
utils.logMsg("Error deleting TV show with ID ",id)
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue