Update app.py
Browse files
app.py
CHANGED
@@ -161,6 +161,37 @@ def download_track(request: DownloadRequest):
|
|
161 |
raise HTTPException(status_code=500, detail=str(e))
|
162 |
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
# Search tracks using Deezer API
|
165 |
@app.get("/search")
|
166 |
def search_tracks(query: str, limit: Optional[int] = 10):
|
|
|
161 |
raise HTTPException(status_code=500, detail=str(e))
|
162 |
|
163 |
|
164 |
+
# Fetch album data
|
165 |
+
@app.post("/album")
|
166 |
+
def fetch_album(album_id: int = Query(..., description="ID of the album to fetch")):
|
167 |
+
try:
|
168 |
+
response = requests.get(f"{DEEZER_API_URL}/album/{album_id}")
|
169 |
+
response.raise_for_status()
|
170 |
+
return response.json()
|
171 |
+
except requests.exceptions.RequestException as e:
|
172 |
+
logger.error(f"Network error fetching album: {e}")
|
173 |
+
raise HTTPException(status_code=500, detail=str(e))
|
174 |
+
except Exception as e:
|
175 |
+
logger.error(f"Error fetching album: {e}")
|
176 |
+
raise HTTPException(status_code=500, detail=str(e))
|
177 |
+
|
178 |
+
|
179 |
+
# Fetch playlist data
|
180 |
+
@app.post("/playlist")
|
181 |
+
def fetch_playlist(playlist_id: int = Query(..., description="ID of the playlist to fetch")):
|
182 |
+
try:
|
183 |
+
response = requests.get(f"{DEEZER_API_URL}/playlist/{playlist_id}")
|
184 |
+
response.raise_for_status()
|
185 |
+
return response.json()
|
186 |
+
except requests.exceptions.RequestException as e:
|
187 |
+
logger.error(f"Network error fetching playlist: {e}")
|
188 |
+
raise HTTPException(status_code=500, detail=str(e))
|
189 |
+
except Exception as e:
|
190 |
+
logger.error(f"Error fetching playlist: {e}")
|
191 |
+
raise HTTPException(status_code=500, detail=str(e))
|
192 |
+
|
193 |
+
|
194 |
+
|
195 |
# Search tracks using Deezer API
|
196 |
@app.get("/search")
|
197 |
def search_tracks(query: str, limit: Optional[int] = 10):
|