From 47c12dbb15f95a48974921b0c21e87d3983344db Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Sun, 16 Mar 2025 14:27:23 +0100 Subject: [PATCH] mp4: Fix error 'set_alpn_protocols' (cherry picked from commit ab094d0b1db21e74b8af4b5b995779dfd88ce3db) --- StreamingCommunity/Lib/Downloader/MP4/downloader.py | 13 +++++++------ StreamingCommunity/Util/config_json.py | 9 +-------- Test/Download/MP4.py | 2 ++ config.json | 3 +-- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/StreamingCommunity/Lib/Downloader/MP4/downloader.py b/StreamingCommunity/Lib/Downloader/MP4/downloader.py index 010fff7..f69c033 100644 --- a/StreamingCommunity/Lib/Downloader/MP4/downloader.py +++ b/StreamingCommunity/Lib/Downloader/MP4/downloader.py @@ -31,7 +31,6 @@ from ...FFmpeg import print_duration_table # Config REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify') -REQUEST_HTTP2 = config_manager.get_bool('REQUESTS', 'http2') GET_ONLY_LINK = config_manager.get_bool('M3U8_PARSER', 'get_only_link') REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout') TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') @@ -111,11 +110,12 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No interrupt_handler = InterruptHandler() original_handler = signal.signal(signal.SIGINT, partial(signal_handler, interrupt_handler=interrupt_handler, original_handler=signal.getsignal(signal.SIGINT))) + # Ensure the output directory exists + os.makedirs(os.path.dirname(path), exist_ok=True) + try: - transport = httpx.HTTPTransport(verify=REQUEST_VERIFY, http2=REQUEST_HTTP2) - - with httpx.Client(transport=transport, timeout=httpx.Timeout(60)) as client: - with client.stream("GET", url, headers=headers, timeout=REQUEST_TIMEOUT) as response: + with httpx.Client() as client: + with client.stream("GET", url, headers=headers) as response: response.raise_for_status() total = int(response.headers.get('content-length', 0)) @@ -123,6 +123,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No console.print("[bold red]No video stream found.[/bold red]") return None, False + # Create a fancy progress bar progress_bar = tqdm( total=total, ascii='░▒█', @@ -135,7 +136,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No unit_scale=True, desc='Downloading', mininterval=0.05, - file=sys.stdout # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment. + file=sys.stdout # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment. ) downloaded = 0 diff --git a/StreamingCommunity/Util/config_json.py b/StreamingCommunity/Util/config_json.py index cde8cc9..e770fd5 100644 --- a/StreamingCommunity/Util/config_json.py +++ b/StreamingCommunity/Util/config_json.py @@ -256,14 +256,7 @@ class ConfigManager: sites_info = [] for site, info in examples: sites_info.append(f"[cyan]{site}[/cyan]: {info.get('full_url', 'N/A')}") - - console.print("[bold cyan]Sample sites:[/bold cyan]") - for info in sites_info: - console.print(f" {info}") - - if site_count > 3: - console.print(f" ... and {site_count - 3} more") - + else: console.print("[bold yellow]API returned empty data set[/bold yellow]") else: diff --git a/Test/Download/MP4.py b/Test/Download/MP4.py index a48e5ca..f2bc65c 100644 --- a/Test/Download/MP4.py +++ b/Test/Download/MP4.py @@ -10,6 +10,8 @@ sys.path.append(src_path) # Import from StreamingCommunity.Util.message import start_message +from StreamingCommunity.Util.os import os_summary +os_summary.get_system_summary() from StreamingCommunity.Util.logger import Logger from StreamingCommunity.Lib.Downloader import MP4_downloader diff --git a/config.json b/config.json index e361fa1..475d25b 100644 --- a/config.json +++ b/config.json @@ -25,8 +25,7 @@ "REQUESTS": { "verify": false, "timeout": 20, - "max_retry": 8, - "http2": true + "max_retry": 8 }, "M3U8_DOWNLOAD": { "tqdm_delay": 0.01,