mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 10:36:52 -07:00
Refactor download info to utils.download_info
This commit is contained in:
parent
a50a5edbf7
commit
04942bf6ad
2 changed files with 25 additions and 20 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
@ -20,7 +19,8 @@ from six import text_type
|
|||
import subliminal
|
||||
|
||||
import core
|
||||
from core import extractor, logger, main_db
|
||||
from core import extractor, logger
|
||||
from core.utils.download_info import get_download_info, update_download_info_status
|
||||
from core.utils.parsers import (
|
||||
parse_args, parse_deluge, parse_other, parse_qbittorrent, parse_rtorrent, parse_transmission,
|
||||
parse_utorrent, parse_vuze,
|
||||
|
@ -950,21 +950,3 @@ def backup_versioned_file(old_file, version):
|
|||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def update_download_info_status(input_name, status):
|
||||
logger.db('Updating status of our download {0} in the DB to {1}'.format(input_name, status))
|
||||
|
||||
my_db = main_db.DBConnection()
|
||||
my_db.action('UPDATE downloads SET status=?, last_update=? WHERE input_name=?',
|
||||
[status, datetime.date.today().toordinal(), text_type(input_name)])
|
||||
|
||||
|
||||
def get_download_info(input_name, status):
|
||||
logger.db('Getting download info for {0} from the DB'.format(input_name))
|
||||
|
||||
my_db = main_db.DBConnection()
|
||||
sql_results = my_db.select('SELECT * FROM downloads WHERE input_name=? AND status=?',
|
||||
[text_type(input_name), status])
|
||||
|
||||
return sql_results
|
||||
|
|
23
core/utils/download_info.py
Normal file
23
core/utils/download_info.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import datetime
|
||||
|
||||
from six import text_type
|
||||
|
||||
from core import logger, main_db
|
||||
|
||||
|
||||
def update_download_info_status(input_name, status):
|
||||
logger.db('Updating status of our download {0} in the DB to {1}'.format(input_name, status))
|
||||
|
||||
my_db = main_db.DBConnection()
|
||||
my_db.action('UPDATE downloads SET status=?, last_update=? WHERE input_name=?',
|
||||
[status, datetime.date.today().toordinal(), text_type(input_name)])
|
||||
|
||||
|
||||
def get_download_info(input_name, status):
|
||||
logger.db('Getting download info for {0} from the DB'.format(input_name))
|
||||
|
||||
my_db = main_db.DBConnection()
|
||||
sql_results = my_db.select('SELECT * FROM downloads WHERE input_name=? AND status=?',
|
||||
[text_type(input_name), status])
|
||||
|
||||
return sql_results
|
Loading…
Add table
Add a link
Reference in a new issue