Update app.py
Browse files
app.py
CHANGED
@@ -106,8 +106,9 @@ async def match():
|
|
106 |
raise HTTPException(status_code=404, detail="Could not fetch track info")
|
107 |
|
108 |
youtube_url = extract_url(track_info["linksByPlatform"], "youtube")
|
|
|
|
|
109 |
if youtube_url:
|
110 |
-
title, artist = extract_track_info(track_info["entitiesByUniqueId"], "youtube")
|
111 |
if title and artist:
|
112 |
filename = f"{title} - {artist}"
|
113 |
return {"url": youtube_url, "filename": filename}
|
@@ -116,8 +117,7 @@ async def match():
|
|
116 |
else:
|
117 |
entityUniqueId = track_info["entityUniqueId"]
|
118 |
logger.info(f"songlink info: {entityUniqueId}")
|
119 |
-
|
120 |
-
artist = track_info["entitiesByUniqueId"][entityUniqueId]["artistName"]
|
121 |
search_query = f'{title}+{artist}'
|
122 |
search_results = ytmusic.search(search_query, filter="songs")
|
123 |
first_song = next((song for song in search_results if 'videoId' in song and song['videoId']), {}) if search_results else {}
|
|
|
106 |
raise HTTPException(status_code=404, detail="Could not fetch track info")
|
107 |
|
108 |
youtube_url = extract_url(track_info["linksByPlatform"], "youtube")
|
109 |
+
title = track_info["entitiesByUniqueId"][entityUniqueId]["title"]
|
110 |
+
artist = track_info["entitiesByUniqueId"][entityUniqueId]["artistName"]
|
111 |
if youtube_url:
|
|
|
112 |
if title and artist:
|
113 |
filename = f"{title} - {artist}"
|
114 |
return {"url": youtube_url, "filename": filename}
|
|
|
117 |
else:
|
118 |
entityUniqueId = track_info["entityUniqueId"]
|
119 |
logger.info(f"songlink info: {entityUniqueId}")
|
120 |
+
|
|
|
121 |
search_query = f'{title}+{artist}'
|
122 |
search_results = ytmusic.search(search_query, filter="songs")
|
123 |
first_song = next((song for song in search_results if 'videoId' in song and song['videoId']), {}) if search_results else {}
|