Add peppiness

This commit is contained in:
Labrys of Knossos 2022-12-09 16:10:57 -05:00
commit 803aed871d
5 changed files with 28 additions and 20 deletions

View file

@ -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

View file

@ -45,7 +45,7 @@ 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:
@ -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)

View file

@ -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

View file

@ -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: