Update app.py
Browse files
app.py
CHANGED
@@ -111,11 +111,12 @@ async def match():
|
|
111 |
title = track_info["entitiesByUniqueId"][entityUniqueId]["title"]
|
112 |
artist = track_info["entitiesByUniqueId"][entityUniqueId]["artistName"]
|
113 |
if youtube_url:
|
|
|
114 |
if title and artist:
|
115 |
filename = f"{title} - {artist}"
|
116 |
-
return {"url": youtube_url, "filename": filename}
|
117 |
else:
|
118 |
-
return {"url": youtube_url, "filename": "Unknown Track - Unknown Artist"}
|
119 |
else:
|
120 |
|
121 |
search_query = f'{title}+{artist}'
|
@@ -124,7 +125,7 @@ async def match():
|
|
124 |
if 'videoId' in first_song:
|
125 |
videoId = first_song["videoId"]
|
126 |
ym_url = f'https://www.youtube.com/watch?v={videoId}'
|
127 |
-
return {"filename":
|
128 |
else:
|
129 |
raise HTTPException(status_code=404, detail="Video ID not found")
|
130 |
|
|
|
111 |
title = track_info["entitiesByUniqueId"][entityUniqueId]["title"]
|
112 |
artist = track_info["entitiesByUniqueId"][entityUniqueId]["artistName"]
|
113 |
if youtube_url:
|
114 |
+
video_id = youtube_url.split("v=")[1] if "v=" in url else None
|
115 |
if title and artist:
|
116 |
filename = f"{title} - {artist}"
|
117 |
+
return {"url": youtube_url, "filename": filename, "track_id": video_id}
|
118 |
else:
|
119 |
+
return {"url": youtube_url, "filename": "Unknown Track - Unknown Artist", "track_id": video_id}
|
120 |
else:
|
121 |
|
122 |
search_query = f'{title}+{artist}'
|
|
|
125 |
if 'videoId' in first_song:
|
126 |
videoId = first_song["videoId"]
|
127 |
ym_url = f'https://www.youtube.com/watch?v={videoId}'
|
128 |
+
return {"filename": search_query, "url": ym_url, "track_id": videoId}
|
129 |
else:
|
130 |
raise HTTPException(status_code=404, detail="Video ID not found")
|
131 |
|