fix: resolve proxy hostname to IP inside tasks.py to satisfy spotDL validation requirements
Build and Push Docker Images / build (api) (push) Successful in 2m31s
Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 6m1s
Details
Build and Push Docker Images / build (web) (push) Successful in 1m29s
Details
Build and Push Docker Images / build (nextgen) (push) Successful in 6m45s
Details
Build and Push Docker Images / build (worker) (push) Successful in 10m37s
Details
Build and Push Docker Images / deploy (push) Successful in 15s
Details
Build and Push Docker Images / build (api) (push) Successful in 2m31s
Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 6m1s
Details
Build and Push Docker Images / build (web) (push) Successful in 1m29s
Details
Build and Push Docker Images / build (nextgen) (push) Successful in 6m45s
Details
Build and Push Docker Images / build (worker) (push) Successful in 10m37s
Details
Build and Push Docker Images / deploy (push) Successful in 15s
Details
This commit is contained in:
parent
7ad4e184f9
commit
93296dbee3
|
|
@ -140,6 +140,30 @@ def run_download_task(task_id: str, query: str, proxy_url: str, jobs_dict: dict,
|
|||
temp_dir = f"/tmp/downloads/{task_id}"
|
||||
os.makedirs(temp_dir, exist_ok=True)
|
||||
|
||||
# Resolve proxy hostname to IP address for spotDL compatibility (spotDL requires IP in proxy URL)
|
||||
resolved_proxy_url = proxy_url
|
||||
if proxy_url:
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
import socket
|
||||
parsed = urlparse(proxy_url)
|
||||
if parsed.hostname and not parsed.hostname.replace('.', '').isdigit():
|
||||
ip = socket.gethostbyname(parsed.hostname)
|
||||
netloc = ip
|
||||
if parsed.port:
|
||||
netloc = f"{ip}:{parsed.port}"
|
||||
if parsed.username or parsed.password:
|
||||
auth = ""
|
||||
if parsed.username:
|
||||
auth += parsed.username
|
||||
if parsed.password:
|
||||
auth += f":{parsed.password}"
|
||||
netloc = f"{auth}@{netloc}"
|
||||
resolved_proxy_url = parsed._replace(netloc=netloc).geturl()
|
||||
logger.info(f"Resolved proxy hostname '{parsed.hostname}' to IP '{ip}'. New proxy URL: '{resolved_proxy_url}'")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to resolve proxy hostname: {e}")
|
||||
|
||||
try:
|
||||
is_tubidy = "tubidy" in query.lower()
|
||||
is_spotify = "spotify.com" in query.lower()
|
||||
|
|
@ -151,13 +175,13 @@ def run_download_task(task_id: str, query: str, proxy_url: str, jobs_dict: dict,
|
|||
logger.info(f"[{task_id}] Attempting Priority 1: spotDL for '{query}'")
|
||||
|
||||
env = os.environ.copy()
|
||||
if proxy_url:
|
||||
env["http_proxy"] = proxy_url
|
||||
env["https_proxy"] = proxy_url
|
||||
if resolved_proxy_url:
|
||||
env["http_proxy"] = resolved_proxy_url
|
||||
env["https_proxy"] = resolved_proxy_url
|
||||
|
||||
cmd = ["spotdl", "download", query]
|
||||
if proxy_url:
|
||||
cmd += ["--proxy", proxy_url]
|
||||
if resolved_proxy_url:
|
||||
cmd += ["--proxy", resolved_proxy_url]
|
||||
|
||||
# Run spotDL in the temp directory
|
||||
result = subprocess.run(cmd, cwd=temp_dir, env=env, capture_output=True, text=True)
|
||||
|
|
@ -174,9 +198,9 @@ def run_download_task(task_id: str, query: str, proxy_url: str, jobs_dict: dict,
|
|||
logger.info(f"[{task_id}] Attempting Priority 2: yt-dlp for '{query}'")
|
||||
|
||||
env = os.environ.copy()
|
||||
if proxy_url:
|
||||
env["http_proxy"] = proxy_url
|
||||
env["https_proxy"] = proxy_url
|
||||
if resolved_proxy_url:
|
||||
env["http_proxy"] = resolved_proxy_url
|
||||
env["https_proxy"] = resolved_proxy_url
|
||||
|
||||
# If not a link, treat as search query
|
||||
search_query = query
|
||||
|
|
@ -191,8 +215,8 @@ def run_download_task(task_id: str, query: str, proxy_url: str, jobs_dict: dict,
|
|||
"--yes-playlist",
|
||||
"--output", "%(title)s.%(ext)s"
|
||||
]
|
||||
if proxy_url:
|
||||
cmd += ["--proxy", proxy_url]
|
||||
if resolved_proxy_url:
|
||||
cmd += ["--proxy", resolved_proxy_url]
|
||||
cmd.append(search_query)
|
||||
|
||||
result = subprocess.run(cmd, cwd=temp_dir, env=env, capture_output=True, text=True)
|
||||
|
|
@ -208,7 +232,7 @@ def run_download_task(task_id: str, query: str, proxy_url: str, jobs_dict: dict,
|
|||
logger.info(f"[{task_id}] Attempting Priority 3: Tubidy Scraper for '{query}'")
|
||||
|
||||
# Scrape MP3 URL
|
||||
mp3_url = scrape_tubidy_link(query, proxy_url)
|
||||
mp3_url = scrape_tubidy_link(query, resolved_proxy_url)
|
||||
logger.info(f"[{task_id}] Scraped Tubidy MP3 URL: {mp3_url}")
|
||||
|
||||
# Formulate filename
|
||||
|
|
@ -222,7 +246,7 @@ def run_download_task(task_id: str, query: str, proxy_url: str, jobs_dict: dict,
|
|||
dest_path = os.path.join(temp_dir, filename)
|
||||
|
||||
# Download file stream
|
||||
download_file_stream(mp3_url, dest_path, proxy_url)
|
||||
download_file_stream(mp3_url, dest_path, resolved_proxy_url)
|
||||
logger.info(f"[{task_id}] Tubidy download completed.")
|
||||
|
||||
# Tag metadata
|
||||
|
|
|
|||
Loading…
Reference in New Issue