Add playlist database based on the micropython 'btree' module. Supported features are: * Create playlist * Load playlist * Store position in playlist Different playlist modes will be added in a followup for #24. Implements #23. The playlist data is stored in the btree database in a hierarchical schema. The hierarchy levels are separated by the '/' character. Currently, the schema is as follows: The top level for a playlist is the 'tag' id encoded as a hexadecimal string. Beneath this, the 'playlist' key contains the elements in the playlist. The exact keys used for the playlist entries are not specified, they are enumerated in native sort order to build the playlist. When writing a playlist using the playlistdb module, the keys are 000, 001, etc. by default. The 'playlistpos' key is also located under the 'tag' key and stores the key of the current playlist entry. For example, a playlist with two entries 'a.mp3' and 'b.mp3' for a tag with the id '00aa11bb22' would be stored in the following key/value pairs in the btree db: - 00aa11bb22/playlist/000: a.mp3 - 00aa11bb22/playlist/001: b.mp3 - 00aa11bb22/playlistpos: 000 Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
22 lines
523 B
Python
22 lines
523 B
Python
# SPDX-License-Identifier: MIT
|
|
# Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
|
|
|
from typing import Iterable
|
|
|
|
|
|
class BTree:
|
|
def close(self): ...
|
|
|
|
def values(self, start_key: str | bytes, end_key: str | bytes | None = None, flags=None) -> Iterable[str | bytes]:
|
|
pass
|
|
|
|
def __setitem__(self, key: str | bytes, val: str | bytes): ...
|
|
|
|
def flush(self): ...
|
|
|
|
def get(self, key: str | bytes, default: str | bytes | None = None) -> str | bytes: ...
|
|
|
|
|
|
def open(dbfile) -> BTree:
|
|
pass
|