Skip to content

Commit

Permalink
Handle special pages with single genre
Browse files Browse the repository at this point in the history
  • Loading branch information
djdembeck committed Aug 28, 2021
1 parent dcac619 commit 23ea98b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,20 @@ def update(self, metadata, media, lang, force=False):
.replace("</p>", "\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},
{'title': update_helper.title},
{'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},
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions Contents/Code/update_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 23ea98b

Please sign in to comment.