Skip to content

Commit

Permalink
Raw json leaked into GUI for shows genre
Browse files Browse the repository at this point in the history
  • Loading branch information
gorgarp authored Jan 15, 2025
1 parent 5f8bb16 commit 45d34a6
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,11 +1561,27 @@ def display_item(self, item: Optional[Dict], media_type: str) -> None:
runtime_str = f"{int(runtime) // 60} min" if str(runtime).isdigit() else runtime
year_runtime = ' | '.join(filter(None, [str(year), runtime_str]))
widgets['year_runtime_label'].setText(year_runtime)
genres = item.get('genres', [])

genres = item.get('genres', '')
if isinstance(genres, str):
genres = json.loads(genres) if genres.startswith('[') else genres.split(',')
genres_str = ", ".join(str(genre).strip() for genre in genres if genre)
try:
genres = json.loads(genres)
except json.JSONDecodeError:
genres = [genres]

if isinstance(genres, list):
genre_names = []
for genre in genres:
if isinstance(genre, dict):
name = genre.get('name', '')
if name:
genre_names.append(name)
else:
genre_names.append(str(genre))
genres_str = ", ".join(genre_names)
else:
genres_str = str(genres)

widgets['genres_label'].setText(genres_str)

summary = item.get('summary', 'No summary available')
Expand All @@ -1584,7 +1600,7 @@ def display_item(self, item: Optional[Dict], media_type: str) -> None:
widgets['genres_label'].setText("")
widgets['summary_text'].setPlainText(f"Error loading item: {str(e)}")
self.poster_downloader._set_default_poster(widgets['poster_label'])

def show_next_recommendation(self, media_type):
print(f"\nFetching next recommendation for {media_type}")
try:
Expand Down

0 comments on commit 45d34a6

Please sign in to comment.