pull/1867/head
meisnate12 10 months ago
parent 35957e48af
commit 32f48aaa3c

@ -1 +1 @@
1.20.0-develop26 1.20.0-develop27

@ -1123,10 +1123,14 @@ class Operations:
if "year" in mv: if "year" in mv:
special_names[f"{mv['title']} ({mv['year']})"] = mk special_names[f"{mv['title']} ({mv['year']})"] = mk
items = self.library.get_all(load=True) items = self.library.get_all(load=True)
titles = [i.title for i in items] titles = []
year_titles = []
for item in items:
titles.append(item.title)
year_titles.append(f"{item.title} ({item.year})")
for i, item in enumerate(items, 1): for i, item in enumerate(items, 1):
logger.ghost(f"Processing: {i}/{len(items)} {item.title}") logger.ghost(f"Processing: {i}/{len(items)} {item.title}")
map_key, attrs = self.library.get_locked_attributes(item, titles) map_key, attrs = self.library.get_locked_attributes(item, titles, year_titles)
if map_key in special_names: if map_key in special_names:
map_key = special_names[map_key] map_key = special_names[map_key]
og_dict = yaml.data["metadata"][map_key] if map_key in yaml.data["metadata"] and yaml.data["metadata"][map_key] and isinstance(yaml.data["metadata"][map_key], dict) else {} og_dict = yaml.data["metadata"][map_key] if map_key in yaml.data["metadata"] and yaml.data["metadata"][map_key] and isinstance(yaml.data["metadata"][map_key], dict) else {}

@ -1494,27 +1494,40 @@ class Plex(Library):
imdb_id = self.get_imdb_from_map(item) imdb_id = self.get_imdb_from_map(item)
return tmdb_id, tvdb_id, imdb_id return tmdb_id, tvdb_id, imdb_id
def get_locked_attributes(self, item, titles=None): def get_locked_attributes(self, item, titles=None, year_titles=None):
item = self.reload(item) item = self.reload(item)
attrs = {} attrs = {}
match_dict = {}
fields = {f.name: f for f in item.fields if f.locked} fields = {f.name: f for f in item.fields if f.locked}
if isinstance(item, (Movie, Show)) and titles and titles.count(item.title) > 1: if isinstance(item, (Movie, Show)) and titles and titles.count(item.title) > 1:
if year_titles.count(f"{item.title} ({item.year})") > 1:
match_dict["title"] = item.title
match_dict["year"] = item.year
if item.editionTitle:
map_key = f"{item.title} ({item.year}) [{item.editionTitle}]"
match_dict["edition"] = item.editionTitle
else:
map_key = f"{item.title} ({item.year})" map_key = f"{item.title} ({item.year})"
attrs["title"] = item.title match_dict["blank_edition"] = True
attrs["year"] = item.year else:
map_key = f"{item.title} ({item.year})"
match_dict["title"] = item.title
match_dict["year"] = item.year
elif isinstance(item, (Season, Episode, Track)) and item.index: elif isinstance(item, (Season, Episode, Track)) and item.index:
map_key = int(item.index) map_key = int(item.index)
else: else:
map_key = item.title map_key = item.title
if "title" in fields: if "title" in fields:
attrs["title"] = item.title
if isinstance(item, (Movie, Show)): if isinstance(item, (Movie, Show)):
tmdb_id, tvdb_id, imdb_id = self.get_ids(item) tmdb_id, tvdb_id, imdb_id = self.get_ids(item)
tmdb_item = self.config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=isinstance(item, Movie)) tmdb_item = self.config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=isinstance(item, Movie))
if tmdb_item: if tmdb_item:
attrs["alt_title"] = tmdb_item.title match_dict["title"] = [item.title, tmdb_item.title]
elif isinstance(item, (Season, Episode, Track)):
attrs["title"] = item.title if match_dict:
attrs["match"] = match_dict
def check_field(plex_key, pmm_key, var_key=None): def check_field(plex_key, pmm_key, var_key=None):
if plex_key in fields and pmm_key not in self.metadata_backup["exclude"]: if plex_key in fields and pmm_key not in self.metadata_backup["exclude"]:
@ -1532,6 +1545,7 @@ class Plex(Library):
attrs[pmm_key] = plex_value attrs[pmm_key] = plex_value
check_field("titleSort", "sort_title") check_field("titleSort", "sort_title")
check_field("editionTitle", "edition")
check_field("originalTitle", "original_artist" if self.is_music else "original_title") check_field("originalTitle", "original_artist" if self.is_music else "original_title")
check_field("originallyAvailableAt", "originally_available") check_field("originallyAvailableAt", "originally_available")
check_field("contentRating", "content_rating") check_field("contentRating", "content_rating")

Loading…
Cancel
Save