Liphos commited on
Commit
72a364e
·
verified ·
1 Parent(s): 41a13d3

add check to verify good music is played

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -79,9 +79,14 @@ def play_preview_deezer(track: str, artist:str) -> None:
79
  # Check if the request was successful
80
  if response.status_code == 200:
81
  data = response.json()
 
82
  # Print the first track from the search results
83
- if data['data']:
84
  first_track = data['data'][0]
 
 
 
 
85
  print(f"Title: {first_track['title']}")
86
  print(f"Artist: {first_track['artist']['name']}")
87
  print(f"Album: {first_track['album']['title']}")
 
79
  # Check if the request was successful
80
  if response.status_code == 200:
81
  data = response.json()
82
+ print([data_sample['title'] for data_sample in data['data']])
83
  # Print the first track from the search results
84
+ if len(data['data']) > 0:
85
  first_track = data['data'][0]
86
+ for data_sample in data['data']:
87
+ if track in data_sample['title'] and (artist in data_sample['artist']['name'] or artist in data_sample["title"]):
88
+ first_track = data_sample
89
+ break
90
  print(f"Title: {first_track['title']}")
91
  print(f"Artist: {first_track['artist']['name']}")
92
  print(f"Album: {first_track['album']['title']}")