[86] Various small fixes

This commit is contained in:
meisnate12 2022-03-03 09:43:00 -05:00
parent fb68189830
commit 25aa052b3f
9 changed files with 33 additions and 22 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 meisnate12
Copyright (c) 2022 meisnate12
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1 +1 @@
1.15.1-develop85
1.15.1-develop86

View file

@ -10,7 +10,7 @@ libraries: # This is called out once within
metadata_path:
- file: config/TVShows.yml
- folder: config/TV Shows/
- git: meisnate12/ShowCharts # Unless otherwise stated, this points to the https://github.com/meisnate12/Plex-Meta-Manager-Configs Repository
- git: meisnate12/ShowCharts # This points to the https://github.com/meisnate12/Plex-Meta-Manager-Configs Repository
Anime:
metadata_path:
- file: config/Anime.yml
@ -19,7 +19,7 @@ libraries: # This is called out once within
- file: config/Music.yml
playlist_files:
- file: config/playlists.yml
- git: meisnate12/Playlists # You can change the custom_repo: setting to amend which GitHub Repository this points to
- git: meisnate12/Playlists
settings:
cache: true
cache_expiration: 60

View file

@ -955,6 +955,8 @@ class CollectionBuilder:
raise Failed(f"{self.Type} Error: {method_name} {search_method} attribute not supported")
elif search_attr == "season":
new_dictionary[search_attr] = util.parse(self.Type, search_attr, search_data, parent=method_name, default=current_season, options=util.seasons)
if new_dictionary[search_attr] == "current":
new_dictionary[search_attr] = current_season
if "year" not in dict_methods:
logger.warning(f"Collection Warning: {method_name} year attribute not found using this year: {default_year} by default")
new_dictionary["year"] = default_year
@ -1070,8 +1072,11 @@ class CollectionBuilder:
elif self.current_time.month in [4, 5, 6]: default_season = "spring"
elif self.current_time.month in [7, 8, 9]: default_season = "summer"
else: default_season = "fall"
season = util.parse(self.Type, "season", dict_data, methods=dict_methods, parent=method_name, default=default_season, options=util.seasons)
if season == "current":
season = default_season
self.builders.append((method_name, {
"season": util.parse(self.Type, "season", dict_data, methods=dict_methods, parent=method_name, default=default_season, options=util.seasons),
"season": season,
"sort_by": util.parse(self.Type, "sort_by", dict_data, methods=dict_methods, parent=method_name, default="members", options=mal.season_sort_options, translation=mal.season_sort_translation),
"year": util.parse(self.Type, "year", dict_data, datatype="int", methods=dict_methods, default=self.current_year, parent=method_name, minimum=1917, maximum=self.current_year + 1),
"limit": util.parse(self.Type, "limit", dict_data, datatype="int", methods=dict_methods, default=100, parent=method_name, maximum=500)
@ -1121,7 +1126,7 @@ class CollectionBuilder:
self.builders.append((method_name, util.parse(self.Type, method_name, method_data, "bool")))
def _mdblist(self, method_name, method_data):
for mdb_dict in self.config.Mdblist.validate_mdblist_lists(method_data):
for mdb_dict in self.config.Mdblist.validate_mdblist_lists(self.Type, method_data):
self.builders.append((method_name, mdb_dict))
def _tautulli(self, method_name, method_data):
@ -2043,7 +2048,6 @@ class CollectionBuilder:
attrs = [attr.tag for attr in getattr(item, filter_actual)]
else:
raise Failed(f"Filter Error: filter: {filter_final} not supported")
if (not list(set(filter_data) & set(attrs)) and modifier == "") \
or (list(set(filter_data) & set(attrs)) and modifier == ".not"):
return False

View file

@ -136,7 +136,7 @@ class ConfigFile:
hooks("collection_changes")
new_config["libraries"][library]["webhooks"]["changes"] = None if not changes else changes if len(changes) > 1 else changes[0]
if "libraries" in new_config: new_config["libraries"] = new_config.pop("libraries")
if "playlists" in new_config: new_config["playlists"] = new_config.pop("playlists")
if "playlist_files" in new_config: new_config["playlist_files"] = new_config.pop("playlist_files")
if "settings" in new_config:
temp = new_config.pop("settings")
if "collection_minimum" in temp:
@ -310,7 +310,7 @@ class ConfigFile:
"custom_repo": check_for_attribute(self.data, "custom_repo", parent="settings", default_is_none=True),
"assets_for_all": check_for_attribute(self.data, "assets_for_all", parent="settings", var_type="bool", default=False, save=False, do_print=False)
}
self.custom_repo = self.general["custom_repo"]
self.custom_repo = self.general["custom_repo"].replace("https://github.com/", "https://raw.githubusercontent.com/") if self.general["custom_repo"] else None
self.session = requests.Session()
if not self.general["verify_ssl"]:

View file

@ -5,7 +5,8 @@ from urllib.parse import urlparse
logger = util.logger
builders = ["mdblist_list"]
list_sorts = ["score", "released", "updated", "imdbrating", "rogerebert", "imdbvotes", "budget", "revenue"]
sort_names = ["score", "released", "imdbrating", "imdbvotes", "imdbpopular", "tmdbpopular", "rogerebert", "budget", "revenue", "added"]
list_sorts = [f"{s}.asc" for s in sort_names] + [f"{s}.desc" for s in sort_names]
base_url = "https://mdblist.com/lists"
api_url = "https://mdblist.com/api/"
@ -109,24 +110,24 @@ class Mdblist:
def get_movie(self, tmdb_id):
return self._request(tmdb_id=tmdb_id, is_movie=True)
def validate_mdblist_lists(self, mdb_lists):
def validate_mdblist_lists(self, error_type, mdb_lists):
valid_lists = []
for mdb_dict in util.get_list(mdb_lists, split=False):
if not isinstance(mdb_dict, dict):
mdb_dict = {"url": mdb_dict}
dict_methods = {dm.lower(): dm for dm in mdb_dict}
if "url" not in dict_methods:
raise Failed(f"Collection Error: mdb_list url attribute not found")
raise Failed(f"{error_type} Error: mdb_list url attribute not found")
elif mdb_dict[dict_methods["url"]] is None:
raise Failed(f"Collection Error: mdb_list url attribute is blank")
raise Failed(f"{error_type} Error: mdb_list url attribute is blank")
else:
mdb_url = mdb_dict[dict_methods["url"]].strip()
if not mdb_url.startswith(base_url):
raise Failed(f"Mdblist Error: {mdb_url} must begin with: {base_url}")
raise Failed(f"{error_type} Error: {mdb_url} must begin with: {base_url}")
list_count = None
if "limit" in dict_methods:
if mdb_dict[dict_methods["limit"]] is None:
logger.warning(f"Collection Warning: mdb_list limit attribute is blank using 0 as default")
logger.warning(f"{error_type} Warning: mdb_list limit attribute is blank using 0 as default")
else:
try:
value = int(str(mdb_dict[dict_methods["limit"]]))
@ -135,15 +136,18 @@ class Mdblist:
except ValueError:
pass
if list_count is None:
logger.warning(f"Collection Warning: mdb_list limit attribute must be an integer 0 or greater using 0 as default")
logger.warning(f"{error_type} Warning: mdb_list limit attribute must be an integer 0 or greater using 0 as default")
if list_count is None:
list_count = 0
sort_by = "score"
sort_by = "score.desc"
if "sort_by" in dict_methods:
if mdb_dict[dict_methods["sort_by"]] is None:
logger.warning(f"Collection Warning: mdb_list sort_by attribute is blank using score as default")
logger.warning(f"{error_type} Warning: mdb_list sort_by attribute is blank using score as default")
elif mdb_dict[dict_methods["sort_by"]].lower() in sort_names:
logger.warning(f"{error_type} Warning: mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} is missing .desc or .asc defaulting to .desc")
sort_by = f"{mdb_dict[dict_methods['sort_by']].lower()}.desc"
elif mdb_dict[dict_methods["sort_by"]].lower() not in list_sorts:
logger.warning(f"Collection Warning: mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} not valid score as default. Options: {', '.join(list_sorts)}")
logger.warning(f"{error_type} Warning: mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} not valid score as default. Options: {', '.join(list_sorts)}")
else:
sort_by = mdb_dict[dict_methods["sort_by"]].lower()
valid_lists.append({"url": mdb_url, "limit": list_count, "sort_by": sort_by})
@ -151,9 +155,10 @@ class Mdblist:
def get_mdblist_ids(self, method, data):
if method == "mdblist_list":
params = {"sort": data["sort_by"]}
logger.info(f"Processing Mdblist.com List: {data['url']}")
logger.info(f"Sort By: {data['sort_by']}")
sort, direction = data["sort_by"].split(".")
params = {"sort": sort, "sortorder": direction}
if data["limit"] > 0:
logger.info(f"Limit: {data['limit']} items")
params["limit"] = data["limit"]

View file

@ -63,7 +63,7 @@ pretty_months = {
1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June",
7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December"
}
seasons = ["winter", "spring", "summer", "fall"]
seasons = ["current", "winter", "spring", "summer", "fall"]
pretty_ids = {"anidbid": "AniDB", "imdbid": "IMDb", "mal_id": "MyAnimeList", "themoviedb_id": "TMDb", "thetvdb_id": "TVDb", "tvdbid": "TVDb"}
collection_mode_options = {
"default": "default", "hide": "hide",

View file

@ -430,12 +430,14 @@ def library_operations(config, library):
if library.update_blank_track_titles:
tracks = library.get_all(collection_level="track")
num_edited = 0
for i, item in enumerate(tracks, 1):
logger.ghost(f"Processing Track: {i}/{len(tracks)} {item.title}")
if not item.title and item.sortTitle:
library.edit_query(item, {"title.locked": 1, "title.value": item.sortTitle})
num_edited += 1
logger.info(f"Track: {item.sortTitle} was updated with sort title")
logger.exorcise()
logger.info(f"{len(tracks)} Tracks Processed; {num_edited} Blank Track Titles Updated")
tmdb_collections = {}
if library.items_library_operation: