mp4: Fix error 'set_alpn_protocols'

(cherry picked from commit ab094d0b1db21e74b8af4b5b995779dfd88ce3db)
This commit is contained in:
Lovi 2025-03-16 14:27:23 +01:00 committed by RubyTemple
parent 587db0cd0b
commit 47c12dbb15
4 changed files with 11 additions and 16 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -25,8 +25,7 @@
"REQUESTS": {
"verify": false,
"timeout": 20,
"max_retry": 8,
"http2": true
"max_retry": 8
},
"M3U8_DOWNLOAD": {
"tqdm_delay": 0.01,