From 9243cff1a926f7acefb96193da3ed8fd3200b9b3 Mon Sep 17 00:00:00 2001 From: Matthias Blankertz Date: Tue, 6 Jan 2026 12:29:14 +0100 Subject: [PATCH] fix: Remove directory based db creation Previously, if no tonberry.db existed on the SD card, the database was initialized with a playlist for each directory containing mp3 files, with the tag serial number matching the directory name. This was used during development before the web UI to edit the playlist db existed. It is no longer necessary, and confusing to the user when unusable playlists are created when albums are preloaded onto the SD card before putting it in the tonberry device. Signed-off-by: Matthias Blankertz --- software/src/main.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/software/src/main.py b/software/src/main.py index 1af8e3c..5384ffc 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -95,15 +95,6 @@ def run(): # Setup MP3 player with SDContext(mosi=hwconfig.SD_DI, miso=hwconfig.SD_DO, sck=hwconfig.SD_SCK, ss=hwconfig.SD_CS, baudrate=hwconfig.SD_CLOCKRATE): - # Temporary hack: build database from folders if no database exists - # Can be removed once playlists can be created via API - try: - _ = os.stat(DB_PATH) - except OSError as ex: - if ex.errno == ENOENT: - print("No playlist DB found, trying to build DB from tag dirs") - builddb() - with BTreeFileManager(DB_PATH) as playlistdb, \ AudioContext(hwconfig.I2S_DIN, hwconfig.I2S_DCLK, hwconfig.I2S_LRCLK) as audioctx: @@ -130,24 +121,6 @@ def run(): asyncio.get_event_loop().run_forever() -def builddb(): - """ - For testing, build a playlist db based on the previous tag directory format. - Can be removed once uploading files / playlist via the web api is possible. - """ - try: - os.unlink(DB_PATH) - except OSError: - pass - with BTreeFileManager(DB_PATH) as db: - for name, type_, _, _ in os.ilistdir(b'/sd'): - if type_ != 0x4000: - continue - fl = [b'/sd/' + name + b'/' + x for x in os.listdir(b'/sd/' + name) if x.endswith(b'.mp3')] - db.createPlaylistForTag(name, fl) - os.sync() - - def error_blink(): while True: if machine.Pin(hwconfig.BUTTONS[0], machine.Pin.IN, machine.Pin.PULL_UP).value() == 0: