This commit is contained in:
nose
2025-11-27 18:35:06 -08:00
parent 9eff65d1af
commit ed417c8200
6 changed files with 143 additions and 93 deletions

View File

@@ -194,30 +194,45 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
if index_arg:
try:
pl_id = int(index_arg)
result = db.get_playlist_by_id(pl_id)
if result is None:
debug(f"Playlist ID {pl_id} not found.")
return 1
name, items = result
current_playlist_name = name
# Queue items (replacing current playlist)
if items:
_queue_items(items, clear_first=True)
# Handle Delete Playlist (if -clear is also passed)
if clear_mode:
if db.delete_playlist(pl_id):
debug(f"Playlist ID {pl_id} deleted.")
# Clear index_arg so we fall through to list mode and show updated list
index_arg = None
# Don't return, let it list the remaining playlists
else:
debug(f"Failed to delete playlist ID {pl_id}.")
return 1
else:
# Empty playlist, just clear
_send_ipc_command({"command": ["playlist-clear"]}, silent=True)
# Switch to list mode to show the result
list_mode = True
index_arg = None
# Fall through to list logic
# Handle Load Playlist
result = db.get_playlist_by_id(pl_id)
if result is None:
debug(f"Playlist ID {pl_id} not found.")
return 1
name, items = result
current_playlist_name = name
# Queue items (replacing current playlist)
if items:
_queue_items(items, clear_first=True)
else:
# Empty playlist, just clear
_send_ipc_command({"command": ["playlist-clear"]}, silent=True)
# Switch to list mode to show the result
list_mode = True
index_arg = None
# Fall through to list logic
except ValueError:
debug(f"Invalid playlist ID: {index_arg}")
return 1
else:
# If we deleted or didn't have an index, list playlists
if not index_arg:
playlists = db.get_playlists()
if not playlists:
@@ -280,7 +295,8 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
return 1
# Handle piped input (add to playlist)
if result:
# Skip adding if -list is specified (user just wants to see current playlist)
if result and not list_mode:
# If result is a list of items, add them to playlist
items_to_add = []
if isinstance(result, list):