Files
Senko-san 58b98ab5ed
Docker Build & Publish / build (push) Successful in 1m10s
Docker Build & Publish / push (push) Failing after 7s
Docker Build & Publish / Prune old image versions (push) Has been skipped
feat(library): lazy materialization foundation for remote tracks (§Phase1)
Adds nullable storage fields + availability column on tracks, remote
source/source_id identity on albums/artists, TrackRepository.materialize()
and get_or_create_remote() repos — groundwork for on-demand YTM library
(placeholders saved without audio, materialized in-place on first play).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 17:51:43 +03:00

76 lines
2.0 KiB
Python

"""Domain enums used by ORM columns.
Plain ``str``-valued enums, stored as strings (not native PG enums) — adding a
variant is a code change, never a migration (plan §4). Columns map these via
``mapped_column(String(...))`` and persist ``Enum.value``.
"""
import enum
class TrackSource(enum.StrEnum):
"""Which backend imported a track. Drives ``is_replaceable`` (plan §6.6)."""
YOUTUBE = "youtube"
LOCAL = "local"
UPLOAD = "upload"
SOUNDCLOUD = "soundcloud"
BANDCAMP = "bandcamp"
class StoragePolicy(enum.StrEnum):
"""What the system did / must do with the stored format (plan §6.6).
``master_keep`` is inviolable — never auto-optimized.
"""
AS_IS = "as_is"
OPTIMIZED = "optimized"
MASTER_KEEP = "master_keep"
class MetadataStatus(enum.StrEnum):
"""Enrichment state. ``manual`` is never overwritten by auto-enrichment."""
PENDING = "pending"
ENRICHED = "enriched"
FAILED = "failed"
MANUAL = "manual"
class LikeValue(enum.StrEnum):
"""A like event's value. Likes are an append-only log, not a boolean —
current state is the latest event per ``(user, track)`` (plan §4.1)."""
LIKE = "like"
DISLIKE = "dislike"
NEUTRAL = "neutral"
class DownloadStatus(enum.StrEnum):
"""Lifecycle of a download job (plan §6.1)."""
QUEUED = "queued"
DOWNLOADING = "downloading"
ENRICHING = "enriching"
DONE = "done"
FAILED = "failed"
class LyricsStatus(enum.StrEnum):
"""Lyrics fetch outcome. ``not_found`` is cached too (with TTL) so we don't
hammer the provider for tracks that have no lyrics (plan §6.7)."""
FOUND = "found"
NOT_FOUND = "not_found"
PENDING = "pending"
class TrackAvailability(enum.StrEnum):
"""Whether a track's audio is on local storage or still a remote placeholder
(plan: lazy materialization). ``remote`` tracks have ``storage_uri = NULL``
until ``TrackRepository.materialize`` fills it in."""
LOCAL = "local"
REMOTE = "remote"