From 6ec5cf4b1b8ffeb17382477f6e2205a40158c112 Mon Sep 17 00:00:00 2001 From: Kagamine Rin Date: Sun, 31 May 2026 11:21:14 -0400 Subject: [PATCH] feat: env-configurable default ID3 tags for artist, album, genre DEFAULT_ID3_ARTIST, DEFAULT_ID3_ALBUM, DEFAULT_ID3_GENRE in .env. Clip-level metadata always takes priority. Env defaults fill in blanks. Current defaults: Kagamine Rin / Kithara Studio / Hardcore Techno. Also updated .env.example with all three new vars (commented out). --- backend/.env.example | 7 ++++++- backend/src/main.py | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/.env.example b/backend/.env.example index e3bcb80..5429564 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -1,3 +1,8 @@ LYRIA_API_KEY=your-api-key-here LYRIA_DEFAULT_MODEL=lyria-3-clip-preview -TZ=America/New_York \ No newline at end of file +TZ=America/New_York + +# Optional: Default ID3 tag values applied on download when track metadata is empty +# DEFAULT_ID3_ARTIST=Kithara Studio +# DEFAULT_ID3_ALBUM=Kithara Studio Collection +# DEFAULT_ID3_GENRE=Hardcore Techno \ No newline at end of file diff --git a/backend/src/main.py b/backend/src/main.py index 7334f47..a08f1c5 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -177,13 +177,15 @@ async def download_clip(clip_id: str): if clip.get("title"): audio.tags["TIT2"] = TIT2(encoding=3, text=clip["title"]) - # Artist - if clip.get("artist"): - audio.tags["TPE1"] = TPE1(encoding=3, text=clip["artist"]) + # Artist (clip field > env default) + artist = clip.get("artist") or os.environ.get("DEFAULT_ID3_ARTIST") + if artist: + audio.tags["TPE1"] = TPE1(encoding=3, text=artist) - # Album - if clip.get("album"): - audio.tags["TALB"] = TALB(encoding=3, text=clip["album"]) + # Album (clip field > env default) + album = clip.get("album") or os.environ.get("DEFAULT_ID3_ALBUM") + if album: + audio.tags["TALB"] = TALB(encoding=3, text=album) # Comment if clip.get("comment"): @@ -197,9 +199,10 @@ async def download_clip(clip_id: str): if clip.get("key"): audio.tags["TKEY"] = TKEY(encoding=3, text=clip["key"]) - # Genre - if clip.get("genre"): - audio.tags["TCON"] = TCON(encoding=3, text=clip["genre"]) + # Genre (clip field > env default) + genre = clip.get("genre") or os.environ.get("DEFAULT_ID3_GENRE") + if genre: + audio.tags["TCON"] = TCON(encoding=3, text=genre) # Album art if clip.get("artwork_filename"):