From 0e7b8eacab92d87130522d20a671b96947ebc103 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 22 Apr 2014 19:11:35 -0700 Subject: [PATCH] Added code in to confirm that the clientAgent returned from the download info in the DB is correct for the script being run so that nzb's don't get processed by torrent scripts and vise-versa. --- TorrentToMedia.py | 4 ++++ nzbToMedia.py | 3 +++ nzbtomedia/__init__.py | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 2abedc47..cca23a71 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -311,10 +311,14 @@ def main(args): downloadInfo = nzbtomedia.get_downloadInfo(os.path.basename(dirName), 0) if downloadInfo: clientAgent = str(downloadInfo['client_agent'][0]) + if not clientAgent.lower() in nzbtomedia.TORRENT_CLIENTS: + continue + inputHash = str(downloadInfo['input_hash'][0]) inputID = str(downloadInfo['input_id'][0]) logger.info("Found download info for %s, setting variables now ..." % (os.path.basename(dirName))) + logger.info("Running %s:%s as a manual run for folder %s ..." % (section, category, dirName)) results = processTorrent(dirName, os.path.basename(dirName), category, inputHash, inputID, clientAgent) if results != 0: diff --git a/nzbToMedia.py b/nzbToMedia.py index 206229b4..04c7a90e 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -446,6 +446,9 @@ def main(args, section=None): downloadInfo = get_downloadInfo(os.path.basename(dirName), 0) if downloadInfo: clientAgent = str(downloadInfo['client_agent'][0]) + if not clientAgent.lower() in nzbtomedia.NZB_CLIENTS: + continue + download_id = str(downloadInfo['input_id'][0]) logger.info("Found download info for %s, setting variables now ..." % (os.path.basename(dirName))) diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index 37b44261..ae0e34a4 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -34,6 +34,10 @@ from nzbtomedia.nzbToMediaUtil import category_search, sanitizeFileName, copy_li from nzbtomedia.transcoder import transcoder from nzbtomedia.databases import mainDB +# Client Agents +NZB_CLIENTS = ['sabnzbd','nzbget'] +TORRENT_CLIENTS = ['transmission', 'deluge', 'utorrent'] + # sabnzbd constants SABNZB_NO_OF_ARGUMENTS = 8 SABNZB_0717_NO_OF_ARGUMENTS = 9