Fixed and pinned rekordbox exports

This commit is contained in:
patben8 committed 2026-10-12 19:10:20 +02:00
1 parent 05051e7056
commit 0204a322ff
11 files changed
+52 -43

No files matched your search

+12 -8
View File
@@ -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 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 stale and **cannot parse Traktor Pro 4 (NML v20)** files — its strict parser
dies on the v4 `<GRID>` element inside `CUE_V2`. `requirements.txt` pins the dies on the v4 `<GRID>` element inside `CUE_V2`. `requirements.txt` pins a
GitHub `master` (v4.0.0). Do not "simplify" this to a plain PyPI pin. 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 **`pyrekordbox` is now the same situation**: PyPI's latest (0.4.4) has no
`devicelib_plus`, which is the OneLibrary (`exportLibrary.db`) reader, so `onelibrary` module, which is the OneLibrary (`exportLibrary.db`) reader
`requirements.txt` pins the GitHub master. That upgrade renamed `db6` → (`OneLibrary` class; `devicelib_plus` / `DeviceLibraryPlus` before upstream's
`masterdb` and `tables` → `models` and moved `BLOB` out of `db6.database`; rename), nor `masterdb` (formerly `db6`, now removed upstream; `tables` →
the Rekordbox adapter uses the new names. `db6` still works as a deprecated `models`, `BLOB` in `masterdb.database`).
alias and is **removed in 0.6.0**. **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 **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 `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 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 deliberately NOT in the fixture, since they carry the machine's name and
UUIDs; those are generated fresh per export. UUIDs; those are generated fresh per export.
- **The two Pioneer key blobs are different.** `masterdb`'s key and - **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. Rekordbox cannot open.
`adapters/onelibrary/export.py` writes a whole drive (`PIONEER/rekordbox/ `adapters/onelibrary/export.py` writes a whole drive (`PIONEER/rekordbox/
exportLibrary.db` from the checked-in DDL, plus ANLZ under `PIONEER/USBANLZ/`, exportLibrary.db` from the checked-in DDL, plus ANLZ under `PIONEER/USBANLZ/`,
@@ -49,7 +49,7 @@ class OneLibraryDriver:
def _has_onelibrary_schema(path: Path) -> bool: def _has_onelibrary_schema(path: Path) -> bool:
try: try:
import sqlcipher3.dbapi2 as sqlcipher import sqlcipher3.dbapi2 as sqlcipher
from pyrekordbox.devicelib_plus.database import BLOB from pyrekordbox.onelibrary.database import BLOB
from pyrekordbox.utils import deobfuscate from pyrekordbox.utils import deobfuscate
except ImportError: # pragma: no cover — dependency missing except ImportError: # pragma: no cover — dependency missing
return False return False
@@ -121,7 +121,7 @@ class OneLibraryExporter:
def write(self, payload: ExportPayload, destination: Path) -> WrittenLibrary: def write(self, payload: ExportPayload, destination: Path) -> WrittenLibrary:
import sqlcipher3.dbapi2 as sqlcipher import sqlcipher3.dbapi2 as sqlcipher
from pyrekordbox.devicelib_plus.database import BLOB from pyrekordbox.onelibrary.database import BLOB
from pyrekordbox.utils import deobfuscate from pyrekordbox.utils import deobfuscate
root = Path(destination) root = Path(destination)
@@ -428,8 +428,10 @@ class OneLibraryExporter:
) )
#: rekordbox's `fileType` codes, as `pyrekordbox.devicelib_plus.FileType` has them. #: rekordbox's `fileType` codes. `.stem.m4a` (a Traktor STEM) is an M4A to a
#: `.stem.m4a` (a Traktor STEM) is an M4A to a Pioneer player. #: 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, _FILE_TYPES = {".mp3": 1, ".m4a": 4, ".mp4": 4, ".aac": 4, ".flac": 5, ".wav": 11,
".aif": 12, ".aiff": 12} ".aif": 12, ".aiff": 12}
@@ -1,6 +1,6 @@
"""OneLibrary rows -> the generic projection. """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. `TrackCues`. Everything above this file sees generic types exclusively.
Field conventions are read off a real rekordbox 7 export rather than guessed: Field conventions are read off a real rekordbox 7 export rather than guessed:
+15 -15
View File
@@ -1,7 +1,7 @@
"""The retained native model for a OneLibrary drive. """The retained native model for a OneLibrary drive.
Owns the drive's ``exportLibrary.db`` and the layout around it, and is the only 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 The database is SQLCipher-encrypted SQLite, like Rekordbox's ``master.db``, but
with a **different and universal key**: every OneLibrary drive from every vendor with a **different and universal key**: every OneLibrary drive from every vendor
@@ -170,10 +170,10 @@ class OneLibraryStore(ReplaceGridCommands):
def _load(self) -> None: def _load(self) -> None:
"""Copy the drive's database into app-data and open the copy.""" """Copy the drive's database into app-data and open the copy."""
try: try:
from pyrekordbox.devicelib_plus import DeviceLibraryPlus from pyrekordbox.onelibrary import OneLibrary
except ImportError as ex: # pragma: no cover — dependency missing except ImportError as ex: # pragma: no cover — dependency missing
raise LibraryNotSupported( raise LibraryNotSupported(
"Reading OneLibrary drives needs pyrekordbox with devicelib_plus" "Reading OneLibrary drives needs pyrekordbox with its onelibrary module"
) from ex ) from ex
_clear_stale_work() _clear_stale_work()
work = Path(tempfile.mkdtemp(prefix="drive-", dir=_work_root())) 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) sidecar = self.path.with_name(self.path.name + suffix)
if sidecar.is_file() and sidecar.stat().st_size: if sidecar.is_file() and sidecar.stat().st_size:
shutil.copyfile(sidecar, working.with_name(working.name + suffix)) 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 except Exception as ex: # noqa: BLE001 — surfaced as a clean 4xx
shutil.rmtree(work, ignore_errors=True) shutil.rmtree(work, ignore_errors=True)
raise LibraryNotSupported(f"Could not open OneLibrary database: {ex}") from ex 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. """Release the working copy and delete it.
The drive itself is never held open (see the module docstring); the copy 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. session and engine are closed here explicitly.
""" """
db, self._db = self._db, None db, self._db = self._db, None
@@ -316,7 +316,7 @@ class OneLibraryStore(ReplaceGridCommands):
image_id = getattr(self.content(track_id), "image_id", None) image_id = getattr(self.content(track_id), "image_id", None)
if not image_id: if not image_id:
return None 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() 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 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: if not name:
return None return None
from pyrekordbox.devicelib_plus import models from pyrekordbox.onelibrary import models
model = getattr(models, model_name) model = getattr(models, model_name)
pk = f"{model.__tablename__}_id" pk = f"{model.__tablename__}_id"
@@ -497,7 +497,7 @@ class OneLibraryStore(ReplaceGridCommands):
stick already has. A new key gets rekordbox's own spelling.""" stick already has. A new key gets rekordbox's own spelling."""
if wheel is None or mode is None: if wheel is None or mode is None:
return None return None
from pyrekordbox.devicelib_plus import models from pyrekordbox.onelibrary import models
from ..rekordbox.projection import parse_key, render_key from ..rekordbox.projection import parse_key, render_key
@@ -567,7 +567,7 @@ class OneLibraryStore(ReplaceGridCommands):
# ---- writes: playlists -------------------------------------------------- # ---- writes: playlists --------------------------------------------------
def _playlist(self, node_id: str): def _playlist(self, node_id: str):
from pyrekordbox.devicelib_plus import models from pyrekordbox.onelibrary import models
try: try:
pid = int(node_id) pid = int(node_id)
@@ -579,14 +579,14 @@ class OneLibraryStore(ReplaceGridCommands):
return row return row
def _siblings(self, parent_id: int, *, excluding: int | None = None) -> list: 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 = 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] 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))) 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: 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() name = (name or "").strip()
noun = "folder" if attribute == ATTRIBUTE_FOLDER else "playlist" noun = "folder" if attribute == ATTRIBUTE_FOLDER else "playlist"
@@ -631,7 +631,7 @@ class OneLibraryStore(ReplaceGridCommands):
def delete_playlist(self, node_id: str) -> None: def delete_playlist(self, node_id: str) -> None:
"""Delete a playlist, or a folder WITH everything in it, and close the gap """Delete a playlist, or a folder WITH everything in it, and close the gap
its `sequenceNo` leaves among its siblings.""" its `sequenceNo` leaves among its siblings."""
from pyrekordbox.devicelib_plus import models from pyrekordbox.onelibrary import models
db = self._require_db() db = self._require_db()
row = self._playlist(node_id) 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: def set_playlist_entries(self, node_id: str, track_ids: list[str]) -> int:
"""Replace a playlist's contents, in order, numbered from 1 (measured).""" """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() db = self._require_db()
playlist = self._playlist(node_id) playlist = self._playlist(node_id)
@@ -1378,9 +1378,9 @@ class OneLibraryStore(ReplaceGridCommands):
return SaveOutcome(summary=summary, snapshot=None, tag_results=tag_results) return SaveOutcome(summary=summary, snapshot=None, tag_results=tag_results)
def _reopen_working(self, work: Path) -> None: 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._content_cache = None
self._by_id = None self._by_id = None
@@ -125,7 +125,7 @@ class RekordboxExporter:
) )
def write(self, payload: ExportPayload, destination: Path) -> WrittenLibrary: 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 # OneLibrary drive uses a universal key shared across vendors, and
# master.db does not. Mixing them up produces a database Rekordbox # master.db does not. Mixing them up produces a database Rekordbox
# cannot open, and pyrekordbox rejects the wrong one outright. # cannot open, and pyrekordbox rejects the wrong one outright.
+2 -2
View File
@@ -14,5 +14,5 @@ Pillow>=11 # a Rekordbox add writes the cover's artwork files
dulwich>=0.22 # version history, beside the library dulwich>=0.22 # version history, beside the library
platformdirs>=4.0 platformdirs>=4.0
# From GitHub, NOT PyPI — see requirements.txt for why. # From GitHub, NOT PyPI — see requirements.txt for why.
traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git traktor-nml-utils @ git+https://github.com/MrPatben8/traktor-nml-utils.git@39a9c15f29d6b0ea2ce61cd7d548501eea38319d
pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git@43137cb91f8297c768d2a8bdce5b27b2225f0a2d
+12 -9
View File
@@ -18,19 +18,22 @@ librosa>=0.11
scikit-learn>=1.5 scikit-learn>=1.5
# Traktor Pro 4 (NML v20) support requires the GitHub master (v4.0.0), # 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. # 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 # Rekordbox (master.db is SQLCipher-encrypted SQLite + per-track ANLZ analysis
# files). Both ship prebuilt Python 3.14 wheels — no Rust/OpenSSL source build. # 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 # 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 # the same kind of reason. PyPI's latest (0.4.4) has no `onelibrary` module
# is the OneLibrary (`exportLibrary.db`) reader the OneLibrary adapter is built # (`exportLibrary.db`, which the OneLibrary adapter is built on; it was called
# on; it exists only on master. Do not "simplify" this back to a version pin. # `devicelib_plus` before the rename) and no `masterdb` (formerly `db6`, now
# # removed). Do not "simplify" this back to a version pin.
# The upgrade also renames `db6` to `masterdb`. `db6` still works as a pyrekordbox @ git+https://github.com/dylanljones/pyrekordbox.git@43137cb91f8297c768d2a8bdce5b27b2225f0a2d
# 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 stem engine and its weights are downloaded over HTTPS by the sidecar; a # 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. # frozen Python on macOS has no system CA bundle of its own.
certifi>=2024.7 certifi>=2024.7
+1 -1
View File
@@ -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 # 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. # every row of Konduktor's exports showed while it was NULL.
import sqlcipher3.dbapi2 as _sq # noqa: E402 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 from pyrekordbox.utils import deobfuscate as _deob # noqa: E402
_con = _sq.connect(str(art_written.library)) _con = _sq.connect(str(art_written.library))
+1 -1
View File
@@ -60,7 +60,7 @@ def dump(db: Path) -> dict:
"""Every row of every table; keyed by primary key, or by the whole row for """Every row of every table; keyed by primary key, or by the whole row for
the link tables, which have none.""" the link tables, which have none."""
import sqlcipher3.dbapi2 as sqlcipher import sqlcipher3.dbapi2 as sqlcipher
from pyrekordbox.devicelib_plus.database import BLOB from pyrekordbox.onelibrary.database import BLOB
from pyrekordbox.utils import deobfuscate from pyrekordbox.utils import deobfuscate
con = sqlcipher.connect(str(db)) con = sqlcipher.connect(str(db))
+1 -1
View File
@@ -65,7 +65,7 @@ def fingerprint(root: Path) -> str:
def rows(root: Path, sql: str): def rows(root: Path, sql: str):
import sqlcipher3.dbapi2 as sqlcipher import sqlcipher3.dbapi2 as sqlcipher
from pyrekordbox.devicelib_plus.database import BLOB from pyrekordbox.onelibrary.database import BLOB
from pyrekordbox.utils import deobfuscate from pyrekordbox.utils import deobfuscate
con = sqlcipher.connect(str(root / "PIONEER" / "rekordbox" / "exportLibrary.db")) con = sqlcipher.connect(str(root / "PIONEER" / "rekordbox" / "exportLibrary.db"))