File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 22from fastapi import APIRouter , Depends
33
44from app .container import Container
5- from app .spotify .schemas import Device , CurrentDevice
5+ from app .spotify .exceptions import TrackNotFoundError , DeviceNotFoundError
6+ from app .spotify .schemas import Device , CurrentDevice , Track
67from app .spotify .service import SpotifyService
78
89spotify_router = APIRouter ()
@@ -62,3 +63,18 @@ def previous_device(
6263 index = spotify_service .get_current_device_index (),
6364 total = spotify_service .get_devices_count ()
6465 )
66+
67+
68+ @spotify_router .post ("/play" )
69+ @inject
70+ def play (
71+ track : Track ,
72+ spotify_service : SpotifyService = Depends (Provide [Container .spotify_service ])
73+ ) -> Device | dict :
74+ try :
75+ spotify_service .play (track )
76+ except TrackNotFoundError :
77+ return {"error" : "Track not found" }
78+ except DeviceNotFoundError :
79+ return {"error" : "Device not found" }
80+ return {"status" : "ok" }
You can’t perform that action at this time.
0 commit comments