mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
Add peppiness
This commit is contained in:
parent
5f54513b75
commit
803aed871d
5 changed files with 28 additions and 20 deletions
|
@ -22,7 +22,8 @@ def char_replace(name_in):
|
|||
if (len(name) != 1) & (Idx < (len(name) - 1)):
|
||||
# Detect UTF-8
|
||||
if ((name[Idx] == 0xC2) | (name[Idx] == 0xC3)) & (
|
||||
(name[Idx + 1] >= 0xA0) & (name[Idx + 1] <= 0xFF)):
|
||||
(name[Idx + 1] >= 0xA0) & (name[Idx + 1] <= 0xFF)
|
||||
):
|
||||
encoding = 'utf-8'
|
||||
break
|
||||
# Detect CP850
|
||||
|
|
|
@ -45,10 +45,10 @@ def move_file(mediafile, path, link):
|
|||
title = os.path.splitext(os.path.basename(mediafile))[0]
|
||||
new_path = os.path.join(path, sanitize_name(title))
|
||||
|
||||
# Removed as encoding of directory no-longer required
|
||||
#try:
|
||||
# # Removed as encoding of directory no-longer required
|
||||
# try:
|
||||
# new_path = new_path.encode(core.SYS_ENCODING)
|
||||
#except Exception:
|
||||
# except Exception:
|
||||
# pass
|
||||
|
||||
# Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe).
|
||||
|
@ -215,8 +215,9 @@ def backup_versioned_file(old_file, version):
|
|||
logger.log('Backup done', logger.DEBUG)
|
||||
break
|
||||
except Exception as error:
|
||||
logger.log('Error while trying to back up {old} to {new} : {msg}'.format
|
||||
(old=old_file, new=new_file, msg=error), logger.WARNING)
|
||||
logger.log(
|
||||
'Error while trying to back up {old} to {new} : {msg}'.format(old=old_file, new=new_file, msg=error), logger.WARNING,
|
||||
)
|
||||
num_tries += 1
|
||||
time.sleep(1)
|
||||
logger.log('Trying again.', logger.DEBUG)
|
||||
|
|
|
@ -61,8 +61,10 @@ def find_imdbid(dir_name, input_name, omdb_api_key):
|
|||
logger.debug(f'Opening URL: {url}')
|
||||
|
||||
try:
|
||||
r = requests.get(url, params={'apikey': omdb_api_key, 'y': year, 't': title},
|
||||
verify=False, timeout=(60, 300))
|
||||
r = requests.get(
|
||||
url, params={'apikey': omdb_api_key, 'y': year, 't': title},
|
||||
verify=False, timeout=(60, 300),
|
||||
)
|
||||
except requests.ConnectionError:
|
||||
logger.error(f'Unable to open URL {url}')
|
||||
return
|
||||
|
@ -111,7 +113,8 @@ def category_search(input_directory, input_name, input_category, root, categorie
|
|||
|
||||
if input_category and os.path.isdir(os.path.join(input_directory, input_category)):
|
||||
logger.info(
|
||||
f'SEARCH: Found category directory {input_category} in input directory directory {input_directory}')
|
||||
f'SEARCH: Found category directory {input_category} in input directory directory {input_directory}',
|
||||
)
|
||||
input_directory = os.path.join(input_directory, input_category)
|
||||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||
if input_name and os.path.isdir(os.path.join(input_directory, input_name)):
|
||||
|
@ -120,8 +123,9 @@ def category_search(input_directory, input_name, input_category, root, categorie
|
|||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||
tordir = True
|
||||
elif input_name and os.path.isdir(os.path.join(input_directory, sanitize_name(input_name))):
|
||||
logger.info('SEARCH: Found torrent directory {} in input directory directory {}'.format(
|
||||
sanitize_name(input_name), input_directory))
|
||||
logger.info(
|
||||
'SEARCH: Found torrent directory {} in input directory directory {}'.format(sanitize_name(input_name), input_directory),
|
||||
)
|
||||
input_directory = os.path.join(input_directory, sanitize_name(input_name))
|
||||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||
tordir = True
|
||||
|
@ -131,8 +135,9 @@ def category_search(input_directory, input_name, input_category, root, categorie
|
|||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||
tordir = True
|
||||
elif input_name and os.path.isfile(os.path.join(input_directory, sanitize_name(input_name))):
|
||||
logger.info('SEARCH: Found torrent file {} in input directory directory {}'.format(
|
||||
sanitize_name(input_name), input_directory))
|
||||
logger.info(
|
||||
'SEARCH: Found torrent file {} in input directory directory {}'.format(sanitize_name(input_name), input_directory,),
|
||||
)
|
||||
input_directory = os.path.join(input_directory, sanitize_name(input_name))
|
||||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||
tordir = True
|
||||
|
|
|
@ -92,12 +92,12 @@ def parse_synods(args):
|
|||
if res['success']:
|
||||
try:
|
||||
tasks = res['data']['tasks']
|
||||
task = [ task for task in tasks if task['id'] == input_id ][0]
|
||||
task = [task for task in tasks if task['id'] == input_id][0]
|
||||
input_id = task['id']
|
||||
input_directory = task['additional']['detail']['destination']
|
||||
except:
|
||||
logger.error('unable to find download details in Synology DS')
|
||||
#Syno paths appear to be relative. Let's test to see if the returned path exists, and if not append to /volume1/
|
||||
# Syno paths appear to be relative. Let's test to see if the returned path exists, and if not append to /volume1/
|
||||
if not os.path.isdir(input_directory):
|
||||
for root in ['/volume1/', '/volume2/', '/volume3/', '/volume4/']:
|
||||
if os.path.isdir(os.path.join(root, input_directory)):
|
||||
|
|
|
@ -97,8 +97,9 @@ def remove_read_only(filename):
|
|||
file_attribute = os.stat(filename)[0]
|
||||
if not file_attribute & stat.S_IWRITE:
|
||||
# File is read-only, so make it writeable
|
||||
logger.debug('Read only mode on file {name}. Attempting to make it writeable'.format
|
||||
(name=filename))
|
||||
logger.debug(
|
||||
'Read only mode on file {name}. Attempting to make it writeable'.format(name=filename),
|
||||
)
|
||||
try:
|
||||
os.chmod(filename, stat.S_IWRITE)
|
||||
except Exception:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue