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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user