JayosChaos commited on
Commit
ea04ad3
·
verified ·
1 Parent(s): 015bd0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -32,10 +32,10 @@ def get_nbp_exchange_rate(currency: str) -> float:
32
 
33
  @tool
34
  def get_billboard_hot_100_last_countdown() -> list:
35
- """A tool that fetches the latest Billboard Hot 100 countdown.
36
 
37
  Returns:
38
- A list of the top 10 songs from the latest Billboard Hot 100.
39
  """
40
  import requests
41
  from bs4 import BeautifulSoup
@@ -46,7 +46,15 @@ def get_billboard_hot_100_last_countdown() -> list:
46
  if response.status_code == 200:
47
  soup = BeautifulSoup(response.text, 'html.parser')
48
  songs = soup.select(".o-chart-results-list__item h3")
49
- return [song.get_text(strip=True) for song in songs[:10]]
 
 
 
 
 
 
 
 
50
  else:
51
  raise ValueError(f"Failed to fetch Billboard Hot 100. HTTP Status: {response.status_code}")
52
 
 
32
 
33
  @tool
34
  def get_billboard_hot_100_last_countdown() -> list:
35
+ """A tool that fetches the latest Billboard Hot 100 countdown with song names and artist names.
36
 
37
  Returns:
38
+ A list of dictionaries containing the top 10 songs with their respective artists from the latest Billboard Hot 100.
39
  """
40
  import requests
41
  from bs4 import BeautifulSoup
 
46
  if response.status_code == 200:
47
  soup = BeautifulSoup(response.text, 'html.parser')
48
  songs = soup.select(".o-chart-results-list__item h3")
49
+ artists = soup.select(".o-chart-results-list__item span.c-label")
50
+
51
+ top_songs = []
52
+ for i in range(min(10, len(songs))):
53
+ song_name = songs[i].get_text(strip=True)
54
+ artist_name = artists[i].get_text(strip=True)
55
+ top_songs.append({"song": song_name, "artist": artist_name})
56
+
57
+ return top_songs
58
  else:
59
  raise ValueError(f"Failed to fetch Billboard Hot 100. HTTP Status: {response.status_code}")
60