diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 4ff1949b..6b9e7f57 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -22,6 +22,11 @@ from utorrent.client import UTorrentClient nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) Logger = logging.getLogger(__name__) + +def category_search_recurs(inputDirectory, inputName, root, categories): + pass + + def category_search(inputDirectory, inputName, inputCategory, root, categories): categorySearch = [os.path.normpath(inputDirectory),""] #initializie notfound = 0 @@ -272,7 +277,7 @@ config.read(configFilename) clientAgent = config.get("Torrent", "clientAgent") try: - parse_args(clientAgent) + inputDirectory, inputName, inputCategory = parse_args(clientAgent) except: Logger.error("MAIN: There was a problem loading variables: Exiting") sys.exit(-1) diff --git a/nzbToMediaUtil.py b/nzbToMediaUtil.py index 61f96ee2..0adad281 100644 --- a/nzbToMediaUtil.py +++ b/nzbToMediaUtil.py @@ -13,9 +13,11 @@ def nzbtomedia_configure_logging(dirname): fileHandler.level = logging.DEBUG logging.getLogger().addHandler(fileHandler) + def parse_other(args): return os.path.normpath(sys.argv[1]), '', '' + def parse_utorrent(args): # uTorrent usage: call TorrentToMedia.py "%D" "%N" "%L" "%I" inputDirectory = os.path.normpath(sys.argv[1]) @@ -28,20 +30,28 @@ def parse_utorrent(args): inputHash = sys.argv[4] except: inputHash = '' + if inputHash: utorrentClass = UTorrentClient(uTorrentWEBui, uTorrentUSR, uTorrentPWD) + return inputDirectory, inputName, inputCategory + + def parse_deluge(args): # Deluge usage: call TorrentToMedia.py TORRENT_ID TORRENT_NAME TORRENT_DIR inputDirectory = os.path.normpath(sys.argv[3]) inputName = sys.argv[2] inputCategory = '' # We dont have a category yet + return inputDirectory, inputName, inputCategory + def parse_transmission(args): # Transmission usage: call TorrenToMedia.py (%TR_TORRENT_DIR% %TR_TORRENT_NAME% is passed on as environmental variables) inputDirectory = os.path.normpath(os.getenv('TR_TORRENT_DIR')) inputName = os.getenv('TR_TORRENT_NAME') inputCategory = '' # We dont have a category yet + return inputDirectory, inputName, inputCategory + __ARG_PARSERS__ = { 'other': parse_other, @@ -50,8 +60,9 @@ __ARG_PARSERS__ = { 'transmission': parse_transmission, } + def parse_args(clientAgent): parseFunc = __ARG_PARSERS__.get(clientAgent, None) if not parseFunc: raise RuntimeError("Could not find client-agent") - parseFunc(sys.argv) + return parseFunc(sys.argv)