[13] #818 fix and metadata_backup fix

pull/847/head
meisnate12 3 years ago
parent 360bafa007
commit ae3b150b68

@ -1 +1 @@
1.16.3-develop12
1.16.3-develop13

@ -527,7 +527,7 @@ Specify where the `repo` attribute's base is when defining `metadata_paths` and
</table>
## Verify SSL
Turn SSl Verification on or off.
Turn SSL Verification on or off.
<table class="dualTable colwidths-auto align-default table">
<tr>

@ -181,7 +181,7 @@ custom_sort_builders = [
"tvdb_list", "imdb_chart", "imdb_list", "stevenlu_popular", "anidb_popular", "tmdb_upcoming", "tmdb_airing_today",
"tmdb_on_the_air", "trakt_list", "trakt_watchlist", "trakt_collection", "trakt_trending", "trakt_popular", "trakt_boxoffice",
"trakt_collected_daily", "trakt_collected_weekly", "trakt_collected_monthly", "trakt_collected_yearly", "trakt_collected_all",
"flixpatrol_url", "flixpatrol_demographics", "flixpatrol_popular", "flixpatrol_top",
"flixpatrol_url", "flixpatrol_demographics", "flixpatrol_popular", "flixpatrol_top", "trakt_recommendations",
"trakt_recommended_personal", "trakt_recommended_daily", "trakt_recommended_weekly", "trakt_recommended_monthly", "trakt_recommended_yearly", "trakt_recommended_all",
"trakt_watched_daily", "trakt_watched_weekly", "trakt_watched_monthly", "trakt_watched_yearly", "trakt_watched_all",
"tautulli_popular", "tautulli_watched", "mdblist_list", "letterboxd_list", "icheckmovies_list",

@ -626,6 +626,7 @@ class MetadataFile(DataFile):
logger.info("")
logger.separator("Running Metadata")
logger.info("")
next_year = datetime.now().year + 1
for mapping_name, meta in self.metadata.items():
methods = {mm.lower(): mm for mm in meta}
@ -687,7 +688,6 @@ class MetadataFile(DataFile):
logger.info("")
year = None
if "year" in methods and not self.library.is_music:
next_year = datetime.now().year + 1
if meta[methods["year"]] is None:
raise Failed("Metadata Error: year attribute is blank")
try:

@ -1137,4 +1137,4 @@ class Plex(Library):
elif isinstance(item, Album):
_recur("tracks")
return map_key, attrs if attrs else None
return map_key, attrs

@ -835,15 +835,30 @@ def library_operations(config, library):
meta = {}
if "metadata" not in meta:
meta["metadata"] = {}
special_names = {}
for mk, mv in meta["metadata"].items():
if "title" in mv:
special_names[mv["title"]] = mk
if "year" in mv:
special_names[f"{mv['title']} ({mv['year']})"] = mk
items = library.get_all(load=True)
titles = [i.title for i in items]
for i, item in enumerate(items, 1):
logger.ghost(f"Processing: {i}/{len(items)} {item.title}")
map_key, attrs = library.get_locked_attributes(item, titles)
if attrs or library.metadata_backup["add_blank_entries"]:
if map_key in special_names:
map_key = special_names[map_key]
og_dict = meta["metadata"][map_key] if map_key in meta["metadata"] and meta["metadata"][map_key] else {}
if attrs or (library.metadata_backup["add_blank_entries"] and not og_dict):
def get_dict(attrs_dict):
return {ak: get_dict(av) if isinstance(av, dict) else av for ak, av in attrs_dict.items()} if isinstance(attrs_dict, dict) else attrs_dict
meta["metadata"][map_key] = get_dict(attrs)
return {ak: get_dict(av) if isinstance(av, dict) else av for ak, av in attrs_dict.items()}
def loop_dict(looping, dest_dict):
if not looping:
return None
for lk, lv in looping:
dest_dict[lk] = loop_dict(lv, dest_dict[lk] if lk in dest_dict and dest_dict[lk] else {}) if isinstance(lv, dict) else lv
return dest_dict
meta["metadata"][map_key] = loop_dict(get_dict(attrs), og_dict)
logger.exorcise()
try:
yaml.round_trip_dump(meta, open(library.metadata_backup["path"], "w", encoding="utf-8"), block_seq_indent=2)

Loading…
Cancel
Save