mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-27 11:25:08 +00:00
* Add native Music core workflow
* feat(music): add shared music core helpers, album folder template, and UX cleanup
Consolidate duplicated music-service logic into core and extend the native music workflow.
- add core/music/extract.py: shared stateless helpers (first_text, first_number, year/duration/name formatting, classify_release_kind, dedupe_track_options, build_music_from_songs) so services stop carrying their own copies
- add core/music/display.py: shared rich rendering (render_track_panel, render_album_header, render_artwork_preview) with TrackRow / MusicHeaderInfo data holders
- export the new helpers from core/music/__init__.py
- add dedicated `albums` folder template kind (output_template.folder.albums) resolving albums -> songs -> "{artist} - {album} ({year})"; whitelist music template variables (album_artist, track_total, disc_total, release_type, genre, explicit, isrc, upc, label)
- fix song filename crash: config.get_output_template(...) did not exist; use config.output_template.get("songs") with a sane default
- strip emojis from music output (renderer, dl.py music branch) to match unshackle UX; remove dead MusicSongPlan import and music_icon logic
- document the albums folder key in unshackle-example.yaml
- add tests for extract, display, and the folder template
---------
Co-authored-by: MrMovies-Dev <MrMovies-Dev@users.noreply.github.com>
59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
from typing import TYPE_CHECKING, Optional
|
|
|
|
if TYPE_CHECKING:
|
|
from unshackle.core.titles.music import Song
|
|
|
|
|
|
@dataclass
|
|
class MusicTrackOption:
|
|
codec: str
|
|
bit_depth: Optional[int] = None
|
|
sample_rate: Optional[int] = None
|
|
bitrate: Optional[int] = None
|
|
channels: Optional[float] = None
|
|
lossless: bool = False
|
|
hires: bool = False
|
|
atmos: bool = False
|
|
explicit: bool = False
|
|
duration: Optional[int] = None
|
|
quality_label: str = ""
|
|
|
|
|
|
@dataclass
|
|
class MusicSongPlan:
|
|
song: Song
|
|
options: list[MusicTrackOption] = field(default_factory=list)
|
|
selected: Optional[MusicTrackOption] = None
|
|
output_path: Optional[Path] = None
|
|
fallback_used: bool = False
|
|
skip_reason: str = ""
|
|
|
|
|
|
@dataclass
|
|
class MusicDiscPlan:
|
|
disc_number: int
|
|
songs: list[MusicSongPlan] = field(default_factory=list)
|
|
|
|
|
|
@dataclass
|
|
class MusicDownloadPlan:
|
|
kind: str
|
|
title: str
|
|
artist: str
|
|
album_artist: str = ""
|
|
year: Optional[int] = None
|
|
released: str = ""
|
|
genre: str = ""
|
|
label: str = ""
|
|
artwork_url: Optional[str] = None
|
|
total_tracks: Optional[int] = None
|
|
total_discs: Optional[int] = None
|
|
total_duration: Optional[int] = None
|
|
discs: list[MusicDiscPlan] = field(default_factory=list)
|
|
quality_requested: str = "best"
|
|
fallback_mode: str = "next-best"
|