Chrunos commited on
Commit
c23aa3d
·
verified ·
1 Parent(s): 3f2a2be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
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
- return response.json()
 
 
 
 
 
 
 
 
 
 
 
209
  except requests.exceptions.RequestException as e:
210
- logger.error(f"Network error fetching playlist: {e}")
211
- raise HTTPException(status_code = 500, detail=str(e))
212
  except Exception as e:
213
- logger.error(f"Error fetching playlist: {e}")
214
- raise HTTPException(status_code = 500, detail=str(e))
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