This commit is contained in:
2026-01-17 02:36:06 -08:00
parent 3a7c443004
commit c6fd6b4224
9 changed files with 440 additions and 226 deletions

View File

@@ -2,7 +2,7 @@
When a URL is passed through download-file, this provider displays available formats
in a table and routes format selection back to download-file with the chosen format
already specified via -format, skipping the format table on the second invocation.
already specified via -query "format:<id>", skipping the format table on the second invocation.
This keeps format selection logic in ytdlp and leaves add-file plug-and-play.
"""
@@ -31,8 +31,8 @@ class ytdlp(TableProviderMixin, Provider):
- User runs: download-file "https://example.com/video"
- If URL is ytdlp-supported and no format specified, displays format table
- User selects @N (e.g., @3 for format index 3)
- Selection args include -format <format_id>, re-invoking download-file
- Second download-file call sees -format and skips table, downloads directly
- Selection args include -query "format:<format_id>", re-invoking download-file
- Second download-file call sees the format query and skips the table, downloads directly
SEARCH USAGE:
- User runs: search-file -provider ytdlp "linux tutorial"
@@ -41,12 +41,12 @@ class ytdlp(TableProviderMixin, Provider):
- Selection args route to download-file for streaming download
SELECTION FLOW (Format):
1. download-file receives URL without -format
1. download-file receives URL without a format query
2. Calls ytdlp to list formats
3. Returns formats as ResultTable (from this provider)
4. User selects @N
5. Selection args: ["-format", "<format_id>"] route back to download-file
6. Second download-file invocation with -format skips table
5. Selection args: ["-query", "format:<format_id>"] route back to download-file
6. Second download-file invocation with format query skips table
SELECTION FLOW (Search):
1. search-file lists YouTube videos via yt_dlp
@@ -56,7 +56,7 @@ class ytdlp(TableProviderMixin, Provider):
5. download-file downloads the selected video
TABLE AUTO-STAGES:
- Format selection: ytdlp.formatlist -> download-file (with -format)
- Format selection: ytdlp.formatlist -> download-file (with -query format:<id>)
- Video search: ytdlp.search -> download-file (with -url)
SUPPORTED URLS:
@@ -106,7 +106,7 @@ class ytdlp(TableProviderMixin, Provider):
"ytdlp.formatlist": ["download-file"],
"ytdlp.search": ["download-file"],
}
# Forward selection args (including -format or -url) to the next stage
# Forward selection args (including -query format:... or -url) to the next stage
AUTO_STAGE_USE_SELECTION_ARGS = True
def search(
@@ -277,7 +277,7 @@ try:
"""Return selection args for format selection.
When user selects @N, these args are passed to download-file which sees
the -format specifier and skips the format table, downloading directly.
the format query and skips the format table, downloading directly.
"""
metadata = row.metadata or {}
@@ -291,7 +291,7 @@ try:
# Fallback: use format_id
format_id = metadata.get("format_id") or metadata.get("id")
if format_id:
result_args = ["-format", str(format_id)]
result_args = ["-query", f"format:{format_id}"]
debug(f"[ytdlp] Selection routed with format_id: {format_id}")
return result_args