This commit is contained in:
2026-01-27 14:56:01 -08:00
parent 334841dcfa
commit a44b80fd1d
7 changed files with 253 additions and 109 deletions

View File

@@ -1063,28 +1063,6 @@ class Download_File(Cmdlet):
return selection_format_id
@staticmethod
def _format_selector_for_query_height(query_format: str) -> Optional[str]:
import re
if query_format is None:
return None
s = str(query_format).strip().lower()
m = re.match(r"^(\d{2,5})p$", s)
if not m:
return None
try:
height = int(m.group(1))
except Exception:
return None
if height <= 0:
raise ValueError(f"Invalid height selection: {query_format}")
return f"bv*[height<={height}]+ba"
@staticmethod
def _canonicalize_url_for_storage(*, requested_url: str, ytdlp_tool: YtDlpTool, playlist_items: Optional[str]) -> str:
if playlist_items:
@@ -1929,7 +1907,7 @@ class Download_File(Cmdlet):
query_format = str(fmt_candidate).strip()
except Exception:
query_format = None
query_audio: Optional[bool] = None
try:
audio_values = query_keyed.get("audio", []) if isinstance(query_keyed, dict) else []
@@ -1980,20 +1958,20 @@ class Download_File(Cmdlet):
formats_cache: Dict[str, Optional[List[Dict[str, Any]]]] = {}
playlist_items = str(parsed.get("item")) if parsed.get("item") else None
ytdl_format = None
height_selector = None
if query_format and not query_wants_audio:
try:
height_selector = self._format_selector_for_query_height(query_format)
except ValueError as e:
log(f"Error parsing format selection: {e}", file=sys.stderr)
return 1
height_selector = ytdlp_tool.resolve_height_selector(query_format)
except Exception:
height_selector = None
if height_selector:
ytdl_format = height_selector
else:
import re
if height_selector:
ytdl_format = height_selector
else:
import re
if not re.match(r"^\s*#?\d+\s*$", str(query_format)):
ytdl_format = query_format
if not re.match(r"^\s*#?\d+\s*$", str(query_format)):
ytdl_format = query_format
debug(f"DEBUG: [download-file] Using literal query_format '{query_format}' as ytdl_format")
playlist_selection_handled = False
if len(supported_url) == 1 and not playlist_items:
@@ -2594,8 +2572,7 @@ class Download_File(Cmdlet):
self,
result: Any,
args: Sequence[str],
config: Dict[str,
Any]
config: Dict[str, Any]
) -> int:
"""Main download implementation for direct HTTP files."""
progress = PipelineProgress(pipeline_context)