diff --git a/backend/app/openings_downloader/services/animethemes.py b/backend/app/openings_downloader/services/animethemes.py index 3ec3578..26a9e45 100644 --- a/backend/app/openings_downloader/services/animethemes.py +++ b/backend/app/openings_downloader/services/animethemes.py @@ -205,11 +205,13 @@ class AnimeThemesService: key = (theme_type, sequence) if key in existing_themes: - # Update existing theme + # Update existing theme (skip if already has video_url) theme = existing_themes[key] - theme.song_title = song_title - theme.artist = artist - if video_url: + if not theme.song_title: + theme.song_title = song_title + if not theme.artist: + theme.artist = artist + if video_url and not theme.animethemes_video_url: theme.animethemes_video_url = video_url else: # Create new theme @@ -225,6 +227,8 @@ class AnimeThemesService: if anime.themes is None: anime.themes = [] anime.themes.append(theme) + # Add to existing_themes to avoid duplicates from API + existing_themes[key] = theme await db.commit()