removed TUI and others
This commit is contained in:
@@ -13,7 +13,7 @@ from pathlib import Path
|
||||
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from ProviderCore.base import Provider, SearchResult
|
||||
from ProviderCore.base import Provider, SearchResult, parse_inline_query_arguments
|
||||
from SYS.provider_helpers import TableProviderMixin
|
||||
from SYS.logger import debug, log
|
||||
from SYS.models import DownloadError, DownloadMediaResult, DownloadOptions
|
||||
@@ -32,6 +32,7 @@ from tool.ytdlp import (
|
||||
_read_text_file,
|
||||
collapse_picker_formats,
|
||||
format_for_table_selection,
|
||||
get_display_format_id,
|
||||
get_selection_format_id,
|
||||
is_browseable_format,
|
||||
is_url_supported_by_ytdlp,
|
||||
@@ -357,6 +358,12 @@ def _format_id_for_query_index(
|
||||
return normalized or s_val
|
||||
|
||||
candidate_formats = collapse_picker_formats(fmts, video_audio_suffix="bestaudio")
|
||||
if s_val and not s_val.startswith("#"):
|
||||
for item in candidate_formats:
|
||||
if get_display_format_id(item) == s_val:
|
||||
normalized = get_selection_format_id(item, video_audio_suffix="bestaudio")
|
||||
return normalized or s_val
|
||||
|
||||
filtered_formats = candidate_formats if candidate_formats else list(fmts)
|
||||
if idx <= 0 or idx > len(filtered_formats):
|
||||
raise ValueError(f"Format index {idx} out of range")
|
||||
@@ -497,6 +504,10 @@ def _build_pipe_objects(
|
||||
class ytdlp(TableProviderMixin, Provider):
|
||||
"""yt-dlp-backed search and direct download plugin."""
|
||||
|
||||
PLUGIN_NAME = "ytdlp"
|
||||
PLUGIN_ALIASES = ("youtube",)
|
||||
SEARCH_QUERY_KEYS = ("search", "q")
|
||||
|
||||
@classmethod
|
||||
def url_patterns(cls) -> Tuple[str, ...]:
|
||||
try:
|
||||
@@ -529,10 +540,47 @@ class ytdlp(TableProviderMixin, Provider):
|
||||
|
||||
TABLE_AUTO_STAGES = {
|
||||
"ytdlp.formatlist": ["download-file"],
|
||||
"ytdlp.search": ["download-file"],
|
||||
"youtube": ["download-file"],
|
||||
}
|
||||
AUTO_STAGE_USE_SELECTION_ARGS = True
|
||||
|
||||
def extract_query_arguments(self, query: str) -> Tuple[str, Dict[str, Any]]:
|
||||
normalized_query, inline_args = parse_inline_query_arguments(query)
|
||||
search_parts: List[str] = []
|
||||
|
||||
for key in self.SEARCH_QUERY_KEYS:
|
||||
value = str(inline_args.pop(key, "") or "").strip()
|
||||
if value:
|
||||
search_parts.append(value)
|
||||
|
||||
if normalized_query:
|
||||
search_parts.append(normalized_query)
|
||||
|
||||
resolved_query = " ".join(part for part in search_parts if part).strip()
|
||||
if not resolved_query:
|
||||
resolved_query = str(query or "").strip()
|
||||
|
||||
filters: Dict[str, Any] = dict(inline_args or {})
|
||||
filters.setdefault("search_provider", "youtube")
|
||||
return resolved_query, filters
|
||||
|
||||
def get_table_type(
|
||||
self,
|
||||
query: str,
|
||||
filters: Optional[Dict[str, Any]] = None,
|
||||
) -> str:
|
||||
_ = query, filters
|
||||
return "youtube"
|
||||
|
||||
def get_table_title(
|
||||
self,
|
||||
query: str,
|
||||
filters: Optional[Dict[str, Any]] = None,
|
||||
) -> str:
|
||||
_ = filters
|
||||
q = str(query or "").strip() or "*"
|
||||
return f"YouTube: {q}"
|
||||
|
||||
def search(
|
||||
self,
|
||||
query: str,
|
||||
@@ -567,7 +615,7 @@ class ytdlp(TableProviderMixin, Provider):
|
||||
|
||||
results.append(
|
||||
SearchResult(
|
||||
table="ytdlp.search",
|
||||
table="youtube",
|
||||
title=title,
|
||||
path=url,
|
||||
detail=f"By: {uploader}",
|
||||
@@ -1443,11 +1491,11 @@ try:
|
||||
return ["-title", row.title or ""]
|
||||
|
||||
_register_table_plugin_once(
|
||||
"ytdlp.search",
|
||||
"youtube",
|
||||
_search_adapter,
|
||||
columns=_search_columns_factory,
|
||||
selection_fn=_search_selection_fn,
|
||||
metadata={"description": "ytdlp video search using yt-dlp"},
|
||||
metadata={"description": "YouTube search using yt-dlp"},
|
||||
)
|
||||
except Exception as exc:
|
||||
debug(f"[ytdlp] Provider registration note: {exc}")
|
||||
|
||||
Reference in New Issue
Block a user