From 4332ce5967a15ae6083780e309875e2f41d12918 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 22 Apr 2014 07:31:57 -0700 Subject: [PATCH] Fix for download info --- TorrentToMedia.py | 8 ++++---- nzbToMedia.py | 8 ++++---- nzbtomedia/databases/mainDB.py | 2 +- nzbtomedia/nzbToMediaUtil.py | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index c81b844a..6414815a 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -197,7 +197,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, resume_torrent(clientAgent, inputHash, inputID, result, inputName) else: # update download status in our DB - update_downloadInfoStatus(inputDirectory, 1) + update_downloadInfoStatus(inputName, 1) # cleanup our processing folders of any misc unwanted files and empty directories cleanProcDirs() @@ -315,13 +315,13 @@ def main(args): inputHash = None inputID = None - logger.info("Checking database for download info ...") - downloadInfo = get_downloadInfo(dirName, 0) + logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName))) + downloadInfo = get_downloadInfo(os.path.basename(dirName), 0) if downloadInfo: clientAgent = downloadInfo['client_agent'] inputHash = downloadInfo['input_hash'] inputID = downloadInfo['input_id'] - logger.info("Found download info for directory %s, setting variables now ..." % (dirName)) + 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) diff --git a/nzbToMedia.py b/nzbToMedia.py index c9437868..e0642985 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -329,7 +329,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down if result == 0: # update download status in our DB - update_downloadInfoStatus(inputDirectory, 1) + update_downloadInfoStatus(inputName, 1) # cleanup our processing folders of any misc unwanted files and empty directories cleanProcDirs() @@ -442,12 +442,12 @@ def main(args, section=None): clientAgent = 'manual' download_id = None - logger.info("Checking database for download info ...") - downloadInfo = get_downloadInfo(dirName, 0) + logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName))) + downloadInfo = get_downloadInfo(os.path.basename(dirName), 0) if downloadInfo: clientAgent = downloadInfo['client_agent'] download_id = downloadInfo['input_id'] - logger.info("Found download info for directory %s, setting variables now ..." % (dirName)) + logger.info("Found download info for %s, setting variables now ..." % (os.path.basename(dirName))) logger.info("Starting manual run for %s:%s - Folder:%s" % (section, category, dirName)) results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent, download_id=download_id, inputCategory=category) diff --git a/nzbtomedia/databases/mainDB.py b/nzbtomedia/databases/mainDB.py index 2d836d30..85f57c8e 100644 --- a/nzbtomedia/databases/mainDB.py +++ b/nzbtomedia/databases/mainDB.py @@ -25,7 +25,7 @@ class InitialSchema(nzbToMediaDB.SchemaUpgrade): if not self.hasTable("history") and not self.hasTable("db_version"): queries = [ "CREATE TABLE db_version (db_version INTEGER);", - "CREATE TABLE downloads (input_directory TEXT PRIMARY KEY, input_name TEXT, input_hash TEXT, input_id TEXT, client_agent TEXT, status INTEGER, last_update NUMERIC);", + "CREATE TABLE downloads (input_directory TEXT, input_name TEXT PRIMARY KEY, input_hash TEXT, input_id TEXT, client_agent TEXT, status INTEGER, last_update NUMERIC);", "INSERT INTO db_version (db_version) VALUES (1);" ] for query in queries: diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index 882dae39..5552034b 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -730,19 +730,19 @@ def backupVersionedFile(old_file, version): return True -def update_downloadInfoStatus(inputDirectory, status): - logger.db("Updating status of our download in the DB to %s" % (status)) +def update_downloadInfoStatus(inputName, status): + logger.db("Updating status of our download %s in the DB to %s" % (inputName, status)) myDB = nzbToMediaDB.DBConnection() - myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_directory=?", - [status, datetime.date.today().toordinal(), inputDirectory]) + myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_name=?", + [status, datetime.date.today().toordinal(), inputName]) -def get_downloadInfo(inputDirectory, status): - logger.db("Getting download info from the DB for directory %s" % (inputDirectory)) +def get_downloadInfo(inputName, status): + logger.db("Getting download info for %s from the DB" % (inputName)) myDB = nzbToMediaDB.DBConnection() - sqlResults = myDB.select("SELECT * FROM downloads WHERE input_directory=? AND status=?", - [inputDirectory, status]) + sqlResults = myDB.select("SELECT * FROM downloads WHERE input_name=? AND status=?", + [inputName, status]) return sqlResults \ No newline at end of file