mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
small fixes
This commit is contained in:
parent
da5656a9a8
commit
264361f839
4 changed files with 35 additions and 34 deletions
|
@ -971,7 +971,7 @@ class Config:
|
|||
terms = None
|
||||
for filter_method, filter_data in filters:
|
||||
if filter_method.startswith("original_language"):
|
||||
terms = filter_data if isinstance(filter_data, list) else [lang.strip().lower() for lang in str(filter_data).split(",")]
|
||||
terms = util.get_list(filter_data, lower=True)
|
||||
not_lang = filter_method.endswith(".not")
|
||||
break
|
||||
|
||||
|
@ -1076,33 +1076,34 @@ class Config:
|
|||
|
||||
if library.asset_directory:
|
||||
path = os.path.join(library.asset_directory, "{}".format(name_mapping))
|
||||
dirs = [folder for folder in os.listdir(path) if os.path.isdir(os.path.join(path, folder))]
|
||||
if len(dirs) > 0:
|
||||
for item in plex_collection.items():
|
||||
folder = os.path.basename(os.path.dirname(item.locations[0]))
|
||||
if folder in dirs:
|
||||
files = [file for file in os.listdir(os.path.join(path, folder)) if os.path.isfile(os.path.join(path, folder, file))]
|
||||
poster_path = None
|
||||
background_path = None
|
||||
for file in files:
|
||||
if poster_path is None and file.startswith("poster."):
|
||||
poster_path = os.path.join(path, folder, file)
|
||||
if background_path is None and file.startswith("background."):
|
||||
background_path = os.path.join(path, folder, file)
|
||||
if poster_path:
|
||||
item.uploadPoster(filepath=poster_path)
|
||||
logger.info("Detail: asset_directory updated {}'s poster to [file] {}".format(item.title, poster_path))
|
||||
if background_path:
|
||||
item.uploadArt(filepath=background_path)
|
||||
logger.info("Detail: asset_directory updated {}'s background to [file] {}".format(item.title, background_path))
|
||||
if poster_path is None and background_path is None:
|
||||
logger.warning("No Files Found: {}".format(os.path.join(path, folder)))
|
||||
else:
|
||||
logger.warning("No Folder: {}".format(os.path.join(path, folder)))
|
||||
if os.path.isdir(path):
|
||||
dirs = [folder for folder in os.listdir(path) if os.path.isdir(os.path.join(path, folder))]
|
||||
if len(dirs) > 0:
|
||||
for item in plex_collection.items():
|
||||
folder = os.path.basename(os.path.dirname(item.locations[0]))
|
||||
if folder in dirs:
|
||||
files = [file for file in os.listdir(os.path.join(path, folder)) if os.path.isfile(os.path.join(path, folder, file))]
|
||||
poster_path = None
|
||||
background_path = None
|
||||
for file in files:
|
||||
if poster_path is None and file.startswith("poster."):
|
||||
poster_path = os.path.join(path, folder, file)
|
||||
if background_path is None and file.startswith("background."):
|
||||
background_path = os.path.join(path, folder, file)
|
||||
if poster_path:
|
||||
item.uploadPoster(filepath=poster_path)
|
||||
logger.info("Detail: asset_directory updated {}'s poster to [file] {}".format(item.title, poster_path))
|
||||
if background_path:
|
||||
item.uploadArt(filepath=background_path)
|
||||
logger.info("Detail: asset_directory updated {}'s background to [file] {}".format(item.title, background_path))
|
||||
if poster_path is None and background_path is None:
|
||||
logger.warning("No Files Found: {}".format(os.path.join(path, folder)))
|
||||
else:
|
||||
logger.warning("No Folder: {}".format(os.path.join(path, folder)))
|
||||
except Exception as e:
|
||||
util.print_stacktrace()
|
||||
logger.error("Unknown Error: {}".format(e))
|
||||
if library.show_unmanaged is True:
|
||||
if library.show_unmanaged is True and not test:
|
||||
logger.info("")
|
||||
util.seperator("Unmanaged Collections in {} Library".format(library.name))
|
||||
logger.info("")
|
||||
|
@ -1114,6 +1115,7 @@ class Config:
|
|||
unmanaged_count += 1
|
||||
logger.info("{} Unmanaged Collections".format(unmanaged_count))
|
||||
else:
|
||||
logger.info("")
|
||||
logger.error("No collection to update")
|
||||
|
||||
def map_guids(self, library):
|
||||
|
|
|
@ -187,7 +187,7 @@ class PlexAPI:
|
|||
match = False
|
||||
break
|
||||
elif method == "original_language":
|
||||
terms = f[1] if isinstance(f[1], list) else [lang.lower() for lang in str(f[1]).split(", ")]
|
||||
terms = util.get_list(f[1], lower=True)
|
||||
tmdb_id = None
|
||||
movie = None
|
||||
for key, value in movie_map.items():
|
||||
|
@ -216,7 +216,7 @@ class PlexAPI:
|
|||
match = False
|
||||
break
|
||||
else:
|
||||
terms = f[1] if isinstance(f[1], list) else str(f[1]).split(", ")
|
||||
terms = util.get_list(f[1])
|
||||
if method in ["video_resolution", "audio_language", "subtitle_language"]:
|
||||
for media in current.media:
|
||||
if method == "video_resolution": attrs = [media.videoResolution]
|
||||
|
|
|
@ -10,10 +10,8 @@ def run_tests(default_dir):
|
|||
config = Config(default_dir)
|
||||
logger.info("")
|
||||
util.seperator("Mapping Tests")
|
||||
|
||||
config.map_guids(config.libraries[0])
|
||||
config.map_guids(config.libraries[1])
|
||||
config.map_guids(config.libraries[2])
|
||||
for library in config.libraries:
|
||||
config.map_guids(library)
|
||||
anidb_tests(config)
|
||||
imdb_tests(config)
|
||||
mal_tests(config)
|
||||
|
|
|
@ -254,7 +254,7 @@ collectionless_lists = [
|
|||
other_attributes = [
|
||||
"schedule",
|
||||
"sync_mode",
|
||||
"test",
|
||||
"test",
|
||||
"tmdb_person"
|
||||
]
|
||||
dictionary_lists = [
|
||||
|
@ -481,10 +481,11 @@ def choose_from_list(datalist, description, data=None, list_type="title", exact=
|
|||
else:
|
||||
return None
|
||||
|
||||
def get_list(data):
|
||||
def get_list(data, lower=False):
|
||||
if isinstance(data, list): return data
|
||||
elif isinstance(data, dict): return [data]
|
||||
else: return str(data).split(", ")
|
||||
elif lower is True: return [d.strip().lower() for d in str(data).split(",")]
|
||||
else: return [d.strip() for d in str(data).split(",")]
|
||||
|
||||
def get_int_list(data, id_type):
|
||||
values = get_list(data)
|
||||
|
|
Loading…
Reference in a new issue