Kodi Janitor doesn't work with Krypton yet, and the author said he's not sure when he'll be able to fix it. Here's a python script that replaces (some of) the functionality of Kodi Janitor.
You'll have to replace the string values for MediaDrive, MediDir and WatchedDir at the beginning of the script with the appropriate values for your installation. This script will only work when both the media and the watched folders are on the same local drive. It will handle smb: references to files as long as those references resolve to the same local drive as the watched folder.
One other important note: it depends on the Kodi Watchdog addon to update the Kodi library after the files are moved, so install and enable that in Kodi if you want the library updated automatically.
I have it set up to run after XBMC2.Player.OnStop.episode and XBMC2.VideoLibrary.OnUpdate.episode events. You may want to do the same.
Don't use this script if you don't understand what it's doing.
If you're a better Python programmer than I am (not hard), I'm sure this script could use lots of improvement. Have at it!
Code: Select all
import socket
import os
import glob
import sys
import time
MediaDrive = "D"
MediaDir = "\MEDIA"
WatchedDir = "\WATCHED"
WatchedPath = MediaDrive + ":" + MediaDir + WatchedDir
time.sleep(1)
Episodes = eg.plugins.XBMC2.JSONRPC(u'VideoLibrary.GetEpisodes', u'{ "filter": {"field": "playcount", "operator": "greaterthan", "value": "0"}}', False)
epcount = Episodes['limits']['total']
if epcount == 0:
print "No watched episodes"
sys.exit()
print "Moving " +str(epcount) + " Episodes to " + WatchedPath
watched = Episodes['episodes']
for dict in watched:
epId = dict['episodeid']
Episode = eg.plugins.XBMC2.JSONRPC(u'VideoLibrary.GetEpisodeDetails', u"["+str(epId)+",['file']]", False)
path = Episode['episodedetails']['file']
unc, rest = os.path.splitunc(path)
unc = unc.upper
path = path.upper().replace("SMB://" + socket.gethostname().upper() + "/" + MediaDrive, MediaDrive + ":")
wildpath = os.path.splitext(path)[0] + ".*"
files = glob.glob(wildpath)
for src in files:
print src
dst = WatchedPath + "\\" + os.path.basename(src)
if os.path.isfile(dst):
print "Replacing existing watched file ", dst
os.remove(dst)
time.sleep(1)
os.rename(src, dst)