feat: Metadata fields (artist, album, comment) with ID3 tag export
Backend:
- Added artist, album, comment columns to clips DB (migration in init_db)
- New update_metadata() function in database.py
- New PATCH /api/clips/{id}/metadata endpoint
- Updated download endpoint to write ID3 tags using mutagen:
* TIT2 (Title) — from clip title
* TPE1 (Artist) — from clip artist
* TALB (Album) — from clip album
* COMM (Comment) — from clip comment
* TBPM (BPM) — from detected BPM
* TKEY (Key) — from detected key
* TIT1 (Content Group) — prompt for reference
- Added mutagen==1.47.0 to requirements.txt
- Creates temporary copy with tags, original file untouched
Frontend:
- Clip interface updated with artist, album, comment fields
- New MetadataField component in DetailPanel:
* Inline editing with click-to-edit
* Input field with lyria-accent border
* Enter to save, Escape to cancel, blur to save
* Pencil icon on hover
* Shows placeholder when empty
- App.tsx: handleUpdateMetadata() function, passed to DetailPanel
- Updates state across clips, currentClip, selectedClip
Architecture KB and Tasks KB updated.
This commit is contained in:
1 parent
e687f7d457
commit
a713488fb7
6 files changed
+238
-10
No files matched your search
@@ -19,6 +19,9 @@ interface Clip {
|
||||
bpm?: number | null
|
||||
key?: string | null
|
||||
prompt_structure?: Record<string, string> | null
|
||||
artist?: string | null
|
||||
album?: string | null
|
||||
comment?: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
@@ -187,6 +190,32 @@ function App() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleUpdateMetadata = async (id: string, artist: string, album: string, comment: string) => {
|
||||
try {
|
||||
const res = await fetch(`/api/clips/${id}/metadata`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ artist, album, comment }),
|
||||
})
|
||||
if (res.ok) {
|
||||
const updated = await res.json()
|
||||
setClips(prev => prev.map(c => c.id === updated.id ? updated : c))
|
||||
if (currentClip?.id === updated.id) {
|
||||
setCurrentClip(updated)
|
||||
}
|
||||
if (selectedClip?.id === updated.id) {
|
||||
setSelectedClip(updated)
|
||||
}
|
||||
} else {
|
||||
const err = await res.json()
|
||||
alert(err.detail || 'Failed to update metadata')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to update metadata:', err)
|
||||
alert('Failed to update metadata')
|
||||
}
|
||||
}
|
||||
|
||||
const handleClearWaveforms = async () => {
|
||||
try {
|
||||
await fetch('/api/admin/clear-waveforms', { method: 'POST' })
|
||||
@@ -275,6 +304,7 @@ function App() {
|
||||
onPlay={handlePlay}
|
||||
onTogglePlay={() => setIsPlaying(!isPlaying)}
|
||||
onGenerateArtwork={handleGenerateArtwork}
|
||||
onUpdateMetadata={handleUpdateMetadata}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in new issue
Block a user