Update app.py
Browse files
app.py
CHANGED
@@ -205,13 +205,24 @@ def fetch_playlist(request: PlaylistRequest):
|
|
205 |
try:
|
206 |
response = requests.get(f"{DEEZER_API_URL}/playlist/{playlist_id}")
|
207 |
response.raise_for_status()
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
except requests.exceptions.RequestException as e:
|
210 |
-
logger.error(f"Network error fetching
|
211 |
-
raise HTTPException(status_code
|
212 |
except Exception as e:
|
213 |
-
logger.error(f"Error fetching
|
214 |
-
raise HTTPException(status_code
|
215 |
|
216 |
|
217 |
|
|
|
205 |
try:
|
206 |
response = requests.get(f"{DEEZER_API_URL}/playlist/{playlist_id}")
|
207 |
response.raise_for_status()
|
208 |
+
playlist_data = response.json()
|
209 |
+
tracks = playlist_data.get("tracks", {}).get("data", [])
|
210 |
+
result = []
|
211 |
+
for track in tracks:
|
212 |
+
title = track.get("title")
|
213 |
+
link = track.get("link")
|
214 |
+
if title and link:
|
215 |
+
result.append({
|
216 |
+
"title": title,
|
217 |
+
"link": link
|
218 |
+
})
|
219 |
+
return result
|
220 |
except requests.exceptions.RequestException as e:
|
221 |
+
logger.error(f"Network error fetching album: {e}")
|
222 |
+
raise HTTPException(status_code=500, detail=str(e))
|
223 |
except Exception as e:
|
224 |
+
logger.error(f"Error fetching album: {e}")
|
225 |
+
raise HTTPException(status_code=500, detail=str(e))
|
226 |
|
227 |
|
228 |
|