This commit is contained in:
Nathan Rashleigh committed 2026-06-08 23:22:16 +10:00
1 parent 6a6553077b
commit f71a2a3512
23 files changed
+7773 -68

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
"""Build a maple export.pdb from the SAME tracks as the real rekordbox AceMo
export, so the two can be diffed and the maple pdb tested on a player against
the audio/USBANLZ already on the USB.
Reads metadata out of data/acemo/PIONEER/rekordbox/export.pdb (the real export)
and reconstructs an identical-content maple Database, then writes
captures/maple_acemo.pdb.
"""
import sys
from io import BytesIO
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))
from kaitaistruct import KaitaiStream
from kaitai.rekordbox_pdb import RekordboxPdb
from maple.model import Album, Artist, Artwork, Database, Key, Track
from maple.pdb.writer import write_pdb
REAL = ROOT / "data/acemo/PIONEER/rekordbox/export.pdb"
OUT = ROOT / "captures/maple_acemo.pdb"
PT = {t.value: t.name for t in RekordboxPdb.PageType}
def _rows(tbl):
out, ref = [], tbl.first_page
while True:
pg = ref.body
if pg.is_data_page:
for rg in pg.row_groups:
for r in rg.rows:
if r.present:
out.append(r.body)
if ref.index == tbl.last_page.index:
break
ref = pg.next_page
return out
def _txt(v):
try:
return v.body.text
except Exception:
return ""
def main():
pdb = RekordboxPdb(is_ext=False, _io=KaitaiStream(BytesIO(REAL.read_bytes())))
by = {PT.get(t.type.value): _rows(t) for t in pdb.tables}
db = Database()
for a in by.get("artists", []):
db.artists.append(Artist(id=a.id, name=_txt(a.name)))
for a in by.get("albums", []):
db.albums.append(Album(id=a.id, name=_txt(a.name), artist_id=a.artist_id))
for k in by.get("keys", []):
db.keys.append(Key(id=k.id, name=_txt(k.name), id2=k.id2))
for a in by.get("artwork", []):
db.artwork.append(Artwork(id=a.id, path=_txt(a.path)))
for t in by.get("tracks", []):
db.tracks.append(Track(
id=t.id, title=_txt(t.title), artist_id=t.artist_id, album_id=t.album_id,
filename=_txt(t.filename), file_path=_txt(t.file_path), file_size=t.file_size,
sample_rate=t.sample_rate, sample_depth=t.sample_depth, bitrate=t.bitrate,
duration=t.duration, track_number=t.track_number, year=t.year,
disc_number=t.disc_number, tempo=t.tempo, comment=_txt(t.comment),
date_added=_txt(t.date_added), release_date=_txt(t.release_date),
mix_name=_txt(t.mix_name), analyze_path=_txt(t.analyze_path),
analyze_date=_txt(t.analyze_date), artwork_id=t.artwork_id, genre_id=t.genre_id))
write_pdb(db, OUT)
sz = OUT.stat().st_size
print(f"wrote {OUT} ({sz} bytes, page-mult={sz % 4096 == 0}) "
f"tracks={len(db.tracks)} artists={len(db.artists)} albums={len(db.albums)} "
f"keys={len(db.keys)} artwork={len(db.artwork)}")
if __name__ == "__main__":
main()