diff --git a/CLAUDE.md b/CLAUDE.md index 05af4e2..ecf43f8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1475,14 +1475,18 @@ frontend at `http://localhost:5173`. 1. **`traktor-nml-utils` MUST come from GitHub, not PyPI.** PyPI's `3.1.0` is stale and **cannot parse Traktor Pro 4 (NML v20)** files — its strict parser - dies on the v4 `` element inside `CUE_V2`. `requirements.txt` pins the - GitHub `master` (v4.0.0). Do not "simplify" this to a plain PyPI pin. + dies on the v4 `` element inside `CUE_V2`. `requirements.txt` pins a + GitHub commit (v4.0.0). Do not "simplify" this to a plain PyPI pin. **`pyrekordbox` is now the same situation**: PyPI's latest (0.4.4) has no - `devicelib_plus`, which is the OneLibrary (`exportLibrary.db`) reader, so - `requirements.txt` pins the GitHub master. That upgrade renamed `db6` → - `masterdb` and `tables` → `models` and moved `BLOB` out of `db6.database`; - the Rekordbox adapter uses the new names. `db6` still works as a deprecated - alias and is **removed in 0.6.0**. + `onelibrary` module, which is the OneLibrary (`exportLibrary.db`) reader + (`OneLibrary` class; `devicelib_plus` / `DeviceLibraryPlus` before upstream's + rename), nor `masterdb` (formerly `db6`, now removed upstream; `tables` → + `models`, `BLOB` in `masterdb.database`). + **Both GitHub deps are pinned to a COMMIT, never bare master**: the + `devicelib_plus` → `onelibrary` rename reached CI's fresh install while dev + venvs kept the old commit, and a release shipped that could not export or + read OneLibrary while every local test passed. Move a pin on purpose, with + `./run_tests.sh`. **PyAV: open files for reading through `core/pyav.open_input`, never `av.open` directly.** PyAV 18 refuses a file with non-UTF-8 tags unless given `metadata_errors="ignore"`; PyAV 19 removed that keyword. CI installs @@ -1814,7 +1818,7 @@ that number and nothing else — everything derives from it: deliberately NOT in the fixture, since they carry the machine's name and UUIDs; those are generated fresh per export. - **The two Pioneer key blobs are different.** `masterdb`'s key and - `devicelib_plus`'s are not the same string; mixing them up yields a database + `onelibrary`'s are not the same string; mixing them up yields a database Rekordbox cannot open. `adapters/onelibrary/export.py` writes a whole drive (`PIONEER/rekordbox/ exportLibrary.db` from the checked-in DDL, plus ANLZ under `PIONEER/USBANLZ/`, diff --git a/backend/konduktor/adapters/onelibrary/driver.py b/backend/konduktor/adapters/onelibrary/driver.py index 7c81145..87524f5 100644 --- a/backend/konduktor/adapters/onelibrary/driver.py +++ b/backend/konduktor/adapters/onelibrary/driver.py @@ -49,7 +49,7 @@ class OneLibraryDriver: def _has_onelibrary_schema(path: Path) -> bool: try: import sqlcipher3.dbapi2 as sqlcipher - from pyrekordbox.devicelib_plus.database import BLOB + from pyrekordbox.onelibrary.database import BLOB from pyrekordbox.utils import deobfuscate except ImportError: # pragma: no cover — dependency missing return False diff --git a/backend/konduktor/adapters/onelibrary/export.py b/backend/konduktor/adapters/onelibrary/export.py index b9af620..a5ed86f 100644 --- a/backend/konduktor/adapters/onelibrary/export.py +++ b/backend/konduktor/adapters/onelibrary/export.py @@ -121,7 +121,7 @@ class OneLibraryExporter: def write(self, payload: ExportPayload, destination: Path) -> WrittenLibrary: import sqlcipher3.dbapi2 as sqlcipher - from pyrekordbox.devicelib_plus.database import BLOB + from pyrekordbox.onelibrary.database import BLOB from pyrekordbox.utils import deobfuscate root = Path(destination) @@ -428,8 +428,10 @@ class OneLibraryExporter: ) -#: rekordbox's `fileType` codes, as `pyrekordbox.devicelib_plus.FileType` has them. -#: `.stem.m4a` (a Traktor STEM) is an M4A to a Pioneer player. +#: rekordbox's `fileType` codes. `.stem.m4a` (a Traktor STEM) is an M4A to a +#: Pioneer player. `pyrekordbox.onelibrary.FileType` now also lists MP4 = 3 (the +#: `.mp4` container) and ALAC = 6 (an ALAC `.m4a`); neither is measured here, so +#: both still write 4. _FILE_TYPES = {".mp3": 1, ".m4a": 4, ".mp4": 4, ".aac": 4, ".flac": 5, ".wav": 11, ".aif": 12, ".aiff": 12} diff --git a/backend/konduktor/adapters/onelibrary/projection.py b/backend/konduktor/adapters/onelibrary/projection.py index e1b9919..50e2213 100644 --- a/backend/konduktor/adapters/onelibrary/projection.py +++ b/backend/konduktor/adapters/onelibrary/projection.py @@ -1,6 +1,6 @@ """OneLibrary rows -> the generic projection. -The only place a ``devicelib_plus`` ORM object becomes a generic `Track` / +The only place a ``pyrekordbox.onelibrary`` ORM object becomes a generic `Track` / `TrackCues`. Everything above this file sees generic types exclusively. Field conventions are read off a real rekordbox 7 export rather than guessed: diff --git a/backend/konduktor/adapters/onelibrary/store.py b/backend/konduktor/adapters/onelibrary/store.py index e36d7ff..67b2c63 100644 --- a/backend/konduktor/adapters/onelibrary/store.py +++ b/backend/konduktor/adapters/onelibrary/store.py @@ -1,7 +1,7 @@ """The retained native model for a OneLibrary drive. Owns the drive's ``exportLibrary.db`` and the layout around it, and is the only -place a ``pyrekordbox.devicelib_plus`` row or an ANLZ tag is touched. +place a ``pyrekordbox.onelibrary`` row or an ANLZ tag is touched. The database is SQLCipher-encrypted SQLite, like Rekordbox's ``master.db``, but with a **different and universal key**: every OneLibrary drive from every vendor @@ -170,10 +170,10 @@ class OneLibraryStore(ReplaceGridCommands): def _load(self) -> None: """Copy the drive's database into app-data and open the copy.""" try: - from pyrekordbox.devicelib_plus import DeviceLibraryPlus + from pyrekordbox.onelibrary import OneLibrary except ImportError as ex: # pragma: no cover — dependency missing raise LibraryNotSupported( - "Reading OneLibrary drives needs pyrekordbox with devicelib_plus" + "Reading OneLibrary drives needs pyrekordbox with its onelibrary module" ) from ex _clear_stale_work() work = Path(tempfile.mkdtemp(prefix="drive-", dir=_work_root())) @@ -186,7 +186,7 @@ class OneLibraryStore(ReplaceGridCommands): sidecar = self.path.with_name(self.path.name + suffix) if sidecar.is_file() and sidecar.stat().st_size: shutil.copyfile(sidecar, working.with_name(working.name + suffix)) - db = DeviceLibraryPlus(str(working)) + db = OneLibrary(str(working)) except Exception as ex: # noqa: BLE001 — surfaced as a clean 4xx shutil.rmtree(work, ignore_errors=True) raise LibraryNotSupported(f"Could not open OneLibrary database: {ex}") from ex @@ -206,7 +206,7 @@ class OneLibraryStore(ReplaceGridCommands): """Release the working copy and delete it. The drive itself is never held open (see the module docstring); the copy - is, and `DeviceLibraryPlus.close()` only unregisters events, so the + is, and `OneLibrary.close()` only unregisters events, so the session and engine are closed here explicitly. """ db, self._db = self._db, None @@ -316,7 +316,7 @@ class OneLibraryStore(ReplaceGridCommands): image_id = getattr(self.content(track_id), "image_id", None) if not image_id: return None - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models row = self._require_db().query(models.Image).filter_by(image_id=image_id).one_or_none() small = self.layout.resolve(getattr(row, "path", None)) if row is not None else None @@ -456,7 +456,7 @@ class OneLibraryStore(ReplaceGridCommands): """ if not name: return None - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models model = getattr(models, model_name) pk = f"{model.__tablename__}_id" @@ -497,7 +497,7 @@ class OneLibraryStore(ReplaceGridCommands): stick already has. A new key gets rekordbox's own spelling.""" if wheel is None or mode is None: return None - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models from ..rekordbox.projection import parse_key, render_key @@ -567,7 +567,7 @@ class OneLibraryStore(ReplaceGridCommands): # ---- writes: playlists -------------------------------------------------- def _playlist(self, node_id: str): - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models try: pid = int(node_id) @@ -579,14 +579,14 @@ class OneLibraryStore(ReplaceGridCommands): return row def _siblings(self, parent_id: int, *, excluding: int | None = None) -> list: - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models rows = self._require_db().query(models.Playlist).filter_by(playlist_id_parent=parent_id).all() rows = [r for r in rows if r.playlist_id != excluding] return sorted(rows, key=lambda r: (int(r.sequenceNo or 0), int(r.playlist_id))) def _create_node(self, name: str, parent_id: str | None, attribute: int) -> str: - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models name = (name or "").strip() noun = "folder" if attribute == ATTRIBUTE_FOLDER else "playlist" @@ -631,7 +631,7 @@ class OneLibraryStore(ReplaceGridCommands): def delete_playlist(self, node_id: str) -> None: """Delete a playlist, or a folder WITH everything in it, and close the gap its `sequenceNo` leaves among its siblings.""" - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models db = self._require_db() row = self._playlist(node_id) @@ -693,7 +693,7 @@ class OneLibraryStore(ReplaceGridCommands): def set_playlist_entries(self, node_id: str, track_ids: list[str]) -> int: """Replace a playlist's contents, in order, numbered from 1 (measured).""" - from pyrekordbox.devicelib_plus import models + from pyrekordbox.onelibrary import models db = self._require_db() playlist = self._playlist(node_id) @@ -1378,9 +1378,9 @@ class OneLibraryStore(ReplaceGridCommands): return SaveOutcome(summary=summary, snapshot=None, tag_results=tag_results) def _reopen_working(self, work: Path) -> None: - from pyrekordbox.devicelib_plus import DeviceLibraryPlus + from pyrekordbox.onelibrary import OneLibrary - self._db, self._work = DeviceLibraryPlus(str(work / self.path.name)), work + self._db, self._work = OneLibrary(str(work / self.path.name)), work self._content_cache = None self._by_id = None diff --git a/backend/konduktor/adapters/rekordbox/export.py b/backend/konduktor/adapters/rekordbox/export.py index 57e9e1d..129e5f9 100644 --- a/backend/konduktor/adapters/rekordbox/export.py +++ b/backend/konduktor/adapters/rekordbox/export.py @@ -125,7 +125,7 @@ class RekordboxExporter: ) def write(self, payload: ExportPayload, destination: Path) -> WrittenLibrary: - # `masterdb`'s OWN key blob. `devicelib_plus` has a different one — a + # `masterdb`'s OWN key blob. `onelibrary` has a different one — a # OneLibrary drive uses a universal key shared across vendors, and # master.db does not. Mixing them up produces a database Rekordbox # cannot open, and pyrekordbox rejects the wrong one outright. diff --git a/backend/requirements-server.txt b/backend/requirements-server.txt index e546af3..20dda75 100644 --- a/backend/requirements-server.txt +++ b/backend/requirements-server.txt @@ -14,5 +14,5 @@ Pillow>=11 # a Rekordbox add writes the cover's artwork files dulwich>=0.22 # version history, beside the library platformdirs>=4.0 # From GitHub, NOT PyPI — see requirements.txt for why. -traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git -pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git +traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@39a9c15f29d6b0ea2ce61cd7d548501eea38319d +pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git@43137cb91f8297c768d2a8bdce5b27b2225f0a2d diff --git a/backend/requirements.txt b/backend/requirements.txt index f691eb3..c18c19f 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -18,19 +18,22 @@ librosa>=0.11 scikit-learn>=1.5 # Traktor Pro 4 (NML v20) support requires the GitHub master (v4.0.0), # NOT the stale PyPI release (3.1.0), which cannot parse v4 files. -traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git +# +# Both GitHub dependencies are PINNED TO A COMMIT. Unpinned, a fresh install +# (CI's release build) takes whatever master is that day while a dev venv keeps +# what it had: pyrekordbox renamed `devicelib_plus` to `onelibrary` upstream, +# every local test passed, and the released app could not export or read a +# OneLibrary stick. Move a pin deliberately, with ./run_tests.sh. +traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@39a9c15f29d6b0ea2ce61cd7d548501eea38319d # Rekordbox (master.db is SQLCipher-encrypted SQLite + per-track ANLZ analysis # files). Both ship prebuilt Python 3.14 wheels — no Rust/OpenSSL source build. # # FROM GITHUB, NOT PyPI — the same situation as traktor-nml-utils above, and for -# the same kind of reason. PyPI's latest (0.4.4) has no `devicelib_plus`, which -# is the OneLibrary (`exportLibrary.db`) reader the OneLibrary adapter is built -# on; it exists only on master. Do not "simplify" this back to a version pin. -# -# The upgrade also renames `db6` to `masterdb`. `db6` still works as a -# deprecated alias and is removed in 0.6.0, so the Rekordbox adapter keeps -# running as-is — but that rename is the thing to fix before taking 0.6. -pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git +# the same kind of reason. PyPI's latest (0.4.4) has no `onelibrary` module +# (`exportLibrary.db`, which the OneLibrary adapter is built on; it was called +# `devicelib_plus` before the rename) and no `masterdb` (formerly `db6`, now +# removed). Do not "simplify" this back to a version pin. +pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git@43137cb91f8297c768d2a8bdce5b27b2225f0a2d # The stem engine and its weights are downloaded over HTTPS by the sidecar; a # frozen Python on macOS has no system CA bundle of its own. certifi>=2024.7 diff --git a/backend/test_export_pioneer.py b/backend/test_export_pioneer.py index af8649a..dd8796a 100644 --- a/backend/test_export_pioneer.py +++ b/backend/test_export_pioneer.py @@ -504,7 +504,7 @@ print("\n== content.contentLink is what rekordbox writes ==") # row's song-list preview plain blue and put a "?" beside CUE — exactly what # every row of Konduktor's exports showed while it was NULL. import sqlcipher3.dbapi2 as _sq # noqa: E402 -from pyrekordbox.devicelib_plus.database import BLOB as _BLOB # noqa: E402 +from pyrekordbox.onelibrary.database import BLOB as _BLOB # noqa: E402 from pyrekordbox.utils import deobfuscate as _deob # noqa: E402 _con = _sq.connect(str(art_written.library)) diff --git a/backend/test_onelibrary_fidelity.py b/backend/test_onelibrary_fidelity.py index dfb2c99..a8a14a6 100644 --- a/backend/test_onelibrary_fidelity.py +++ b/backend/test_onelibrary_fidelity.py @@ -60,7 +60,7 @@ def dump(db: Path) -> dict: """Every row of every table; keyed by primary key, or by the whole row for the link tables, which have none.""" import sqlcipher3.dbapi2 as sqlcipher - from pyrekordbox.devicelib_plus.database import BLOB + from pyrekordbox.onelibrary.database import BLOB from pyrekordbox.utils import deobfuscate con = sqlcipher.connect(str(db)) diff --git a/backend/test_onelibrary_tracks.py b/backend/test_onelibrary_tracks.py index e5c6c18..f68b217 100644 --- a/backend/test_onelibrary_tracks.py +++ b/backend/test_onelibrary_tracks.py @@ -65,7 +65,7 @@ def fingerprint(root: Path) -> str: def rows(root: Path, sql: str): import sqlcipher3.dbapi2 as sqlcipher - from pyrekordbox.devicelib_plus.database import BLOB + from pyrekordbox.onelibrary.database import BLOB from pyrekordbox.utils import deobfuscate con = sqlcipher.connect(str(root / "PIONEER" / "rekordbox" / "exportLibrary.db"))