From 23ea98b292b86cb0d358693e7d751653cf61da34 Mon Sep 17 00:00:00 2001 From: djdembeck Date: Sat, 28 Aug 2021 16:58:28 -0500 Subject: [PATCH] Handle special pages with single genre --- Contents/Code/__init__.py | 12 ++++++++++-- Contents/Code/update_tools.py | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index d9ab79e..63aa4c7 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -288,6 +288,12 @@ def update(self, metadata, media, lang, force=False): .replace("

", "\n") ) + # Handle single genre result + if update_helper.genre_child: + genre_string = update_helper.genre_parent + ', ' + update_helper.genre_child + else: + genre_string = update_helper.genre_parent + # Setup logging of all data in the array data_to_log = [ {'date': update_helper.date}, @@ -295,7 +301,7 @@ def update(self, metadata, media, lang, force=False): {'author': update_helper.author}, {'narrator': update_helper.narrator}, {'series': update_helper.series}, - {'genres': update_helper.genre_parent + ', ' + update_helper.genre_child}, + {'genres': genre_string}, {'studio': update_helper.studio}, {'thumb': update_helper.thumb}, {'rating': update_helper.rating}, @@ -699,7 +705,9 @@ def compile_metadata(self, helper): if not Prefs['no_overwrite_genre']: helper.metadata.genres.clear() helper.metadata.genres.add(helper.genre_parent) - helper.metadata.genres.add(helper.genre_child) + # Not all books have 2 genres + if helper.genre_child: + helper.metadata.genres.add(helper.genre_child) self.parse_author_narrator(helper) diff --git a/Contents/Code/update_tools.py b/Contents/Code/update_tools.py index 569849f..3ccbd8f 100644 --- a/Contents/Code/update_tools.py +++ b/Contents/Code/update_tools.py @@ -55,6 +55,12 @@ def re_parse_with_date_published(self, json_data): ) except AttributeError: continue + except IndexError: + log.info( + '"' + self.title + '", ' + "only has one genre" + ) + continue # Writes metadata information to log. def writeInfo(self):