save missing supports utf-8

This commit is contained in:
meisnate12 2021-10-26 09:39:30 -04:00
parent 13ed5caed3
commit 39c9bfa28d
2 changed files with 10 additions and 12 deletions

View file

@ -1697,14 +1697,13 @@ class CollectionBuilder:
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
continue continue
current_title = str(show.title.encode("ascii", "replace").decode())
if self.check_tmdb_filter(missing_id, False, check_released=self.details["missing_only_released"]): if self.check_tmdb_filter(missing_id, False, check_released=self.details["missing_only_released"]):
missing_shows_with_names.append((current_title, missing_id)) missing_shows_with_names.append((show.title, missing_id))
if self.details["show_missing"] is True: if self.details["show_missing"] is True:
logger.info(f"{self.name} Collection | ? | {current_title} (TVDB: {missing_id})") logger.info(f"{self.name} Collection | ? | {show.title} (TVDB: {missing_id})")
else: else:
if self.details["show_filtered"] is True and self.details["show_missing"] is True: if self.details["show_filtered"] is True and self.details["show_missing"] is True:
logger.info(f"{self.name} Collection | X | {current_title} (TVDb: {missing_id})") logger.info(f"{self.name} Collection | X | {show.title} (TVDb: {missing_id})")
logger.info("") logger.info("")
logger.info(f"{len(missing_shows_with_names)} Show{'s' if len(missing_shows_with_names) > 1 else ''} Missing") logger.info(f"{len(missing_shows_with_names)} Show{'s' if len(missing_shows_with_names) > 1 else ''} Missing")
if len(missing_shows_with_names) > 0: if len(missing_shows_with_names) > 0:
@ -2102,7 +2101,7 @@ class CollectionBuilder:
for missing_id in self.run_again_shows: for missing_id in self.run_again_shows:
if missing_id not in self.library.show_map: if missing_id not in self.library.show_map:
try: try:
title = str(self.config.TVDb.get_series(self.language, missing_id).title.encode("ascii", "replace").decode()) title = self.config.TVDb.get_series(self.language, missing_id).title
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
continue continue

View file

@ -203,17 +203,16 @@ class Library(ABC):
pass pass
def add_missing(self, collection, items, is_movie): def add_missing(self, collection, items, is_movie):
col_name = collection.encode("ascii", "replace").decode() if collection not in self.missing:
if col_name not in self.missing: self.missing[collection] = {}
self.missing[col_name] = {}
section = "Movies Missing (TMDb IDs)" if is_movie else "Shows Missing (TVDb IDs)" section = "Movies Missing (TMDb IDs)" if is_movie else "Shows Missing (TVDb IDs)"
if section not in self.missing[col_name]: if section not in self.missing[collection]:
self.missing[col_name][section] = {} self.missing[collection][section] = {}
for title, item_id in items: for title, item_id in items:
self.missing[col_name][section][int(item_id)] = str(title).encode("ascii", "replace").decode() self.missing[collection][section][int(item_id)] = title
with open(self.missing_path, "w"): pass with open(self.missing_path, "w"): pass
try: try:
yaml.round_trip_dump(self.missing, open(self.missing_path, "w")) yaml.round_trip_dump(self.missing, open(self.missing_path, "w", encoding="utf-8"))
except yaml.scanner.ScannerError as e: except yaml.scanner.ScannerError as e:
util.print_multiline(f"YAML Error: {util.tab_new_lines(e)}", error=True) util.print_multiline(f"YAML Error: {util.tab_new_lines(e)}", error=True)