mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
Merge pull request #1532 from clinton-hall/refactor/configuration
Refactor configuration
This commit is contained in:
commit
80a9576fc3
14 changed files with 486 additions and 229 deletions
|
@ -22,7 +22,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
|||
root = 0
|
||||
found_file = 0
|
||||
|
||||
if client_agent != 'manual' and not core.DOWNLOADINFO:
|
||||
if client_agent != 'manual' and not core.DOWNLOAD_INFO:
|
||||
logger.debug('Adding TORRENT download info for directory {0} to database'.format(input_directory))
|
||||
|
||||
my_db = main_db.DBConnection()
|
||||
|
@ -114,13 +114,13 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
|||
basename = os.path.basename(input_directory)
|
||||
basename = core.sanitize_name(input_name) \
|
||||
if input_name == basename else os.path.splitext(core.sanitize_name(input_name))[0]
|
||||
output_destination = os.path.join(core.OUTPUTDIRECTORY, input_category, basename)
|
||||
output_destination = os.path.join(core.OUTPUT_DIRECTORY, input_category, basename)
|
||||
elif unique_path:
|
||||
output_destination = os.path.normpath(
|
||||
core.os.path.join(core.OUTPUTDIRECTORY, input_category, core.sanitize_name(input_name).replace(' ', '.')))
|
||||
core.os.path.join(core.OUTPUT_DIRECTORY, input_category, core.sanitize_name(input_name).replace(' ', '.')))
|
||||
else:
|
||||
output_destination = os.path.normpath(
|
||||
core.os.path.join(core.OUTPUTDIRECTORY, input_category))
|
||||
core.os.path.join(core.OUTPUT_DIRECTORY, input_category))
|
||||
try:
|
||||
output_destination = output_destination.encode(core.SYS_ENCODING)
|
||||
except UnicodeError:
|
||||
|
@ -131,7 +131,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
|||
|
||||
logger.info('Output directory set to: {0}'.format(output_destination))
|
||||
|
||||
if core.SAFE_MODE and output_destination == core.TORRENT_DEFAULTDIR:
|
||||
if core.SAFE_MODE and output_destination == core.TORRENT_DEFAULT_DIRECTORY:
|
||||
logger.error('The output directory:[{0}] is the Download Directory. '
|
||||
'Edit outputDirectory in autoProcessMedia.cfg. Exiting'.format
|
||||
(input_directory))
|
||||
|
@ -196,7 +196,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
|||
|
||||
if torrent_no_link == 0:
|
||||
try:
|
||||
core.copy_link(inputFile, target_file, core.USELINK)
|
||||
core.copy_link(inputFile, target_file, core.USE_LINK)
|
||||
core.remove_read_only(target_file)
|
||||
except Exception:
|
||||
logger.error('Failed to link: {0} to {1}'.format(inputFile, target_file))
|
||||
|
@ -270,7 +270,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
|||
core.update_download_info_status(input_name, 1)
|
||||
|
||||
# remove torrent
|
||||
if core.USELINK == 'move-sym' and not core.DELETE_ORIGINAL == 1:
|
||||
if core.USE_LINK == 'move-sym' and not core.DELETE_ORIGINAL == 1:
|
||||
logger.debug('Checking for sym-links to re-direct in: {0}'.format(input_directory))
|
||||
for dirpath, dirs, files in os.walk(input_directory):
|
||||
for file in files:
|
||||
|
@ -291,7 +291,7 @@ def main(args):
|
|||
core.initialize()
|
||||
|
||||
# clientAgent for Torrents
|
||||
client_agent = core.TORRENT_CLIENTAGENT
|
||||
client_agent = core.TORRENT_CLIENT_AGENT
|
||||
|
||||
logger.info('#########################################################')
|
||||
logger.info('## ..::[{0}]::.. ##'.format(os.path.basename(__file__)))
|
||||
|
@ -328,11 +328,11 @@ def main(args):
|
|||
|
||||
logger.info('Checking database for download info for {0} ...'.format
|
||||
(os.path.basename(dir_name)))
|
||||
core.DOWNLOADINFO = core.get_download_info(os.path.basename(dir_name), 0)
|
||||
if core.DOWNLOADINFO:
|
||||
client_agent = text_type(core.DOWNLOADINFO[0].get('client_agent', 'manual'))
|
||||
input_hash = text_type(core.DOWNLOADINFO[0].get('input_hash', ''))
|
||||
input_id = text_type(core.DOWNLOADINFO[0].get('input_id', ''))
|
||||
core.DOWNLOAD_INFO = core.get_download_info(os.path.basename(dir_name), 0)
|
||||
if core.DOWNLOAD_INFO:
|
||||
client_agent = text_type(core.DOWNLOAD_INFO[0].get('client_agent', 'manual'))
|
||||
input_hash = text_type(core.DOWNLOAD_INFO[0].get('input_hash', ''))
|
||||
input_id = text_type(core.DOWNLOAD_INFO[0].get('input_id', ''))
|
||||
logger.info('Found download info for {0}, '
|
||||
'setting variables now ...'.format(os.path.basename(dir_name)))
|
||||
else:
|
||||
|
|
587
core/__init__.py
587
core/__init__.py
|
@ -105,7 +105,7 @@ FORKS = {
|
|||
ALL_FORKS = {k: None for k in set(list(itertools.chain.from_iterable([FORKS[x].keys() for x in FORKS.keys()])))}
|
||||
|
||||
# NZBGet Exit Codes
|
||||
NZBGET_POSTPROCESS_PARCHECK = 92
|
||||
NZBGET_POSTPROCESS_PAR_CHECK = 92
|
||||
NZBGET_POSTPROCESS_SUCCESS = 93
|
||||
NZBGET_POSTPROCESS_ERROR = 94
|
||||
NZBGET_POSTPROCESS_NONE = 95
|
||||
|
@ -131,55 +131,55 @@ FORCE_CLEAN = None
|
|||
SAFE_MODE = None
|
||||
NOEXTRACTFAILED = None
|
||||
|
||||
NZB_CLIENTAGENT = None
|
||||
SABNZBDHOST = None
|
||||
SABNZBDPORT = None
|
||||
SABNZBDAPIKEY = None
|
||||
NZB_DEFAULTDIR = None
|
||||
NZB_CLIENT_AGENT = None
|
||||
SABNZBD_HOST = None
|
||||
SABNZBD_PORT = None
|
||||
SABNZBD_APIKEY = None
|
||||
NZB_DEFAULT_DIRECTORY = None
|
||||
|
||||
TORRENT_CLIENTAGENT = None
|
||||
TORRENT_CLIENT_AGENT = None
|
||||
TORRENT_CLASS = None
|
||||
USELINK = None
|
||||
OUTPUTDIRECTORY = None
|
||||
USE_LINK = None
|
||||
OUTPUT_DIRECTORY = None
|
||||
NOFLATTEN = []
|
||||
DELETE_ORIGINAL = None
|
||||
TORRENT_CHMOD_DIRECTORY = None
|
||||
TORRENT_DEFAULTDIR = None
|
||||
TORRENT_DEFAULT_DIRECTORY = None
|
||||
TORRENT_RESUME = None
|
||||
TORRENT_RESUME_ON_FAILURE = None
|
||||
|
||||
REMOTEPATHS = []
|
||||
REMOTE_PATHS = []
|
||||
|
||||
UTORRENTWEBUI = None
|
||||
UTORRENTUSR = None
|
||||
UTORRENTPWD = None
|
||||
UTORRENT_WEB_UI = None
|
||||
UTORRENT_USER = None
|
||||
UTORRENT_PASSWORD = None
|
||||
|
||||
TRANSMISSIONHOST = None
|
||||
TRANSMISSIONPORT = None
|
||||
TRANSMISSIONUSR = None
|
||||
TRANSMISSIONPWD = None
|
||||
TRANSMISSION_HOST = None
|
||||
TRANSMISSION_PORT = None
|
||||
TRANSMISSION_USER = None
|
||||
TRANSMISSION_PASSWORD = None
|
||||
|
||||
DELUGEHOST = None
|
||||
DELUGEPORT = None
|
||||
DELUGEUSR = None
|
||||
DELUGEPWD = None
|
||||
DELUGE_HOST = None
|
||||
DELUGE_PORT = None
|
||||
DELUGE_USER = None
|
||||
DELUGE_PASSWORD = None
|
||||
|
||||
QBITTORRENTHOST = None
|
||||
QBITTORRENTPORT = None
|
||||
QBITTORRENTUSR = None
|
||||
QBITTORRENTPWD = None
|
||||
QBITTORRENT_HOST = None
|
||||
QBITTORRENT_PORT = None
|
||||
QBITTORRENT_USER = None
|
||||
QBITTORRENT_PASSWORD = None
|
||||
|
||||
PLEXSSL = None
|
||||
PLEXHOST = None
|
||||
PLEXPORT = None
|
||||
PLEXTOKEN = None
|
||||
PLEXSEC = []
|
||||
PLEX_SSL = None
|
||||
PLEX_HOST = None
|
||||
PLEX_PORT = None
|
||||
PLEX_TOKEN = None
|
||||
PLEX_SECTION = []
|
||||
|
||||
EXTCONTAINER = []
|
||||
COMPRESSEDCONTAINER = []
|
||||
MEDIACONTAINER = []
|
||||
AUDIOCONTAINER = []
|
||||
METACONTAINER = []
|
||||
EXT_CONTAINER = []
|
||||
COMPRESSED_CONTAINER = []
|
||||
MEDIA_CONTAINER = []
|
||||
AUDIO_CONTAINER = []
|
||||
META_CONTAINER = []
|
||||
|
||||
SECTIONS = []
|
||||
CATEGORIES = []
|
||||
|
@ -236,8 +236,8 @@ CHECK_MEDIA = None
|
|||
NICENESS = []
|
||||
HWACCEL = False
|
||||
|
||||
PASSWORDSFILE = None
|
||||
DOWNLOADINFO = None
|
||||
PASSWORDS_FILE = None
|
||||
DOWNLOAD_INFO = None
|
||||
GROUPS = None
|
||||
|
||||
USER_SCRIPT_MEDIAEXTENSIONS = None
|
||||
|
@ -251,28 +251,9 @@ USER_SCRIPT_RUNONCE = None
|
|||
__INITIALIZED__ = False
|
||||
|
||||
|
||||
def initialize(section=None):
|
||||
global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PARCHECK, NZBGET_POSTPROCESS_SUCCESS, \
|
||||
NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \
|
||||
NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \
|
||||
SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \
|
||||
NOFLATTEN, UTORRENTPWD, UTORRENTUSR, UTORRENTWEBUI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \
|
||||
TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \
|
||||
METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \
|
||||
__INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \
|
||||
GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \
|
||||
DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \
|
||||
VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \
|
||||
ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \
|
||||
SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, LOG_DIR, LOG_FILE, \
|
||||
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \
|
||||
DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
|
||||
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
||||
TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \
|
||||
PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC, TORRENT_RESUME, PAR2CMD, QBITTORRENTHOST, QBITTORRENTPORT, QBITTORRENTUSR, QBITTORRENTPWD
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
def configure_logging():
|
||||
global LOG_FILE
|
||||
global LOG_DIR
|
||||
|
||||
if 'NTM_LOGFILE' in os.environ:
|
||||
LOG_FILE = os.environ['NTM_LOGFILE']
|
||||
|
@ -281,11 +262,19 @@ def initialize(section=None):
|
|||
if not make_dir(LOG_DIR):
|
||||
print('No log folder, logging to screen only')
|
||||
|
||||
|
||||
def configure_process():
|
||||
global MYAPP
|
||||
|
||||
MYAPP = RunningProcess()
|
||||
while MYAPP.alreadyrunning():
|
||||
print('Waiting for existing session to end')
|
||||
time.sleep(30)
|
||||
|
||||
|
||||
def configure_locale():
|
||||
global SYS_ENCODING
|
||||
|
||||
try:
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
SYS_ENCODING = locale.getpreferredencoding()
|
||||
|
@ -313,8 +302,10 @@ def initialize(section=None):
|
|||
else:
|
||||
sys.exit(1)
|
||||
|
||||
# init logging
|
||||
logger.ntm_log_instance.init_logging()
|
||||
|
||||
def configure_migration():
|
||||
global CONFIG_FILE
|
||||
global CFG
|
||||
|
||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||
if not config.migrate():
|
||||
|
@ -332,9 +323,16 @@ def initialize(section=None):
|
|||
logger.info('Loading config from [{0}]'.format(CONFIG_FILE))
|
||||
CFG = config()
|
||||
|
||||
|
||||
def configure_logging_part_2():
|
||||
global LOG_DB
|
||||
global LOG_DEBUG
|
||||
global LOG_ENV
|
||||
global LOG_GIT
|
||||
|
||||
# Enable/Disable DEBUG Logging
|
||||
LOG_DEBUG = int(CFG['General']['log_debug'])
|
||||
LOG_DB = int(CFG['General']['log_db'])
|
||||
LOG_DEBUG = int(CFG['General']['log_debug'])
|
||||
LOG_ENV = int(CFG['General']['log_env'])
|
||||
LOG_GIT = int(CFG['General']['log_git'])
|
||||
|
||||
|
@ -342,12 +340,21 @@ def initialize(section=None):
|
|||
for item in os.environ:
|
||||
logger.info('{0}: {1}'.format(item, os.environ[item]), 'ENVIRONMENT')
|
||||
|
||||
# initialize the main SB database
|
||||
main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema)
|
||||
|
||||
def configure_general():
|
||||
global VERSION_NOTIFY
|
||||
global GIT_REPO
|
||||
global GIT_PATH
|
||||
global GIT_USER
|
||||
global GIT_BRANCH
|
||||
global FORCE_CLEAN
|
||||
global FFMPEG_PATH
|
||||
global CHECK_MEDIA
|
||||
global SAFE_MODE
|
||||
global NOEXTRACTFAILED
|
||||
|
||||
# Set Version and GIT variables
|
||||
VERSION_NOTIFY = int(CFG['General']['version_notify'])
|
||||
AUTO_UPDATE = int(CFG['General']['auto_update'])
|
||||
GIT_REPO = 'nzbToMedia'
|
||||
GIT_PATH = CFG['General']['git_path']
|
||||
GIT_USER = CFG['General']['git_user'] or 'clinton-hall'
|
||||
|
@ -358,130 +365,320 @@ def initialize(section=None):
|
|||
SAFE_MODE = int(CFG['General']['safe_mode'])
|
||||
NOEXTRACTFAILED = int(CFG['General']['no_extract_failed'])
|
||||
|
||||
|
||||
def configure_updates():
|
||||
global AUTO_UPDATE
|
||||
global MYAPP
|
||||
|
||||
AUTO_UPDATE = int(CFG['General']['auto_update'])
|
||||
version_checker = version_check.CheckVersion()
|
||||
|
||||
# Check for updates via GitHUB
|
||||
if version_check.CheckVersion().check_for_new_version():
|
||||
if AUTO_UPDATE == 1:
|
||||
logger.info('Auto-Updating nzbToMedia, Please wait ...')
|
||||
updated = version_check.CheckVersion().update()
|
||||
if updated:
|
||||
# restart nzbToMedia
|
||||
try:
|
||||
del MYAPP
|
||||
except Exception:
|
||||
pass
|
||||
restart()
|
||||
else:
|
||||
logger.error('Update wasn\'t successful, not restarting. Check your log for more information.')
|
||||
if version_checker.check_for_new_version() and AUTO_UPDATE:
|
||||
logger.info('Auto-Updating nzbToMedia, Please wait ...')
|
||||
if version_checker.update():
|
||||
# restart nzbToMedia
|
||||
try:
|
||||
del MYAPP
|
||||
except Exception:
|
||||
pass
|
||||
restart()
|
||||
else:
|
||||
logger.error('Update failed, not restarting. Check your log for more information.')
|
||||
|
||||
# Set Current Version
|
||||
logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format
|
||||
(version=NZBTOMEDIA_VERSION, branch=GIT_BRANCH,
|
||||
system=platform.system(), release=platform.release()))
|
||||
|
||||
if int(CFG['WakeOnLan']['wake']) == 1:
|
||||
|
||||
def configure_wake_on_lan():
|
||||
if int(CFG['WakeOnLan']['wake']):
|
||||
wake_up()
|
||||
|
||||
NZB_CLIENTAGENT = CFG['Nzb']['clientAgent'] # sabnzbd
|
||||
SABNZBDHOST = CFG['Nzb']['sabnzbd_host']
|
||||
SABNZBDPORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accomodate NzbGet
|
||||
SABNZBDAPIKEY = CFG['Nzb']['sabnzbd_apikey']
|
||||
NZB_DEFAULTDIR = CFG['Nzb']['default_downloadDirectory']
|
||||
|
||||
def configure_sabnzbd():
|
||||
global SABNZBD_HOST
|
||||
global SABNZBD_PORT
|
||||
global SABNZBD_APIKEY
|
||||
|
||||
SABNZBD_HOST = CFG['Nzb']['sabnzbd_host']
|
||||
SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accommodate NzbGet
|
||||
SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey']
|
||||
|
||||
|
||||
def configure_nzbs():
|
||||
global NZB_CLIENT_AGENT
|
||||
global NZB_DEFAULT_DIRECTORY
|
||||
|
||||
NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd
|
||||
NZB_DEFAULT_DIRECTORY = CFG['Nzb']['default_downloadDirectory']
|
||||
|
||||
configure_sabnzbd()
|
||||
|
||||
|
||||
def configure_groups():
|
||||
global GROUPS
|
||||
|
||||
GROUPS = CFG['Custom']['remove_group']
|
||||
|
||||
if isinstance(GROUPS, str):
|
||||
GROUPS = GROUPS.split(',')
|
||||
|
||||
if GROUPS == ['']:
|
||||
GROUPS = None
|
||||
|
||||
TORRENT_CLIENTAGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other
|
||||
USELINK = CFG['Torrent']['useLink'] # no | hard | sym
|
||||
OUTPUTDIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/
|
||||
TORRENT_DEFAULTDIR = CFG['Torrent']['default_downloadDirectory']
|
||||
CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software
|
||||
|
||||
def configure_utorrent():
|
||||
global UTORRENT_WEB_UI
|
||||
global UTORRENT_USER
|
||||
global UTORRENT_PASSWORD
|
||||
|
||||
UTORRENT_WEB_UI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/
|
||||
UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr
|
||||
UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr
|
||||
|
||||
|
||||
def configure_transmission():
|
||||
global TRANSMISSION_HOST
|
||||
global TRANSMISSION_PORT
|
||||
global TRANSMISSION_USER
|
||||
global TRANSMISSION_PASSWORD
|
||||
|
||||
TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost
|
||||
TRANSMISSION_PORT = int(CFG['Torrent']['TransmissionPort'])
|
||||
TRANSMISSION_USER = CFG['Torrent']['TransmissionUSR'] # mysecretusr
|
||||
TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr
|
||||
|
||||
|
||||
def configure_deluge():
|
||||
global DELUGE_HOST
|
||||
global DELUGE_PORT
|
||||
global DELUGE_USER
|
||||
global DELUGE_PASSWORD
|
||||
|
||||
DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost
|
||||
DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084
|
||||
DELUGE_USER = CFG['Torrent']['DelugeUSR'] # mysecretusr
|
||||
DELUGE_PASSWORD = CFG['Torrent']['DelugePWD'] # mysecretpwr
|
||||
|
||||
|
||||
def configure_qbittorrent():
|
||||
global QBITTORRENT_HOST
|
||||
global QBITTORRENT_PORT
|
||||
global QBITTORRENT_USER
|
||||
global QBITTORRENT_PASSWORD
|
||||
|
||||
QBITTORRENT_HOST = CFG['Torrent']['qBittorrenHost'] # localhost
|
||||
QBITTORRENT_PORT = int(CFG['Torrent']['qBittorrentPort']) # 8080
|
||||
QBITTORRENT_USER = CFG['Torrent']['qBittorrentUSR'] # mysecretusr
|
||||
QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr
|
||||
|
||||
|
||||
def configure_flattening():
|
||||
global NOFLATTEN
|
||||
|
||||
NOFLATTEN = (CFG['Torrent']['noFlatten'])
|
||||
if isinstance(NOFLATTEN, str):
|
||||
NOFLATTEN = NOFLATTEN.split(',')
|
||||
|
||||
|
||||
def configure_torrent_categories():
|
||||
global CATEGORIES
|
||||
|
||||
CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software
|
||||
if isinstance(CATEGORIES, str):
|
||||
CATEGORIES = CATEGORIES.split(',')
|
||||
DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal'])
|
||||
TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8)
|
||||
|
||||
|
||||
def configure_torrent_resuming():
|
||||
global TORRENT_RESUME
|
||||
global TORRENT_RESUME_ON_FAILURE
|
||||
|
||||
TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure'])
|
||||
TORRENT_RESUME = int(CFG['Torrent']['resume'])
|
||||
UTORRENTWEBUI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/
|
||||
UTORRENTUSR = CFG['Torrent']['uTorrentUSR'] # mysecretusr
|
||||
UTORRENTPWD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr
|
||||
|
||||
TRANSMISSIONHOST = CFG['Torrent']['TransmissionHost'] # localhost
|
||||
TRANSMISSIONPORT = int(CFG['Torrent']['TransmissionPort'])
|
||||
TRANSMISSIONUSR = CFG['Torrent']['TransmissionUSR'] # mysecretusr
|
||||
TRANSMISSIONPWD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr
|
||||
|
||||
DELUGEHOST = CFG['Torrent']['DelugeHost'] # localhost
|
||||
DELUGEPORT = int(CFG['Torrent']['DelugePort']) # 8084
|
||||
DELUGEUSR = CFG['Torrent']['DelugeUSR'] # mysecretusr
|
||||
DELUGEPWD = CFG['Torrent']['DelugePWD'] # mysecretpwr
|
||||
def configure_torrent_permissions():
|
||||
global TORRENT_CHMOD_DIRECTORY
|
||||
|
||||
QBITTORRENTHOST = CFG['Torrent']['qBittorrenHost'] # localhost
|
||||
QBITTORRENTPORT = int(CFG['Torrent']['qBittorrentPort']) # 8080
|
||||
QBITTORRENTUSR = CFG['Torrent']['qBittorrentUSR'] # mysecretusr
|
||||
QBITTORRENTPWD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr
|
||||
TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8)
|
||||
|
||||
REMOTEPATHS = CFG['Network']['mount_points'] or []
|
||||
if REMOTEPATHS:
|
||||
if isinstance(REMOTEPATHS, list):
|
||||
REMOTEPATHS = ','.join(REMOTEPATHS) # fix in case this imported as list.
|
||||
REMOTEPATHS = [tuple(item.split(',')) for item in
|
||||
REMOTEPATHS.split('|')] # /volume1/Public/,E:\|/volume2/share/,\\NAS\
|
||||
REMOTEPATHS = [(local.strip(), remote.strip()) for local, remote in
|
||||
REMOTEPATHS] # strip trailing and leading whitespaces
|
||||
|
||||
PLEXSSL = int(CFG['Plex']['plex_ssl'])
|
||||
PLEXHOST = CFG['Plex']['plex_host']
|
||||
PLEXPORT = CFG['Plex']['plex_port']
|
||||
PLEXTOKEN = CFG['Plex']['plex_token']
|
||||
PLEXSEC = CFG['Plex']['plex_sections'] or []
|
||||
if PLEXSEC:
|
||||
if isinstance(PLEXSEC, list):
|
||||
PLEXSEC = ','.join(PLEXSEC) # fix in case this imported as list.
|
||||
PLEXSEC = [tuple(item.split(',')) for item in PLEXSEC.split('|')]
|
||||
def configure_torrent_deltetion():
|
||||
global DELETE_ORIGINAL
|
||||
|
||||
devnull = open(os.devnull, 'w')
|
||||
try:
|
||||
subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate()
|
||||
NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))])
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate()
|
||||
DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal'])
|
||||
|
||||
|
||||
def configure_torrent_linking():
|
||||
global USE_LINK
|
||||
|
||||
USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym
|
||||
|
||||
|
||||
def configure_torrents():
|
||||
global TORRENT_CLIENT_AGENT
|
||||
global OUTPUT_DIRECTORY
|
||||
global TORRENT_DEFAULT_DIRECTORY
|
||||
|
||||
TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other
|
||||
OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/
|
||||
TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory']
|
||||
configure_torrent_linking()
|
||||
configure_flattening()
|
||||
configure_torrent_deltetion()
|
||||
configure_torrent_categories()
|
||||
configure_torrent_permissions()
|
||||
configure_torrent_resuming()
|
||||
configure_utorrent()
|
||||
configure_transmission()
|
||||
configure_deluge()
|
||||
configure_qbittorrent()
|
||||
|
||||
|
||||
def configure_remote_paths():
|
||||
global REMOTE_PATHS
|
||||
|
||||
REMOTE_PATHS = CFG['Network']['mount_points'] or []
|
||||
|
||||
if REMOTE_PATHS:
|
||||
if isinstance(REMOTE_PATHS, list):
|
||||
REMOTE_PATHS = ','.join(REMOTE_PATHS) # fix in case this imported as list.
|
||||
|
||||
REMOTE_PATHS = (
|
||||
# /volume1/Public/,E:\|/volume2/share/,\\NAS\
|
||||
tuple(item.split(','))
|
||||
for item in REMOTE_PATHS.split('|')
|
||||
)
|
||||
|
||||
REMOTE_PATHS = [
|
||||
# strip trailing and leading whitespaces
|
||||
(local.strip(), remote.strip())
|
||||
for local, remote in REMOTE_PATHS
|
||||
]
|
||||
|
||||
|
||||
def configure_plex():
|
||||
global PLEX_SSL
|
||||
global PLEX_HOST
|
||||
global PLEX_PORT
|
||||
global PLEX_TOKEN
|
||||
global PLEX_SECTION
|
||||
|
||||
PLEX_SSL = int(CFG['Plex']['plex_ssl'])
|
||||
PLEX_HOST = CFG['Plex']['plex_host']
|
||||
PLEX_PORT = CFG['Plex']['plex_port']
|
||||
PLEX_TOKEN = CFG['Plex']['plex_token']
|
||||
PLEX_SECTION = CFG['Plex']['plex_sections'] or []
|
||||
|
||||
if PLEX_SECTION:
|
||||
if isinstance(PLEX_SECTION, list):
|
||||
PLEX_SECTION = ','.join(PLEX_SECTION) # fix in case this imported as list.
|
||||
PLEX_SECTION = [
|
||||
tuple(item.split(','))
|
||||
for item in PLEX_SECTION.split('|')
|
||||
]
|
||||
|
||||
|
||||
def configure_niceness():
|
||||
global NICENESS
|
||||
|
||||
with open(os.devnull, 'w') as devnull:
|
||||
try:
|
||||
NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))])
|
||||
subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate()
|
||||
NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))])
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
if 'ionice' in NICENESS:
|
||||
NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
||||
else:
|
||||
NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
||||
subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate()
|
||||
try:
|
||||
NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))])
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
if 'ionice' in NICENESS:
|
||||
NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
||||
else:
|
||||
NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))])
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
devnull.close()
|
||||
|
||||
COMPRESSEDCONTAINER = [re.compile(r'.r\d{2}$', re.I),
|
||||
re.compile(r'.part\d+.rar$', re.I),
|
||||
re.compile('.rar$', re.I)]
|
||||
COMPRESSEDCONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in CFG['Extensions']['compressedExtensions']]
|
||||
MEDIACONTAINER = CFG['Extensions']['mediaExtensions']
|
||||
AUDIOCONTAINER = CFG['Extensions']['audioExtensions']
|
||||
METACONTAINER = CFG['Extensions']['metaExtensions'] # .nfo,.sub,.srt
|
||||
if isinstance(COMPRESSEDCONTAINER, str):
|
||||
COMPRESSEDCONTAINER = COMPRESSEDCONTAINER.split(',')
|
||||
if isinstance(MEDIACONTAINER, str):
|
||||
MEDIACONTAINER = MEDIACONTAINER.split(',')
|
||||
if isinstance(AUDIOCONTAINER, str):
|
||||
AUDIOCONTAINER = AUDIOCONTAINER.split(',')
|
||||
if isinstance(METACONTAINER, str):
|
||||
METACONTAINER = METACONTAINER.split(',')
|
||||
|
||||
def configure_containers():
|
||||
global COMPRESSED_CONTAINER
|
||||
global MEDIA_CONTAINER
|
||||
global AUDIO_CONTAINER
|
||||
global META_CONTAINER
|
||||
|
||||
COMPRESSED_CONTAINER = [re.compile(r'.r\d{2}$', re.I),
|
||||
re.compile(r'.part\d+.rar$', re.I),
|
||||
re.compile('.rar$', re.I)]
|
||||
COMPRESSED_CONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in
|
||||
CFG['Extensions']['compressedExtensions']]
|
||||
MEDIA_CONTAINER = CFG['Extensions']['mediaExtensions']
|
||||
AUDIO_CONTAINER = CFG['Extensions']['audioExtensions']
|
||||
META_CONTAINER = CFG['Extensions']['metaExtensions'] # .nfo,.sub,.srt
|
||||
|
||||
if isinstance(COMPRESSED_CONTAINER, str):
|
||||
COMPRESSED_CONTAINER = COMPRESSED_CONTAINER.split(',')
|
||||
|
||||
if isinstance(MEDIA_CONTAINER, str):
|
||||
MEDIA_CONTAINER = MEDIA_CONTAINER.split(',')
|
||||
|
||||
if isinstance(AUDIO_CONTAINER, str):
|
||||
AUDIO_CONTAINER = AUDIO_CONTAINER.split(',')
|
||||
|
||||
if isinstance(META_CONTAINER, str):
|
||||
META_CONTAINER = META_CONTAINER.split(',')
|
||||
|
||||
|
||||
def configure_transcoder():
|
||||
global GETSUBS
|
||||
global TRANSCODE
|
||||
global DUPLICATE
|
||||
global CONCAT
|
||||
global IGNOREEXTENSIONS
|
||||
global OUTPUTFASTSTART
|
||||
global GENERALOPTS
|
||||
global OUTPUTQUALITYPERCENT
|
||||
global OUTPUTVIDEOPATH
|
||||
global PROCESSOUTPUT
|
||||
global ALANGUAGE
|
||||
global AINCLUDE
|
||||
global SLANGUAGES
|
||||
global SINCLUDE
|
||||
global SEXTRACT
|
||||
global SEMBED
|
||||
global SUBSDIR
|
||||
global VEXTENSION
|
||||
global VCODEC
|
||||
global VPRESET
|
||||
global VFRAMERATE
|
||||
global VBITRATE
|
||||
global VRESOLUTION
|
||||
global VCRF
|
||||
global VLEVEL
|
||||
global VCODEC_ALLOW
|
||||
global ACODEC
|
||||
global ACODEC_ALLOW
|
||||
global ACHANNELS
|
||||
global ABITRATE
|
||||
global ACODEC2
|
||||
global ACODEC2_ALLOW
|
||||
global ACHANNELS2
|
||||
global ABITRATE2
|
||||
global ACODEC3
|
||||
global ACODEC3_ALLOW
|
||||
global ACHANNELS3
|
||||
global ABITRATE3
|
||||
global SCODEC
|
||||
global BURN
|
||||
global HWACCEL
|
||||
global ALLOWSUBS
|
||||
global DEFAULTS
|
||||
|
||||
GETSUBS = int(CFG['Transcoder']['getSubs'])
|
||||
TRANSCODE = int(CFG['Transcoder']['transcode'])
|
||||
|
@ -763,7 +960,39 @@ def initialize(section=None):
|
|||
extra = [item for item in codec_alias[codec] if item not in ACODEC3_ALLOW]
|
||||
ACODEC3_ALLOW.extend(extra)
|
||||
|
||||
PASSWORDSFILE = CFG['passwords']['PassWordFile']
|
||||
|
||||
def configure_passwords_file():
|
||||
global PASSWORDS_FILE
|
||||
|
||||
PASSWORDS_FILE = CFG['passwords']['PassWordFile']
|
||||
|
||||
|
||||
def configure_torrent_class():
|
||||
global TORRENT_CLASS
|
||||
|
||||
# create torrent class
|
||||
TORRENT_CLASS = create_torrent_class(TORRENT_CLIENT_AGENT)
|
||||
|
||||
|
||||
def configure_sections(section):
|
||||
global SECTIONS
|
||||
global CATEGORIES
|
||||
# check for script-defied section and if None set to allow sections
|
||||
SECTIONS = CFG[
|
||||
tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled())
|
||||
if not section else (section,)
|
||||
]
|
||||
for section, subsections in SECTIONS.items():
|
||||
CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()])
|
||||
CATEGORIES = list(set(CATEGORIES))
|
||||
|
||||
|
||||
def configure_utility_locations():
|
||||
global SHOWEXTRACT
|
||||
global SEVENZIP
|
||||
global FFMPEG
|
||||
global FFPROBE
|
||||
global PAR2CMD
|
||||
|
||||
# Setup FFMPEG, FFPROBE and SEVENZIP locations
|
||||
if platform.system() == 'Windows':
|
||||
|
@ -853,14 +1082,42 @@ def initialize(section=None):
|
|||
logger.warning('Failed to locate ffprobe. Video corruption detection disabled!')
|
||||
logger.warning('Install ffmpeg with x264 support to enable this feature ...')
|
||||
|
||||
# check for script-defied section and if None set to allow sections
|
||||
SECTIONS = CFG[tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) if not section else (section,)]
|
||||
for section, subsections in SECTIONS.items():
|
||||
CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()])
|
||||
CATEGORIES = list(set(CATEGORIES))
|
||||
|
||||
# create torrent class
|
||||
TORRENT_CLASS = create_torrent_class(TORRENT_CLIENTAGENT)
|
||||
def initialize(section=None):
|
||||
global __INITIALIZED__
|
||||
|
||||
# finished initalizing
|
||||
return True
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
|
||||
configure_logging()
|
||||
configure_process()
|
||||
configure_locale()
|
||||
|
||||
# init logging
|
||||
logger.ntm_log_instance.init_logging()
|
||||
|
||||
configure_migration()
|
||||
configure_logging_part_2()
|
||||
|
||||
# initialize the main SB database
|
||||
main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema)
|
||||
|
||||
configure_general()
|
||||
configure_updates()
|
||||
configure_wake_on_lan()
|
||||
configure_nzbs()
|
||||
configure_torrents()
|
||||
configure_remote_paths()
|
||||
configure_plex()
|
||||
configure_niceness()
|
||||
configure_containers()
|
||||
configure_transcoder()
|
||||
configure_passwords_file()
|
||||
configure_utility_locations()
|
||||
configure_sections(section)
|
||||
configure_torrent_class()
|
||||
|
||||
__INITIALIZED__ = True
|
||||
|
||||
# finished initializing
|
||||
return __INITIALIZED__
|
||||
|
|
|
@ -152,7 +152,7 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
|||
if not release and '.cp(tt' not in video and imdbid:
|
||||
video_name, video_ext = os.path.splitext(video)
|
||||
video2 = '{0}.cp({1}){2}'.format(video_name, imdbid, video_ext)
|
||||
if not (client_agent in [core.TORRENT_CLIENTAGENT, 'manual'] and core.USELINK == 'move-sym'):
|
||||
if not (client_agent in [core.TORRENT_CLIENT_AGENT, 'manual'] and core.USE_LINK == 'move-sym'):
|
||||
logger.debug('Renaming: {0} to: {1}'.format(video, video2))
|
||||
os.rename(video, video2)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ def process(section, dir_name, input_name=None, failed=False, client_agent='manu
|
|||
delete_failed = int(cfg.get('delete_failed', 0))
|
||||
nzb_extraction_by = cfg.get('nzbExtractionBy', 'Downloader')
|
||||
process_method = cfg.get('process_method')
|
||||
if client_agent == core.TORRENT_CLIENTAGENT and core.USELINK == 'move-sym':
|
||||
if client_agent == core.TORRENT_CLIENT_AGENT and core.USE_LINK == 'move-sym':
|
||||
process_method = 'symlink'
|
||||
remote_path = int(cfg.get('remote_path', 0))
|
||||
wait_for = int(cfg.get('wait_for', 2))
|
||||
|
|
|
@ -90,8 +90,8 @@ def extract(file_path, output_destination):
|
|||
# Create outputDestination folder
|
||||
core.make_dir(output_destination)
|
||||
|
||||
if core.PASSWORDSFILE and os.path.isfile(os.path.normpath(core.PASSWORDSFILE)):
|
||||
passwords = [line.strip() for line in open(os.path.normpath(core.PASSWORDSFILE))]
|
||||
if core.PASSWORDS_FILE and os.path.isfile(os.path.normpath(core.PASSWORDS_FILE)):
|
||||
passwords = [line.strip() for line in open(os.path.normpath(core.PASSWORDS_FILE))]
|
||||
else:
|
||||
passwords = []
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ def is_video_good(videofile, status):
|
|||
file_name_ext = os.path.basename(videofile)
|
||||
file_name, file_ext = os.path.splitext(file_name_ext)
|
||||
disable = False
|
||||
if file_ext not in core.MEDIACONTAINER or not core.FFPROBE or not core.CHECK_MEDIA or file_ext in ['.iso'] or (status > 0 and core.NOEXTRACTFAILED):
|
||||
if file_ext not in core.MEDIA_CONTAINER or not core.FFPROBE or not core.CHECK_MEDIA or file_ext in ['.iso'] or (status > 0 and core.NOEXTRACTFAILED):
|
||||
disable = True
|
||||
else:
|
||||
test_details, res = get_video_details(core.TEST_FILE)
|
||||
|
|
|
@ -100,13 +100,13 @@ def get_dirs(section, subsection, link='hard'):
|
|||
except Exception as e:
|
||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format(watch_directory, e))
|
||||
|
||||
if core.USELINK == 'move':
|
||||
if core.USE_LINK == 'move':
|
||||
try:
|
||||
output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection)
|
||||
output_directory = os.path.join(core.OUTPUT_DIRECTORY, subsection)
|
||||
if os.path.exists(output_directory):
|
||||
to_return.extend(process_dir(output_directory, link))
|
||||
except Exception as e:
|
||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUTDIRECTORY, e))
|
||||
logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUT_DIRECTORY, e))
|
||||
|
||||
if not to_return:
|
||||
logger.debug('No directories identified in {0}:{1} for post-processing'.format(section, subsection))
|
||||
|
|
|
@ -20,7 +20,7 @@ def move_file(mediafile, path, link):
|
|||
new_path = None
|
||||
file_ext = os.path.splitext(mediafile)[1]
|
||||
try:
|
||||
if file_ext in core.AUDIOCONTAINER:
|
||||
if file_ext in core.AUDIO_CONTAINER:
|
||||
f = beets.mediafile.MediaFile(mediafile)
|
||||
|
||||
# get artist and album info
|
||||
|
@ -29,7 +29,7 @@ def move_file(mediafile, path, link):
|
|||
|
||||
# create new path
|
||||
new_path = os.path.join(path, '{0} - {1}'.format(sanitize_name(artist), sanitize_name(album)))
|
||||
elif file_ext in core.MEDIACONTAINER:
|
||||
elif file_ext in core.MEDIA_CONTAINER:
|
||||
f = guessit.guessit(mediafile)
|
||||
|
||||
# get title
|
||||
|
@ -75,7 +75,7 @@ def is_min_size(input_name, min_size):
|
|||
|
||||
# audio files we need to check directory size not file size
|
||||
input_size = os.path.getsize(input_name)
|
||||
if file_ext in core.AUDIOCONTAINER:
|
||||
if file_ext in core.AUDIO_CONTAINER:
|
||||
try:
|
||||
input_size = get_dir_size(os.path.dirname(input_name))
|
||||
except Exception:
|
||||
|
@ -89,7 +89,7 @@ def is_min_size(input_name, min_size):
|
|||
|
||||
def is_archive_file(filename):
|
||||
"""Check if the filename is allowed for the Archive"""
|
||||
for regext in core.COMPRESSEDCONTAINER:
|
||||
for regext in core.COMPRESSED_CONTAINER:
|
||||
if regext.search(filename):
|
||||
return regext.split(filename)[0]
|
||||
return False
|
||||
|
@ -109,9 +109,9 @@ def is_media_file(mediafile, media=True, audio=True, meta=True, archives=True, o
|
|||
pass
|
||||
|
||||
return any([
|
||||
(media and file_ext.lower() in core.MEDIACONTAINER),
|
||||
(audio and file_ext.lower() in core.AUDIOCONTAINER),
|
||||
(meta and file_ext.lower() in core.METACONTAINER),
|
||||
(media and file_ext.lower() in core.MEDIA_CONTAINER),
|
||||
(audio and file_ext.lower() in core.AUDIO_CONTAINER),
|
||||
(meta and file_ext.lower() in core.META_CONTAINER),
|
||||
(archives and is_archive_file(mediafile)),
|
||||
(other and (file_ext.lower() in otherext or 'all' in otherext)),
|
||||
])
|
||||
|
|
|
@ -101,13 +101,13 @@ def find_download(client_agent, download_id):
|
|||
if torrent['hash'] == download_id:
|
||||
return True
|
||||
if client_agent == 'sabnzbd':
|
||||
if 'http' in core.SABNZBDHOST:
|
||||
base_url = '{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT)
|
||||
if 'http' in core.SABNZBD_HOST:
|
||||
base_url = '{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT)
|
||||
else:
|
||||
base_url = 'http://{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT)
|
||||
base_url = 'http://{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT)
|
||||
url = base_url
|
||||
params = {
|
||||
'apikey': core.SABNZBDAPIKEY,
|
||||
'apikey': core.SABNZBD_APIKEY,
|
||||
'mode': 'get_files',
|
||||
'output': 'json',
|
||||
'value': download_id,
|
||||
|
|
|
@ -8,20 +8,20 @@ def plex_update(category):
|
|||
if core.FAILED:
|
||||
return
|
||||
url = '{scheme}://{host}:{port}/library/sections/'.format(
|
||||
scheme='https' if core.PLEXSSL else 'http',
|
||||
host=core.PLEXHOST,
|
||||
port=core.PLEXPORT,
|
||||
scheme='https' if core.PLEX_SSL else 'http',
|
||||
host=core.PLEX_HOST,
|
||||
port=core.PLEX_PORT,
|
||||
)
|
||||
section = None
|
||||
if not core.PLEXSEC:
|
||||
if not core.PLEX_SECTION:
|
||||
return
|
||||
logger.debug('Attempting to update Plex Library for category {0}.'.format(category), 'PLEX')
|
||||
for item in core.PLEXSEC:
|
||||
for item in core.PLEX_SECTION:
|
||||
if item[0] == category:
|
||||
section = item[1]
|
||||
|
||||
if section:
|
||||
url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEXTOKEN)
|
||||
url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEX_TOKEN)
|
||||
requests.get(url, timeout=(60, 120), verify=False)
|
||||
logger.debug('Plex Library has been refreshed.', 'PLEX')
|
||||
else:
|
||||
|
|
|
@ -10,13 +10,13 @@ def get_nzoid(input_name):
|
|||
nzoid = None
|
||||
slots = []
|
||||
logger.debug('Searching for nzoid from SAbnzbd ...')
|
||||
if 'http' in core.SABNZBDHOST:
|
||||
base_url = '{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT)
|
||||
if 'http' in core.SABNZBD_HOST:
|
||||
base_url = '{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT)
|
||||
else:
|
||||
base_url = 'http://{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT)
|
||||
base_url = 'http://{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT)
|
||||
url = base_url
|
||||
params = {
|
||||
'apikey': core.SABNZBDAPIKEY,
|
||||
'apikey': core.SABNZBD_APIKEY,
|
||||
'mode': 'queue',
|
||||
'output': 'json',
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ def make_dir(path):
|
|||
|
||||
|
||||
def remote_dir(path):
|
||||
if not core.REMOTEPATHS:
|
||||
if not core.REMOTE_PATHS:
|
||||
return path
|
||||
for local, remote in core.REMOTEPATHS:
|
||||
for local, remote in core.REMOTE_PATHS:
|
||||
if local in path:
|
||||
base_dirs = path.replace(local, '').split(os.sep)
|
||||
if '/' in remote:
|
||||
|
|
|
@ -15,35 +15,35 @@ def create_torrent_class(client_agent):
|
|||
|
||||
if client_agent == 'utorrent':
|
||||
try:
|
||||
logger.debug('Connecting to {0}: {1}'.format(client_agent, core.UTORRENTWEBUI))
|
||||
tc = UTorrentClient(core.UTORRENTWEBUI, core.UTORRENTUSR, core.UTORRENTPWD)
|
||||
logger.debug('Connecting to {0}: {1}'.format(client_agent, core.UTORRENT_WEB_UI))
|
||||
tc = UTorrentClient(core.UTORRENT_WEB_UI, core.UTORRENT_USER, core.UTORRENT_PASSWORD)
|
||||
except Exception:
|
||||
logger.error('Failed to connect to uTorrent')
|
||||
|
||||
if client_agent == 'transmission':
|
||||
try:
|
||||
logger.debug('Connecting to {0}: http://{1}:{2}'.format(
|
||||
client_agent, core.TRANSMISSIONHOST, core.TRANSMISSIONPORT))
|
||||
tc = TransmissionClient(core.TRANSMISSIONHOST, core.TRANSMISSIONPORT,
|
||||
core.TRANSMISSIONUSR,
|
||||
core.TRANSMISSIONPWD)
|
||||
client_agent, core.TRANSMISSION_HOST, core.TRANSMISSION_PORT))
|
||||
tc = TransmissionClient(core.TRANSMISSION_HOST, core.TRANSMISSION_PORT,
|
||||
core.TRANSMISSION_USER,
|
||||
core.TRANSMISSION_PASSWORD)
|
||||
except Exception:
|
||||
logger.error('Failed to connect to Transmission')
|
||||
|
||||
if client_agent == 'deluge':
|
||||
try:
|
||||
logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGEHOST, core.DELUGEPORT))
|
||||
logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGE_HOST, core.DELUGE_PORT))
|
||||
tc = DelugeClient()
|
||||
tc.connect(host=core.DELUGEHOST, port=core.DELUGEPORT, username=core.DELUGEUSR,
|
||||
password=core.DELUGEPWD)
|
||||
tc.connect(host=core.DELUGE_HOST, port=core.DELUGE_PORT, username=core.DELUGE_USER,
|
||||
password=core.DELUGE_PASSWORD)
|
||||
except Exception:
|
||||
logger.error('Failed to connect to Deluge')
|
||||
|
||||
if client_agent == 'qbittorrent':
|
||||
try:
|
||||
logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.QBITTORRENTHOST, core.QBITTORRENTPORT))
|
||||
tc = qBittorrentClient('http://{0}:{1}/'.format(core.QBITTORRENTHOST, core.QBITTORRENTPORT))
|
||||
tc.login(core.QBITTORRENTUSR, core.QBITTORRENTPWD)
|
||||
logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.QBITTORRENT_HOST, core.QBITTORRENT_PORT))
|
||||
tc = qBittorrentClient('http://{0}:{1}/'.format(core.QBITTORRENT_HOST, core.QBITTORRENT_PORT))
|
||||
tc.login(core.QBITTORRENT_USER, core.QBITTORRENT_PASSWORD)
|
||||
except Exception:
|
||||
logger.error('Failed to connect to qBittorrent')
|
||||
|
||||
|
@ -85,7 +85,7 @@ def resume_torrent(client_agent, input_hash, input_id, input_name):
|
|||
|
||||
|
||||
def remove_torrent(client_agent, input_hash, input_id, input_name):
|
||||
if core.DELETE_ORIGINAL == 1 or core.USELINK == 'move':
|
||||
if core.DELETE_ORIGINAL == 1 or core.USE_LINK == 'move':
|
||||
logger.debug('Deleting torrent {0} from {1}'.format(input_name, client_agent))
|
||||
try:
|
||||
if client_agent == 'utorrent' and core.TORRENT_CLASS != '':
|
||||
|
|
|
@ -645,7 +645,7 @@ except NameError:
|
|||
|
||||
# post-processing
|
||||
def process(input_directory, input_name=None, status=0, client_agent='manual', download_id=None, input_category=None, failure_link=None):
|
||||
if core.SAFE_MODE and input_directory == core.NZB_DEFAULTDIR:
|
||||
if core.SAFE_MODE and input_directory == core.NZB_DEFAULT_DIRECTORY:
|
||||
logger.error(
|
||||
'The input directory:[{0}] is the Default Download Directory. Please configure category directories to prevent processing of other media.'.format(
|
||||
input_directory))
|
||||
|
@ -657,7 +657,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
|
|||
if not download_id and client_agent == 'sabnzbd':
|
||||
download_id = get_nzoid(input_name)
|
||||
|
||||
if client_agent != 'manual' and not core.DOWNLOADINFO:
|
||||
if client_agent != 'manual' and not core.DOWNLOAD_INFO:
|
||||
logger.debug('Adding NZB download info for directory {0} to database'.format(input_directory))
|
||||
|
||||
my_db = main_db.DBConnection()
|
||||
|
@ -725,7 +725,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
|
|||
extract = int(cfg.get('extract', 0))
|
||||
|
||||
try:
|
||||
if int(cfg.get('remote_path')) and not core.REMOTEPATHS:
|
||||
if int(cfg.get('remote_path')) and not core.REMOTE_PATHS:
|
||||
logger.error('Remote Path is enabled for {0}:{1} but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!'.format(
|
||||
section_name, input_category))
|
||||
return ProcessResult(
|
||||
|
@ -899,13 +899,13 @@ def main(args, section=None):
|
|||
logger.info('Starting manual run for {0}:{1} - Folder: {2}'.format(section, subsection, dir_name))
|
||||
logger.info('Checking database for download info for {0} ...'.format(os.path.basename(dir_name)))
|
||||
|
||||
core.DOWNLOADINFO = get_download_info(os.path.basename(dir_name), 0)
|
||||
if core.DOWNLOADINFO:
|
||||
core.DOWNLOAD_INFO = get_download_info(os.path.basename(dir_name), 0)
|
||||
if core.DOWNLOAD_INFO:
|
||||
logger.info('Found download info for {0}, '
|
||||
'setting variables now ...'.format
|
||||
(os.path.basename(dir_name)))
|
||||
client_agent = text_type(core.DOWNLOADINFO[0].get('client_agent', 'manual'))
|
||||
download_id = text_type(core.DOWNLOADINFO[0].get('input_id', ''))
|
||||
client_agent = text_type(core.DOWNLOAD_INFO[0].get('client_agent', 'manual'))
|
||||
download_id = text_type(core.DOWNLOAD_INFO[0].get('input_id', ''))
|
||||
else:
|
||||
logger.info('Unable to locate download info for {0}, '
|
||||
'continuing to try and process this release ...'.format
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue