Real backends + fetch/display workflows; config paths
Wire the incremental pipeline to real sources and expose two workflows. Config (Env.py): three explicit paths — LOCAL_LIBRARY_PATH (scan source), ITUNES_XML_PATH (manual export), DATA_DIR (storage root: DB + Spotify cache). Real, incremental ingesters: - local_scan: walks the library, skips files whose mtime/size are unchanged, prunes deleted ones, and reads embedded ISRC + recording MBID from tags (tagged files get real IDs with no network), via tags.py. - itunes_xml: parse the iTunes Library.xml as a plist; skip if mtime unchanged. - spotify_raw: ingest raw Spotify JSON (ISRC from external_ids); live fetch wrapper for when credentials are set. Workflows (src/workflows.py + main.py): - `fetch` — pull + scan + parse + enrich + match, with readable step logs. First run is slow (full scan + MB lookups); later runs only touch changes (verified: ~71s first, ~0.6s second). - `display` — launch the GUI. Also: enrich uses ISRC-first again (local MBIDs now come from tags), fix --enrich-limit 0, quiet musicbrainzngs XML warnings, ignore /data/. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
0e64d439c4
commit
03b98d9a1d
14 changed files with 570 additions and 243 deletions
48
Env.py
48
Env.py
|
|
@ -1,25 +1,39 @@
|
|||
"""Configuration. The three things you point at your own data:
|
||||
|
||||
LOCAL_LIBRARY_PATH folder of audio files to scan
|
||||
ITUNES_XML_PATH iTunes/Music "Library.xml" you exported manually
|
||||
DATA_DIR storage root: the database + cached fetches live here
|
||||
|
||||
Everything can be overridden via environment variables (see .env.example).
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Local config. Paths can be overridden via environment variables.
|
||||
local_library_path = Path(os.environ.get("MUSIC_LIBRARY_PATH", "~/Music")).expanduser()
|
||||
work_dir = Path(os.environ.get("WORK_DIR", "./work_dir/new"))
|
||||
|
||||
# Spotify app credentials. NEVER hardcode these here — set them in the
|
||||
# environment (see .env.example) so they don't end up in version control.
|
||||
# export SPOTIFY_CLIENT_ID=...
|
||||
# export SPOTIFY_CLIENT_SECRET=...
|
||||
def _path(env, default):
|
||||
return Path(os.environ.get(env, default)).expanduser()
|
||||
|
||||
|
||||
# --- where YOUR data is read from / written to -------------------------------
|
||||
# Local music library to scan (tags incl. ISRC/MusicBrainz id are read).
|
||||
local_library_path = _path("LOCAL_LIBRARY_PATH", "~/Music")
|
||||
|
||||
# iTunes / Apple Music library export. In the Music app:
|
||||
# File -> Library -> Export Library… (produces an XML/plist file).
|
||||
itunes_xml_path = _path("ITUNES_XML_PATH", "~/Music/iTunes Library.xml")
|
||||
|
||||
# Storage root — the database and cached Spotify responses go here.
|
||||
data_dir = _path("DATA_DIR", "./data")
|
||||
|
||||
# --- derived storage locations -----------------------------------------------
|
||||
spotify_cache_dir = data_dir / "spotify" # raw Spotify API responses
|
||||
database_url = os.environ.get(
|
||||
"DATABASE_URL", f"sqlite:///{(data_dir / 'musicindexer.db').as_posix()}"
|
||||
)
|
||||
|
||||
# --- Spotify app credentials (only needed for live fetching) -----------------
|
||||
client_id = os.environ.get("SPOTIFY_CLIENT_ID")
|
||||
client_secret = os.environ.get("SPOTIFY_CLIENT_SECRET")
|
||||
|
||||
# Persistent store. Defaults to a local SQLite file; point DATABASE_URL at a
|
||||
# Postgres instance (postgresql+psycopg://user:pass@host/db) to switch with no
|
||||
# code changes.
|
||||
database_url = os.environ.get("DATABASE_URL", "sqlite:///./musicindexer.db")
|
||||
|
||||
# Folder of prefetched JSON used to (re)build the DB without hitting the network.
|
||||
prefetched_dir = Path(os.environ.get("PREFETCHED_DIR", "./work_dir/latest-1"))
|
||||
|
||||
# Contact email sent to MusicBrainz in the User-Agent (be a good API citizen).
|
||||
# Contact string sent to MusicBrainz in the User-Agent.
|
||||
mb_contact = os.environ.get("MB_CONTACT", "music-indexer@example.com")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue