/pyrekordbox

Inofficial Python package for interacting with the library of Pioneer's Rekordbox DJ software. It supports XML files, ANLZ files, My-Settings files and the Rekordbox v6 master.db database

Primary LanguagePythonMIT LicenseMIT

logo

Tests Codecov Version Python Platform license: MIT style: black

Pyrekordbox is a Python package for interacting with the library and export data of Pioneer's Rekordbox DJ Software. It currently supports the

  • Rekordbox v6 master.db database
  • Rekordbox XML database
  • Analysis files (ANLZ)
  • My-Setting files

Tested Rekordbox versions: 5.8.6 | 6.5.3

Note: This project is not affiliated with Pioneer Corp. or its related companies in any way and has been written independently! Pyrekordbox is licensed under the MIT license.

⚠️ This project is still under heavy development and might contain bugs or have breaking API changes in the future.

🔧 Installation

Pyrekordbox is available on PyPI:

pip install pyrekordbox

Alternatively, it can be installed via GitHub

pip install git+https://github.com/dylanljones/pyrekordbox.git@VERSION

where VERSION is a release, tag or branch name.

Dependencies

Unlocking the new Rekordbox 6 master.db database file requires SQLCipher. Pyrekordbox makes no attempt to download/install SQLCipher, as it is a pure Python package - whereas the SQLCipher/pysqlcipher3 installation is platform-dependent and can not be installed via pip.

Windows

SQLCipher can be used by building the libary against an amalgamation with pysqlcipher3 or by using pre-built DLL's (not recommended). For a detailed instruction, see INSTALLATION.

MacOS

For MacOS follow these steps:

  1. Install Homebrew if you do not have it on your machine.
  2. Install SQLCipher with brew install SQLCipher.
  3. With the python environment you are using to run pyrekordbox active execute the following:
git clone https://github.com/rigglemania/pysqlcipher3
cd pysqlcipher3
C_INCLUDE_PATH=/opt/homebrew/Cellar/sqlcipher/4.5.1/include LIBRARY_PATH=/opt/homebrew/Cellar/sqlcipher/4.5.1/lib python setup.py build
C_INCLUDE_PATH=/opt/homebrew/Cellar/sqlcipher/4.5.1/include LIBRARY_PATH=/opt/homebrew/Cellar/sqlcipher/4.5.1/lib python setup.py install

Make sure the C_INCLUDE and LIBRARY_PATH point to the installed SQLCipher path. It may differ on your machine.

🚀 Quick-Start

Read the full documentation on ReadTheDocs!

Please make sure to back up your Rekordbox collection before making changes with pyrekordbox or developing/testing new features. The backup dialog can be found under "File" > "Library" > "Backup Library"

Configuration

Pyrekordbox looks for installed Rekordbox versions and sets up the configuration automatically. The configuration can be checked by calling:

from pyrekordbox import show_config

show_config()

which, for example, will print

Pioneer:
   app_dir =      C:\Users\user\AppData\Roaming\Pioneer
   install_dir =  C:\Program Files\Pioneer
Rekordbox 5:
   app_dir =      C:\Users\user\AppData\Roaming\Pioneer\rekordbox
   install_dir =  C:\Program Files\Pioneer\rekordbox 5.8.6
   ...

If for some reason the configuration fails the values can be updated by providing the paths to the directory where Pioneer applications are installed (pioneer_install_dir) and to the directory where Pioneer stores the application data (pioneer_app_dir)

from pyrekordbox.config import update_config

update_config(pioneer_install_dir, pioneer_app_dir)

Alternatively the two paths can be specified in a configuration file under the section rekordbox. Supported configuration files are pyproject.toml, setup.cfg, pyrekordbox.toml, pyrekordbox.cfg and pyrekordbox.yaml.

Rekordbox XML

The Rekordbox XML database is used for importing (and exporting) Rekordbox collections including track metadata and playlists. They can also be used to share playlists between two databases.

Pyrekordbox can read and write Rekordbox XML databases.

from pyrekordbox.xml import RekordboxXml

xml = RekordboxXml("database.xml")

track = xml.get_track(0)    # Get track by index (or TrackID)
track_id = track.TrackID    # Access via attribute
name = track["Name"]        # or dictionary syntax

path = "/path/to/file.mp3"
track = xml.add_track(path) # Add new track
track["Name"] = "Title"     # Add attributes to new track
track["TrackID"] = 10       # Types are handled automatically

# Get playlist (folder) by path
pl = xml.get_playlist("Folder", "Sub Playlist")
keys = pl.get_tracks()  # Get keys of tracks in playlist
ktype = pl.key_type     # Key can either be TrackID or Location

# Add tracks and sub-playlists (folders)
pl.add_track(track.TrackID)
pl.add_playlist("Sub Sub Playlist")

Rekordbox ANLZ files

Rekordbox stores analysis information of the tracks in the collection in specific files, which also get exported to decives used by Pioneer professional DJ equipment. The files have names like ANLZ0000 and come with the extensions .DAT, .EXT or .2EX. They include waveforms, beat grids (information about the precise time at which each beat occurs), time indices to allow efficient seeking to specific positions inside variable bit-rate audio streams, and lists of memory cues and loop points.

Pyrekordbox can parse all three analysis files, although not all the information of the tracks can be extracted yet.

from pyrekordbox.anlz import AnlzFile

anlz = AnlzFile.parse_file("ANLZ0000.DAT")
beat_grid = anlz.get("beat_grid")
path_tags = anlz.getall_tags("path")

Changing and creating the Rekordbox analysis files is planned as well, but for that the full structure of the analysis files has to be understood.

Rekordbox My-Settings

Rekordbox stores the user settings in *SETTING.DAT files, which get exported to USB devices. These files are either in the PIONEERdirectory of a USB drive (device exports), but are also present for on local installations of Rekordbox 6. The setting files store the settings found on the "DJ System" > "My Settings" page of the Rekordbox preferences. These include language, LCD brightness, tempo fader range, crossfader curve and other settings for Pioneer professional DJ equipment.

Pyrekordbox supports both parsing and writing My-Setting files.

from pyrekordbox.mysettings import read_mysetting_file

mysett = read_mysetting_file("MYSETTINGS.DAT")
sync = mysett.get("sync")
quant = mysett.get("quantize")

Rekordbox 6 database

Rekordbox 6 now uses a SQLite database for storing the collection content. Unfortunatly, the new master.db SQLite database is encrypted using SQLCipher, which means it can't be used without the encryption key. However, since your data is stored and used locally, the key must be present on the machine running Rekordbox.

Pyrekordbox can unlock the new Rekordbox master.db SQLite database and provides an easy interface for accessing the data stored in it:

from pyrekordbox import Rekordbox6Database

db = Rekordbox6Database()

for content in db.get_content():
    print(content.Title, content.Artist.Name)

playlist = db.get_playlist()[0]
for song in playlist.Songs:
    content = song.Content
    print(content.Title, content.Artist.Name)

Adding new rows to the tables of the database is not supported since it is not yet known how Rekordbox generates the UUID/ID's. Using wrong values for new database entries could corrupt the library. This feature will be added after some testing. Changing existing entries like the title, artist or file path of a track in the database should work as expected.

💡 File formats

A summary of the Rekordbox file formats can be found in the documentation:

💻 Development

If you encounter an issue or want to contribute to pyrekordbox, please feel free to get in touch, open an issue or create a new pull request! A guide for contributing to pyrekordbox and the commit-message style can be found in CONTRIBUTING.

Pyrekordbox is tested on Windows and MacOS, however some features can't be tested in the CI setup since it requires a working Rekordbox installation.

Master Test Codecov Docs
Dev Test Codecov Docs

To Do

  • Improve unit testing.
  • Adding new entries to the Rekordbox 6 master.db database
  • Complete ANLZ file support. This included the following tags:
    • PCOB
    • PCO2
    • PSSI
    • PWV6
    • PWV7
    • PWVC
  • Planned: Add RekordboxAgent client
  • Planned: Add USB export database support (.pdb).
  • Improve Rekordbox 6 master.db database parsing.
  • Add MySettings support.

🔗 Related Projects

  • crate-digger: Java library for fetching and parsing rekordbox exports and track analysis files.
  • rekordcrate: Library for parsing Pioneer Rekordbox device exports
  • supbox: Get the currently playing track from Rekordbox v6 as Audio Hijack Shoutcast/Icecast metadata, display in your OBS video broadcast or export as JSON.

🙏 Thank Yous