ソースを参照

Auto-create playlist if not found on get_playlist

Instead of returning 404 when a playlist doesn't exist, automatically
create an empty playlist. This handles cases like "Favorites" where
the UI expects the playlist to exist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 2 週間 前
コミット
492507f73f
1 ファイル変更4 行追加1 行削除
  1. 4 1
      main.py

+ 4 - 1
main.py

@@ -1894,7 +1894,10 @@ async def get_playlist(name: str):
 
     playlist = playlist_manager.get_playlist(name)
     if not playlist:
-        raise HTTPException(status_code=404, detail=f"Playlist '{name}' not found")
+        # Auto-create empty playlist if not found
+        logger.info(f"Playlist '{name}' not found, creating empty playlist")
+        playlist_manager.create_playlist(name, [])
+        playlist = {"name": name, "files": []}
 
     return playlist