mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Fix for download info
This commit is contained in:
parent
3d1b6b032e
commit
4332ce5967
4 changed files with 17 additions and 17 deletions
|
@ -197,7 +197,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
resume_torrent(clientAgent, inputHash, inputID, result, inputName)
|
resume_torrent(clientAgent, inputHash, inputID, result, inputName)
|
||||||
else:
|
else:
|
||||||
# update download status in our DB
|
# 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
|
# cleanup our processing folders of any misc unwanted files and empty directories
|
||||||
cleanProcDirs()
|
cleanProcDirs()
|
||||||
|
@ -315,13 +315,13 @@ def main(args):
|
||||||
inputHash = None
|
inputHash = None
|
||||||
inputID = None
|
inputID = None
|
||||||
|
|
||||||
logger.info("Checking database for download info ...")
|
logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName)))
|
||||||
downloadInfo = get_downloadInfo(dirName, 0)
|
downloadInfo = get_downloadInfo(os.path.basename(dirName), 0)
|
||||||
if downloadInfo:
|
if downloadInfo:
|
||||||
clientAgent = downloadInfo['client_agent']
|
clientAgent = downloadInfo['client_agent']
|
||||||
inputHash = downloadInfo['input_hash']
|
inputHash = downloadInfo['input_hash']
|
||||||
inputID = downloadInfo['input_id']
|
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))
|
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)
|
results = processTorrent(dirName, os.path.basename(dirName), category, inputHash, inputID, clientAgent)
|
||||||
|
|
|
@ -329,7 +329,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
# update download status in our DB
|
# 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
|
# cleanup our processing folders of any misc unwanted files and empty directories
|
||||||
cleanProcDirs()
|
cleanProcDirs()
|
||||||
|
@ -442,12 +442,12 @@ def main(args, section=None):
|
||||||
clientAgent = 'manual'
|
clientAgent = 'manual'
|
||||||
download_id = None
|
download_id = None
|
||||||
|
|
||||||
logger.info("Checking database for download info ...")
|
logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName)))
|
||||||
downloadInfo = get_downloadInfo(dirName, 0)
|
downloadInfo = get_downloadInfo(os.path.basename(dirName), 0)
|
||||||
if downloadInfo:
|
if downloadInfo:
|
||||||
clientAgent = downloadInfo['client_agent']
|
clientAgent = downloadInfo['client_agent']
|
||||||
download_id = downloadInfo['input_id']
|
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))
|
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)
|
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent, download_id=download_id, inputCategory=category)
|
||||||
|
|
|
@ -25,7 +25,7 @@ class InitialSchema(nzbToMediaDB.SchemaUpgrade):
|
||||||
if not self.hasTable("history") and not self.hasTable("db_version"):
|
if not self.hasTable("history") and not self.hasTable("db_version"):
|
||||||
queries = [
|
queries = [
|
||||||
"CREATE TABLE db_version (db_version INTEGER);",
|
"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);"
|
"INSERT INTO db_version (db_version) VALUES (1);"
|
||||||
]
|
]
|
||||||
for query in queries:
|
for query in queries:
|
||||||
|
|
|
@ -730,19 +730,19 @@ def backupVersionedFile(old_file, version):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def update_downloadInfoStatus(inputDirectory, status):
|
def update_downloadInfoStatus(inputName, status):
|
||||||
logger.db("Updating status of our download in the DB to %s" % (status))
|
logger.db("Updating status of our download %s in the DB to %s" % (inputName, status))
|
||||||
|
|
||||||
myDB = nzbToMediaDB.DBConnection()
|
myDB = nzbToMediaDB.DBConnection()
|
||||||
myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_directory=?",
|
myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_name=?",
|
||||||
[status, datetime.date.today().toordinal(), inputDirectory])
|
[status, datetime.date.today().toordinal(), inputName])
|
||||||
|
|
||||||
|
|
||||||
def get_downloadInfo(inputDirectory, status):
|
def get_downloadInfo(inputName, status):
|
||||||
logger.db("Getting download info from the DB for directory %s" % (inputDirectory))
|
logger.db("Getting download info for %s from the DB" % (inputName))
|
||||||
|
|
||||||
myDB = nzbToMediaDB.DBConnection()
|
myDB = nzbToMediaDB.DBConnection()
|
||||||
sqlResults = myDB.select("SELECT * FROM downloads WHERE input_directory=? AND status=?",
|
sqlResults = myDB.select("SELECT * FROM downloads WHERE input_name=? AND status=?",
|
||||||
[inputDirectory, status])
|
[inputName, status])
|
||||||
|
|
||||||
return sqlResults
|
return sqlResults
|
Loading…
Add table
Add a link
Reference in a new issue