Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ from datetime import datetime, timedelta
|
|
7 |
import time
|
8 |
import asyncio
|
9 |
import cloudscraper
|
10 |
-
from fastapi import FastAPI, BackgroundTasks, HTTPException
|
11 |
|
12 |
app = Flask(__name__)
|
13 |
ytmusic = YTMusic()
|
@@ -88,14 +87,15 @@ async def get_track_download_url(track_id: str) -> str:
|
|
88 |
logger.info(f"Response status: {response.status_code}")
|
89 |
logger.info(f"Response content: {response.content}")
|
90 |
|
91 |
-
if response.
|
92 |
-
|
93 |
-
if
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
99 |
continue
|
100 |
|
101 |
logger.error(f"No download URL found")
|
|
|
7 |
import time
|
8 |
import asyncio
|
9 |
import cloudscraper
|
|
|
10 |
|
11 |
app = Flask(__name__)
|
12 |
ytmusic = YTMusic()
|
|
|
87 |
logger.info(f"Response status: {response.status_code}")
|
88 |
logger.info(f"Response content: {response.content}")
|
89 |
|
90 |
+
if response.headers.get('content-type', '').startswith('application/json'):
|
91 |
+
json_response = response.json()
|
92 |
+
if "video.unavailable" in json_response.get("error", {}).get("code", ""):
|
93 |
+
break
|
94 |
+
|
95 |
+
api_rotator.update_last_successful(apis.index(api_url))
|
96 |
+
return json_response.get("url")
|
97 |
+
except Exception as e:
|
98 |
+
logger.error(f"Failed with {api_url}: {str(e)}")
|
99 |
continue
|
100 |
|
101 |
logger.error(f"No download URL found")
|