mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -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)):
|
if (len(name) != 1) & (Idx < (len(name) - 1)):
|
||||||
# Detect UTF-8
|
# Detect UTF-8
|
||||||
if ((name[Idx] == 0xC2) | (name[Idx] == 0xC3)) & (
|
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'
|
encoding = 'utf-8'
|
||||||
break
|
break
|
||||||
# Detect CP850
|
# Detect CP850
|
||||||
|
|
|
@ -45,10 +45,10 @@ def move_file(mediafile, path, link):
|
||||||
title = os.path.splitext(os.path.basename(mediafile))[0]
|
title = os.path.splitext(os.path.basename(mediafile))[0]
|
||||||
new_path = os.path.join(path, sanitize_name(title))
|
new_path = os.path.join(path, sanitize_name(title))
|
||||||
|
|
||||||
# Removed as encoding of directory no-longer required
|
# # Removed as encoding of directory no-longer required
|
||||||
#try:
|
# try:
|
||||||
# new_path = new_path.encode(core.SYS_ENCODING)
|
# new_path = new_path.encode(core.SYS_ENCODING)
|
||||||
#except Exception:
|
# except Exception:
|
||||||
# pass
|
# 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).
|
# 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)
|
logger.log('Backup done', logger.DEBUG)
|
||||||
break
|
break
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
logger.log('Error while trying to back up {old} to {new} : {msg}'.format
|
logger.log(
|
||||||
(old=old_file, new=new_file, msg=error), logger.WARNING)
|
'Error while trying to back up {old} to {new} : {msg}'.format(old=old_file, new=new_file, msg=error), logger.WARNING,
|
||||||
|
)
|
||||||
num_tries += 1
|
num_tries += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
logger.log('Trying again.', logger.DEBUG)
|
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}')
|
logger.debug(f'Opening URL: {url}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, params={'apikey': omdb_api_key, 'y': year, 't': title},
|
r = requests.get(
|
||||||
verify=False, timeout=(60, 300))
|
url, params={'apikey': omdb_api_key, 'y': year, 't': title},
|
||||||
|
verify=False, timeout=(60, 300),
|
||||||
|
)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
logger.error(f'Unable to open URL {url}')
|
logger.error(f'Unable to open URL {url}')
|
||||||
return
|
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)):
|
if input_category and os.path.isdir(os.path.join(input_directory, input_category)):
|
||||||
logger.info(
|
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)
|
input_directory = os.path.join(input_directory, input_category)
|
||||||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||||
if input_name and os.path.isdir(os.path.join(input_directory, input_name)):
|
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}')
|
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||||
tordir = True
|
tordir = True
|
||||||
elif input_name and os.path.isdir(os.path.join(input_directory, sanitize_name(input_name))):
|
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(
|
logger.info(
|
||||||
sanitize_name(input_name), input_directory))
|
'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))
|
input_directory = os.path.join(input_directory, sanitize_name(input_name))
|
||||||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||||
tordir = True
|
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}')
|
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||||
tordir = True
|
tordir = True
|
||||||
elif input_name and os.path.isfile(os.path.join(input_directory, sanitize_name(input_name))):
|
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(
|
logger.info(
|
||||||
sanitize_name(input_name), input_directory))
|
'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))
|
input_directory = os.path.join(input_directory, sanitize_name(input_name))
|
||||||
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
logger.info(f'SEARCH: Setting input_directory to {input_directory}')
|
||||||
tordir = True
|
tordir = True
|
||||||
|
|
|
@ -92,12 +92,12 @@ def parse_synods(args):
|
||||||
if res['success']:
|
if res['success']:
|
||||||
try:
|
try:
|
||||||
tasks = res['data']['tasks']
|
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_id = task['id']
|
||||||
input_directory = task['additional']['detail']['destination']
|
input_directory = task['additional']['detail']['destination']
|
||||||
except:
|
except:
|
||||||
logger.error('unable to find download details in Synology DS')
|
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):
|
if not os.path.isdir(input_directory):
|
||||||
for root in ['/volume1/', '/volume2/', '/volume3/', '/volume4/']:
|
for root in ['/volume1/', '/volume2/', '/volume3/', '/volume4/']:
|
||||||
if os.path.isdir(os.path.join(root, input_directory)):
|
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]
|
file_attribute = os.stat(filename)[0]
|
||||||
if not file_attribute & stat.S_IWRITE:
|
if not file_attribute & stat.S_IWRITE:
|
||||||
# File is read-only, so make it writeable
|
# File is read-only, so make it writeable
|
||||||
logger.debug('Read only mode on file {name}. Attempting to make it writeable'.format
|
logger.debug(
|
||||||
(name=filename))
|
'Read only mode on file {name}. Attempting to make it writeable'.format(name=filename),
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
os.chmod(filename, stat.S_IWRITE)
|
os.chmod(filename, stat.S_IWRITE)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue