Compare commits

1 Commits
main ... main

Author SHA1 Message Date
8ab422a7aa added yt-dlp option 2026-01-03 19:16:26 +00:00

View File

@@ -92,11 +92,27 @@ def download_mp3(url, quality='320'):
# Prefer yt-dlp for YouTube because it can actually control MP3 output bitrate. # Prefer yt-dlp for YouTube because it can actually control MP3 output bitrate.
if _can_use_ytdlp(): if _can_use_ytdlp():
try: try:
print(f"⬇️ Downloading via yt-dlp @ {quality_kbps}kbps...") print(f"✨ Using yt-dlp (preferred method)")
print(f"⬇️ Downloading @ {quality_kbps}kbps...")
return _download_with_ytdlp(url, quality_kbps) return _download_with_ytdlp(url, quality_kbps)
except Exception as e: except Exception as e:
# If yt-dlp fails for any reason, fall back to the existing Cobalt flow. # If yt-dlp fails for any reason, fall back to the existing Cobalt flow.
print(f"⚠️ yt-dlp failed, falling back to Cobalt: {e}") print(f"⚠️ yt-dlp failed, falling back to Cobalt API: {e}")
else:
# Check what's missing
has_ffmpeg = shutil.which("ffmpeg") is not None
has_ytdlp = False
try:
import yt_dlp # noqa: F401
has_ytdlp = True
except:
pass
if not has_ffmpeg:
print("⚠️ ffmpeg not found - using Cobalt API fallback")
if not has_ytdlp:
print("⚠️ yt-dlp not installed - using Cobalt API fallback")
print(" 💡 Install with: pip install yt-dlp")
try: try:
# Use Cobalt v9 API to download # Use Cobalt v9 API to download