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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -173,13 +173,24 @@ def fetch_album(request: AlbumRequest):
173
  try:
174
  response = requests.get(f"{DEEZER_API_URL}/album/{album_id}")
175
  response.raise_for_status()
176
- return response.json()
 
 
 
 
 
 
 
 
 
 
 
177
  except requests.exceptions.RequestException as e:
178
  logger.error(f"Network error fetching album: {e}")
179
- raise HTTPException(status_code = 500, detail=str(e))
180
  except Exception as e:
181
  logger.error(f"Error fetching album: {e}")
182
- raise HTTPException(status_code = 500, detail=str(e))
183
 
184
 
185
  # Pydantic model for playlist request
 
173
  try:
174
  response = requests.get(f"{DEEZER_API_URL}/album/{album_id}")
175
  response.raise_for_status()
176
+ album_data = response.json()
177
+ tracks = album_data.get("tracks", {}).get("data", [])
178
+ result = []
179
+ for track in tracks:
180
+ title = track.get("title")
181
+ link = track.get("link")
182
+ if title and link:
183
+ result.append({
184
+ "title": title,
185
+ "link": link
186
+ })
187
+ return result
188
  except requests.exceptions.RequestException as e:
189
  logger.error(f"Network error fetching album: {e}")
190
+ raise HTTPException(status_code=500, detail=str(e))
191
  except Exception as e:
192
  logger.error(f"Error fetching album: {e}")
193
+ raise HTTPException(status_code=500, detail=str(e))
194
 
195
 
196
  # Pydantic model for playlist request