Update app.py
Browse files
app.py
CHANGED
|
@@ -61,4 +61,18 @@ async def fetch_data_for_url(request: Request):
|
|
| 61 |
|
| 62 |
download_url = f'{BASE}track/getFileUrl?format_id=27&intent=stream&track_id={track_id}&request_ts={timestamp}&request_sig={rSig}'
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
download_url = f'{BASE}track/getFileUrl?format_id=27&intent=stream&track_id={track_id}&request_ts={timestamp}&request_sig={rSig}'
|
| 63 |
|
| 64 |
+
|
| 65 |
+
try:
|
| 66 |
+
download_response = requests.get(download_url, headers=HEADERS)
|
| 67 |
+
download_response.raise_for_status()
|
| 68 |
+
|
| 69 |
+
file_url = download_response.json().get('url')
|
| 70 |
+
if file_url:
|
| 71 |
+
print(f'Download link: {file_url}')
|
| 72 |
+
else:
|
| 73 |
+
print('Error fetching download URL.')
|
| 74 |
+
|
| 75 |
+
except requests.exceptions.RequestException:
|
| 76 |
+
print('Error fetching data for the URL.')
|
| 77 |
+
return {"download_url": file_url}
|
| 78 |
+
|