Commit graph

21 commits

Author SHA1 Message Date
Шурупов Илья Викторович
6920b634c4 Incremental live Spotify fetch (snapshot/watermark)
The live fetch no longer re-pulls everything each run:
- playlists: re-fetch a playlist's tracks only when its snapshot_id changed
  (new/deleted playlists handled); state in spotify_playlist table.
- liked songs: page newest-first, stop at the newest added_at already seen
  (watermark in ingest_state).
- cover art: download only when the file is missing or the URL changed.

New src/ingest/spotify_fetch.py drives this against the low-level
SpotifyWebAPI client and upserts straight to the DB; fetch uses it when creds
are set (falls back to the cached-JSON ingest otherwise). `fetch --spotify-full`
forces a complete resync. Shared upsert helper extracted into spotify_raw.

Verified with a mocked API: unchanged re-run does 0 playlist-track fetches and
one liked page; a snapshot change re-fetches exactly that playlist.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 09:26:09 +03:00
Шурупов Илья Викторович
ca1ca74244 Incremental Spotify ingest + --no-enrich
- spotify_raw: skip re-ingesting when the cache files are unchanged (signature
  in ingest_state), matching the iTunes/local incremental behaviour — so a
  re-run with no changes touches nothing.
- fetch --no-enrich: skip MusicBrainz enrichment and rely on MBIDs already on
  tracks (e.g. local Picard tags).

Verified on the real library: 1st run ~9s, unchanged re-run ~0.3s with all
three sources skipping; with enrichment off, 1164 Spotify tracks still match
locally by ISRC/MBID from tags.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 02:04:54 +03:00
Шурупов Илья Викторович
03b98d9a1d 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>
2026-06-15 01:46:56 +03:00
Шурупов Илья Викторович
0e64d439c4 DB-backed incremental redesign: find tracks missing locally
Replace the JSON-file pipeline with a SQLite/SQLAlchemy store (Postgres via
DATABASE_URL) and an incremental, ID-based matcher whose goal is "which
Spotify/iTunes tracks am I missing locally".

- src/db: models (Track/MbCache/FileState/IngestState) + engine/session.
- src/ingest: upsert prefetched spotify/itunes/local (work_dir/latest-1) by
  (source, source_id); pulls ISRC from raw Spotify; preserves enrichment.
- src/enrich: MusicBrainz recording-MBID resolver. Resolves via NORMALIZED
  text search (so the same song across sources lands on one MBID + one cached
  lookup), ISRC as exact fallback. Only touches unresolved tracks, caches
  positive AND negative results, rate-limited and resumable.
- src/match: normalization + cross-source matcher with tiers ISRC > MBID >
  normalized text; reports present/missing and the match method.
- main.py: CLI (ingest / enrich / match). Gui.py: missing-tracks viewer.
- README + requirements (SQLAlchemy, musicbrainzngs); ignore *.db.

Incremental everywhere: re-running updates only what changed; enrich continues
where it stopped. Live Spotify/local backends are left intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 01:25:21 +03:00
Шурупов Илья Викторович
83f782d125 Remove hardcoded credentials; read them from the environment
- Env.py now reads SPOTIFY_CLIENT_ID/SPOTIFY_CLIENT_SECRET (and optional
  path overrides) from the environment instead of hardcoding them.
- Add .env.example and ignore .env / .venv.
- Rewrite README with setup, usage and layout (drops the leaked secret).

Note: secrets are also purged from prior history in this push.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 00:39:59 +03:00
Шурупов Илья Викторович
36058c318a spotify: resilient fetching, progress bars, venv launcher
- fetch() uses a retrying session (connection resets, 5xx, 429 Retry-After)
  with backoff, so a transient drop mid-fetch no longer aborts the run.
- tqdm progress bars on all paginated fetches (driven by paging `total`).
- Flow.fetch_spotify(): drop stray `self` from the @staticmethod.
- gui.sh runs the venv's streamlit from the script dir; add requirements.txt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 00:39:59 +03:00
Шурупов Илья Викторович
16b55b0674 spotify: update fetching to current Web API
- OAuth: URL-encode authorize params (scope spaces were unencoded),
  bind loopback redirect server to 127.0.0.1 to match the redirect_uri
  per Spotify's 2025 loopback rules, capture refresh_token.
- Search: URL-encode the query and drop the bogus track=1 param.
- Pagination: follow the paging object's `next` field instead of manual
  offset/total bookkeeping (Spotify's recommended approach).
- Fix invalid `raise "string"` in save_image_from_url.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 00:03:10 +03:00
Шурупов Илья Викторович
9cd2c9189b nice 2026-02-07 15:17:59 +03:00
Шурупов Илья Викторович
b6c59e81ad tmp 2026-02-07 11:24:59 +03:00
Шурупов Илья Викторович
99cd872227 nice 2026-02-07 00:48:46 +03:00
Шурупов Илья Викторович
35905ea942 stable 2026-02-04 21:21:19 +03:00
Шурупов Илья Викторович
5d38a146a1 lyrics fetcher 2026-01-17 14:24:05 +03:00
Шурупов Илья Викторович
9c9ddb7a9e nice stats and stable 2026-01-06 02:34:04 +03:00
Шурупов Илья Викторович
11fb2816e3 stable stat 2026-01-05 17:42:56 +03:00
Шурупов Илья Викторович
b1c96511a3 nice stat generator 2026-01-05 14:53:06 +03:00
Шурупов Илья Викторович
20c7b28ed6 fixes 2026-01-05 01:19:00 +03:00
Шурупов Илья Викторович
5f4bbbaa59 refactor 2 2026-01-04 23:40:41 +03:00
Шурупов Илья Викторович
a620e7a4f5 refactor initial not fully recovered 2026-01-04 19:25:42 +03:00
Шурупов Илья Викторович
892568d668 stable - generate local playlists & add default options 2026-01-04 01:37:47 +03:00
Ilya Shurupov
11e3b06824 stable
need run main fetch command
then run indexer
then LinkerPatternGenerator
then link_pattern command in the main
2026-01-03 19:56:39 +03:00
Ilya Shurupov
04da522b64 Initial commit 2024-07-08 23:14:12 +03:00