Fix duplicate theme insertion when API returns multiple versions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-12 11:31:01 +03:00
parent a7cb8b042e
commit c642d2125c

View File

@@ -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]
if not theme.song_title:
theme.song_title = song_title
if not theme.artist:
theme.artist = artist
if video_url:
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()