fix(musicseerr): handle missing pageProps.state gracefully and add jitter
Build and Push Docker Images / build (api) (push) Failing after 4m18s Details
Build and Push Docker Images / build (musicseerr) (push) Failing after 6m12s Details
Build and Push Docker Images / build (nextgen) (push) Failing after 4m31s Details
Build and Push Docker Images / build (web) (push) Failing after 13m41s Details
Build and Push Docker Images / build (worker) (push) Successful in 16m37s Details
Build and Push Docker Images / deploy (push) Has been skipped Details

This commit is contained in:
fchinembiri 2026-07-10 10:39:35 +02:00
parent 4164bde79b
commit 0a6e46160d
1 changed files with 8 additions and 1 deletions

View File

@ -278,18 +278,25 @@ def scrape_spotify_playlist(url: str, proxy_url: str) -> list:
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
import time
# Try with proxy first, then without proxy
for use_proxy in [True, False]:
current_proxies = {"http": proxy_url, "https": proxy_url} if (use_proxy and proxy_url) else None
proxy_desc = f"via proxy {proxy_url}" if current_proxies else "directly"
logger.info(f"Scraping Spotify playlist via embed URL: {embed_url} ({proxy_desc})")
try:
# Short jitter to avoid hitting Spotify exactly at the same time
time.sleep(1)
response = requests.get(embed_url, headers=headers, proxies=current_proxies, timeout=15)
if response.status_code == 200:
next_data_match = re.search(r'<script id="__NEXT_DATA__" type="application/json">(.*?)</script>', response.text)
if next_data_match:
data = json.loads(next_data_match.group(1))
entity = data['props']['pageProps']['state']['data']['entity']
page_props = data.get('props', {}).get('pageProps', {})
if 'state' not in page_props:
logger.warning(f"Spotify embed pageProps does not contain 'state' ({proxy_desc}). HTML snippet: {response.text[:250]}")
continue
entity = page_props['state']['data']['entity']
tracks = entity.get('tracks', entity.get('trackList', []))
track_queries = []
for t in tracks: