jdxi_editor.ui.programs.playlist_orm
SQLAlchemy ORM-based access layer for playlists.
This module provides ORM-based methods for accessing playlists and playlist items using SQLAlchemy, replacing the direct SQLite queries in database.py.
Classes
ORM-based access layer for playlists. |
Module Contents
- class jdxi_editor.ui.programs.playlist_orm.PlaylistORM(db_path: pathlib.Path | None = None)[source]
ORM-based access layer for playlists.
- create_playlist(name: str, description: str | None = None) int | None[source]
Create a new playlist.
- Parameters:
name – Playlist name (must be unique)
description – Optional description
- Returns:
Playlist ID if successful, None otherwise
- get_playlist_by_id(playlist_id: int) Dict | None[source]
Get a playlist by ID.
- Parameters:
playlist_id – Playlist ID
- Returns:
Playlist dictionary if found, None otherwise
- update_playlist(playlist_id: int, name: str | None = None, description: str | None = None) bool[source]
Update a playlist.
- Parameters:
playlist_id – Playlist ID
name – New name (optional)
description – New description (optional)
- Returns:
True if successful, False otherwise
- delete_playlist(playlist_id: int) bool[source]
Delete a playlist and all its items.
- Parameters:
playlist_id – Playlist ID
- Returns:
True if successful, False otherwise
- add_program_to_playlist(playlist_id: int, program_id: str, position: int | None = None) bool[source]
Add a program to a playlist.
- Parameters:
playlist_id – Playlist ID
program_id – Program ID (e.g., “E01”)
position – Position in playlist (optional, will append if not provided)
- Returns:
True if successful, False otherwise
- remove_program_from_playlist(playlist_id: int, program_id: str) bool[source]
Remove a program from a playlist.
- Parameters:
playlist_id – Playlist ID
program_id – Program ID
- Returns:
True if successful, False otherwise
- get_playlist_programs(playlist_id: int, get_program_func: callable | None = None) List[Dict][source]
Get all programs in a playlist with their MIDI file paths, ordered by position.
- Parameters:
playlist_id – Playlist ID
get_program_func – Optional function to get JDXiProgram by ID (for compatibility)
- Returns:
List of dictionaries with ‘program’ (JDXiProgram) and ‘midi_file_path’ (str)
- update_playlist_item_midi_file(playlist_id: int, program_id: str, midi_file_path: str | None) bool[source]
Update the MIDI file path for a playlist item.
- Parameters:
playlist_id – Playlist ID
program_id – Program ID
midi_file_path – Path to MIDI file (or None to clear)
- Returns:
True if successful, False otherwise
- update_playlist_item_cheat_preset(playlist_id: int, program_id: str, cheat_preset_id: str | None = None) bool[source]
Update the cheat preset ID for a playlist item.
- Parameters:
playlist_id – Playlist ID
program_id – Program ID
cheat_preset_id – Cheat preset ID (e.g., “113”) or None to clear
- Returns:
True if updated, False otherwise