Skip to content

Commit

Permalink
fix: 🐛 fix case where no genres exist. fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
djdembeck committed Oct 4, 2021
1 parent 498bbb3 commit 2a017e9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Contents/Code/__init__.py
Expand Up @@ -38,7 +38,7 @@ def Start():
HTTP.Headers['Accept-Encoding'] = 'gzip'
log.separator(
msg=(
"Audible Audiobooks Agent v" + VERSION_NO
"Audnexus Audiobooks Agent v" + VERSION_NO
),
log_level="info"
)
Expand Down Expand Up @@ -287,7 +287,7 @@ def add_genres(self, helper):
"""
Add genre(s) to Plex genres where available and depending on preference.
"""
if not Prefs['no_overwrite_genre']:
if not Prefs['no_overwrite_genre'] and helper.genres:
if not helper.metadata.genres or helper.force:
helper.metadata.genres.clear()
for genre in helper.genres:
Expand Down Expand Up @@ -447,16 +447,19 @@ def update(self, metadata, media, lang, force):
)

# Setup logging of all data in the array
list_of_tags = ''
if update_helper.genres:
list_of_tags = ', '.join(
(genre['name'] for genre in update_helper.genres)
)
data_to_log = [
{'author': ', '.join(
genre['name'] for genre in update_helper.author
author['name'] for author in update_helper.author
)},
{'date': update_helper.date},
{'genres': ', '.join(
genre['name'] for genre in update_helper.genres
)},
{'genres': list_of_tags},
{'narrator': ', '.join(
genre['name'] for genre in update_helper.narrator
narrator['name'] for narrator in update_helper.narrator
)},
{'rating': update_helper.rating},
{'series': update_helper.series},
Expand Down Expand Up @@ -716,7 +719,7 @@ def add_genres(self, helper):
"""
Add genre(s) to Plex genres where available and depending on preference.
"""
if not Prefs['no_overwrite_genre']:
if not Prefs['no_overwrite_genre'] and helper.genres:
if not helper.metadata.genres or helper.force:
helper.metadata.genres.clear()
for genre in helper.genres:
Expand Down

0 comments on commit 2a017e9

Please sign in to comment.