dylanljones / pyrekordbox

Inofficial Python package for interacting with the database and other files (XML, ANLZ, MySettings) of Pioneers Rekordbox DJ software
https://pyrekordbox.readthedocs.io/en/latest/
MIT License
176 stars 22 forks source link

ANLZ file paths don't exist #107

Closed worldveil closed 9 months ago

worldveil commented 9 months ago

Describe the bug I was able to unlock and read the RB6 database. However, upon inspection, the analysis paths returned do not exist.

To Reproduce Steps to reproduce the behavior:

import os
import json

from pyrekordbox import show_config, Rekordbox6Database
from pyrekordbox.anlz import AnlzFile

show_config()

with open('rekordbox.json', 'r') as f:
    secrets = json.load(f)

db = Rekordbox6Database(key=secrets["key"], unlock=True)

analysis_path = None
for content in db.get_content():
    print(f"Analysis file for track: {content.Title} is located at: {content.AnalysisDataPath}")
    analysis_path = content.AnalysisDataPath
    break

# try to find the analysis file
path = os.path.join(db.share_directory, analysis_path.replace('/PIONEER', 'PIONEER'))
anlz = AnlzFile.parse_file(path)

The resulting error is:

Pioneer:
   app_dir =      /Users/me/Library/Application Support/Pioneer
   install_dir =  /Applications
Rekordbox 5:
Rekordbox 6:
   app_dir =      /Users/me/Library/Application Support/Pioneer/rekordbox6
   db_dir =       /Users/me/Library/Pioneer/rekordbox
   db_path =      /Users/me/Library/Pioneer/rekordbox/master.db
   install_dir =  /Applications/rekordbox 6
   version =      6

Analysis file for track: NOISE is located at: /PIONEER/USBANLZ/553/e766b-0928-483a-a2fc-b8a7ef4dfa79/ANLZ0000.DAT
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[15], line 24
     22 # try to find the analysis file
     23 path = os.path.join(db.share_directory, analysis_path.replace('/PIONEER', 'PIONEER'))
---> 24 anlz = AnlzFile.parse_file(path)

File ~/code/keydetection/lib/pyrekordbox/pyrekordbox/anlz/file.py:89, in AnlzFile.parse_file(cls, path)
     86     raise ValueError(f"File type '{ext}' not supported!")
     88 logger.debug(f"Reading file {path.name}")
---> 89 with open(path, "rb") as fh:
     90     data = fh.read()
     92 self = cls.parse(data)

FileNotFoundError: [Errno 2] No such file or directory: '/Users/me/Library/Pioneer/rekordbox/share/PIONEER/USBANLZ/553/e766b-0928-483a-a2fc-b8a7ef4dfa79/ANLZ0000.DAT'

Expected behavior

ls /Users/me/Library/Pioneer/rekordbox/share/PIONEER/USBANLZ/553/e766b-0928-483a-a2fc-b8a7ef4dfa79/ANLZ0000.DAT

should report this is an actual file.

Environment

Perhaps I'm not using the package correctly? But this does seem like an issue. I'd be happy to help track it down if you have any suggestions!

worldveil commented 9 months ago

Ah, after further investigation I found the issue. Not an issue with pyrekordbox! Just rekordbox stale DB entries.