modules.core.queue
Audio Queue Manager
A script that manages a queue of songs from the audio library and plays them using player.py and a db file (assumed to be generated by database.py).
Functions
|
Add missing song to database automatically during playback. |
|
Connect to the SQLite database and return connection. |
|
Display the current queue with highlighting for current song. |
|
Format song information for display with comprehensive metadata. |
|
Get songs from database based on filters. |
|
Interactive mode for queue management. |
|
Main function for audio queue management command-line interface. |
|
Play songs in the queue with various playback options. |
- modules.core.queue.connect_to_database(db_path)[source]
Connect to the SQLite database and return connection.
- Parameters:
db_path (str) – Path to the SQLite database file.
- Returns:
Database connection object, or None if connection fails.
- Return type:
sqlite3.Connection or None
- modules.core.queue.get_songs_from_database(conn, filters=None)[source]
Get songs from database based on filters.
- Parameters:
conn (sqlite3.Connection) – Database connection object.
filters (dict, optional) – Dictionary with filter criteria. Supported keys: ‘artist’, ‘album’, ‘genre’ (all use partial matching).
- Returns:
List of song records as sqlite3.Row objects, ordered by artist, album, disc, track.
- Return type:
- modules.core.queue.format_song_info(song)[source]
Format song information for display with comprehensive metadata.
- Parameters:
song (dict or sqlite3.Row) – Song record with metadata.
- Returns:
Formatted song information string with track, artist, title, albumartist, album, year, and duration.
- Return type:
- modules.core.queue.display_queue(queue, current_index=0)[source]
Display the current queue with highlighting for current song.
- modules.core.queue.play_queue(queue, shuffle=False, repeat=False, start_index=0, conn=None)[source]
Play songs in the queue with various playback options.
- Parameters:
queue (list) – List of song dictionaries or database records.
shuffle (bool, optional) – Enable shuffle mode. Defaults to False.
repeat (bool, optional) – Enable repeat mode. Defaults to False.
start_index (int, optional) – Index to start playback from. Defaults to 0.
conn (sqlite3.Connection, optional) – Database connection for auto-adding missing songs.
- modules.core.queue.add_missing_song_to_database(file_path, conn)[source]
Add missing song to database automatically during playback.
- Parameters:
file_path (str) – Path to the audio file to add.
conn (sqlite3.Connection) – Database connection object.
- Returns:
True if song was added successfully, False otherwise.
- Return type:
- modules.core.queue.interactive_mode(conn)[source]
Interactive mode for queue management.
Provides a command-line interface for managing audio queues with commands for filtering, loading, and playing songs.
- Parameters:
conn (sqlite3.Connection) – Database connection object.
- modules.core.queue.main()[source]
Main function for audio queue management command-line interface.
Parses command-line arguments and performs queue operations including database filtering, playlist loading, and various playback modes.
Examples
- Play all songs by an artist with shuffle:
python queue.py –artist “Pink Floyd” –shuffle
- Play specific album on repeat:
python queue.py –album “Dark Side of the Moon” –repeat
- Play from external playlist:
python queue.py –playlist myplaylist.m3u
- Interactive mode with genre filter:
python queue.py –genre “Rock” –interactive
- Custom database path:
python queue.py –db-path ~/music.db –shuffle