feat(schema): implement songpack v1.0 schemas (manifest, tracks, vocals_f0, editable items)

This commit is contained in:
2026-11-02 12:08:36 +01:00
parent a874afe7cd
commit 2a2da717e8
11 changed files with 437 additions and 76 deletions

View File

@ -1,5 +1,7 @@
"""Schema for meta.json."""
from typing import Literal
from pydantic import BaseModel, ConfigDict, Field
from songsplit.schema.base import SongPackageBase
@ -10,9 +12,40 @@ class SourceFileInfo(BaseModel):
model_config = ConfigDict(extra="ignore")
path: str
sha256: str
size_bytes: int
filename: str = ""
path: str = ""
kind: Literal["audio", "video"] = "audio"
sha256: str = ""
size_bytes: int = 0
class AudioRefInfo(BaseModel):
"""Audio reference information for fingerprinting and alignment."""
model_config = ConfigDict(extra="ignore")
duration_sec: float = Field(ge=0.0)
samplerate: int = 44100
pcm_sha256: str = ""
class KeyInfo(BaseModel):
"""Estimated musical key."""
model_config = ConfigDict(extra="ignore")
tonic: str
mode: str = "major"
confidence: float | None = None
class CapoSuggestion(BaseModel):
"""Capo suggestion and chord shape root."""
model_config = ConfigDict(extra="ignore")
capo: int = 0
shapes_in: str | None = None
class ModelInfo(BaseModel):
@ -26,18 +59,29 @@ class ModelInfo(BaseModel):
class MetaDocument(SongPackageBase):
"""Song-Paket metadata document (meta.json)."""
"""Songpack metadata document (meta.json)."""
model_config = ConfigDict(extra="ignore")
title: str | None = None
artist: str | None = None
album: str | None = None
year: int | None = None
language: str | None = None
duration_sec: float = Field(ge=0.0)
source_file: SourceFileInfo
key: str | None = None
duration_sec: float = Field(default=0.0, ge=0.0)
source: SourceFileInfo = Field(default_factory=SourceFileInfo)
audio_ref: AudioRefInfo | None = None
audio_offset_sec: float = 0.0
key: KeyInfo | str | None = None
capo: int | None = None
capo_suggestion: CapoSuggestion | None = None
ultrastar: dict[str, str] = Field(default_factory=dict)
models_used: list[ModelInfo] = Field(default_factory=list)
created_at: str
created_at: str | None = None
stages_done: list[str] = Field(default_factory=list)
stages_failed: dict[str, str] = Field(default_factory=dict)
# Backward compatibility helper
@property
def source_file(self) -> SourceFileInfo:
return self.source