Update app.py
Browse files
app.py
CHANGED
|
@@ -117,23 +117,33 @@ def get_best_formats_with_fallback(data: dict, requested_quality: int):
|
|
| 117 |
|
| 118 |
def run_ytdlp_download(url: str, out_path: Path):
|
| 119 |
"""
|
| 120 |
-
Runs a single yt-dlp download using
|
|
|
|
| 121 |
"""
|
| 122 |
ydl_opts = {
|
| 123 |
'outtmpl': str(out_path),
|
| 124 |
'quiet': True,
|
| 125 |
'noprogress': True,
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
'--min-split-size=1M',
|
| 132 |
'--max-connection-per-server=16',
|
| 133 |
'--max-concurrent-downloads=16',
|
| 134 |
'--split=16'
|
| 135 |
-
]
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
with YoutubeDL(ydl_opts) as ydl:
|
| 138 |
ydl.download([url])
|
| 139 |
|
|
|
|
| 117 |
|
| 118 |
def run_ytdlp_download(url: str, out_path: Path):
|
| 119 |
"""
|
| 120 |
+
Runs a single yt-dlp download, using 'aria2c' for direct files
|
| 121 |
+
and the default (or ffmpeg) downloader for HLS/m3u8 streams.
|
| 122 |
"""
|
| 123 |
ydl_opts = {
|
| 124 |
'outtmpl': str(out_path),
|
| 125 |
'quiet': True,
|
| 126 |
'noprogress': True,
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
# Check if the URL is an HLS playlist.
|
| 130 |
+
# If it's NOT, we assume it's a direct file and can use the aria2c optimization.
|
| 131 |
+
if ".m3u8" not in url.lower():
|
| 132 |
+
logging.info(f"Using aria2c for direct file download: {out_path.name}")
|
| 133 |
+
# --- SPEED OPTIMIZATION (FOR DIRECT FILES) ---
|
| 134 |
+
ydl_opts['external_downloader'] = 'aria2c'
|
| 135 |
+
ydl_opts['external_downloader_args'] = [
|
| 136 |
'--min-split-size=1M',
|
| 137 |
'--max-connection-per-server=16',
|
| 138 |
'--max-concurrent-downloads=16',
|
| 139 |
'--split=16'
|
| 140 |
+
]
|
| 141 |
+
else:
|
| 142 |
+
logging.info(f"Using default HLS downloader for m3u8 stream: {out_path.name}")
|
| 143 |
+
# For M3U8 streams, yt-dlp will use its internal HLS downloader
|
| 144 |
+
# or FFmpeg. Since FFmpeg is already required for your merge step,
|
| 145 |
+
# this will work perfectly.
|
| 146 |
+
|
| 147 |
with YoutubeDL(ydl_opts) as ydl:
|
| 148 |
ydl.download([url])
|
| 149 |
|