Skip to content

Commit dbb88ac

Browse files
committed
Add yt-dlp stubs
1 parent a46eea7 commit dbb88ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3407
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Extractors do not need to be stubbed.
2+
yt_dlp.extractor.*
3+
# Postprocessors will not be stubbed at this time.
4+
yt_dlp.postprocessor.*
5+
# Won't be covered.
6+
yt_dlp.__main__
7+
yt_dlp.__pyinstaller.*
8+
yt_dlp.compat.(shutil|types|urllib).*
9+
yt_dlp.dependencies.*
10+
yt_dlp.jsinterp.Debugger.sys
11+
yt_dlp.networking.impersonate.ImpersonateTarget._DT
12+
yt_dlp.utils.xattr
13+
# Deprecated
14+
yt_dlp.YoutubeDL.(YoutubeDL.)?parse_outtmpl
15+
yt_dlp.downloader.(common.)?FileDownloader.parse_bytes
16+
yt_dlp.networking.(common.)?Response.(code|info|get(code|url|header))
17+
yt_dlp.utils._legacy.decode_png
18+
# except IndexError is sufficient.
19+
yt_dlp.utils.(_utils.)?(PlaylistEntries|(Lazy|Paged)List).IndexError
20+
# Reports 'not a function'.
21+
yt_dlp.networking.(common.)?(HEAD|PATCH|PUT)Request
22+
# This is partially typed.
23+
yt_dlp.utils.(_utils.)?is_iterable_like
24+
# Generated with functools.partial.
25+
yt_dlp.utils.(_utils.)?prepend_extension
26+
yt_dlp.utils.(_utils.)?replace_extension

stubs/yt-dlp/METADATA.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version = "2025.05.*"
2+
upstream_repository = "https://github.com/yt-dlp/yt-dlp"

stubs/yt-dlp/yt_dlp/YoutubeDL.pyi

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
from collections.abc import Callable, Collection, Iterable, Iterator, Mapping
2+
from functools import cached_property
3+
from types import TracebackType
4+
from typing_extensions import Self, TypeAlias
5+
from urllib.request import Request
6+
7+
from yt_dlp.cache import Cache
8+
from yt_dlp.cookies import YoutubeDLCookieJar
9+
from yt_dlp.networking import RequestDirector, RequestHandler, Response
10+
from yt_dlp.utils import Namespace
11+
12+
from . import _Params
13+
from .extractor.common import InfoExtractor, _InfoDict
14+
from .postprocessor.common import PostProcessor
15+
from .utils._utils import _ProgressState
16+
17+
_FormatSelector: TypeAlias = Callable[[Mapping[str, object]], Iterator[object]]
18+
19+
class YoutubeDL:
20+
params: _Params
21+
cache: Cache
22+
format_selector: _FormatSelector
23+
archive: set[str]
24+
def __init__(self, params: _Params | None = ..., auto_init: bool = ...) -> None: ...
25+
def warn_if_short_id(self, argv: list[str]) -> None: ...
26+
def add_info_extractor(self, ie: InfoExtractor) -> None: ...
27+
def get_info_extractor(self, ie_key: str) -> InfoExtractor: ...
28+
def add_default_info_extractors(self) -> None: ...
29+
def add_post_processor(self, pp: PostProcessor, when: str = "post_process") -> None: ...
30+
def add_post_hook(self, ph: Callable[..., object]) -> None: ...
31+
def add_close_hook(self, ch: Callable[..., object]) -> None: ...
32+
def add_progress_hook(self, ph: Callable[..., object]) -> None: ...
33+
def add_postprocessor_hook(self, ph: Callable[..., object]) -> None: ...
34+
def to_stdout(self, message: str, skip_eol: bool = False, quiet: bool | None = None) -> None: ...
35+
def to_screen(self, message: str, skip_eol: bool = False, quiet: bool | None = None, only_once: bool = False) -> None: ...
36+
def to_stderr(self, message: str, only_once: bool = False) -> None: ...
37+
def to_console_title(
38+
self, message: str | None = None, progress_state: _ProgressState | None = None, percent: int | None = None
39+
) -> None: ...
40+
def save_console_title(self) -> None: ...
41+
def restore_console_title(self) -> None: ...
42+
def __enter__(self) -> Self: ...
43+
def save_cookies(self) -> None: ...
44+
def __exit__(self, *args: object) -> None: ...
45+
def close(self) -> None: ...
46+
def trouble(self, message: str | None = None, tb: TracebackType | None = None, is_error: bool = True) -> None: ...
47+
Styles: Namespace
48+
def report_warning(self, message: str, only_once: bool = False) -> None: ...
49+
def deprecation_warning(self, message: str, *, stacklevel: int = 0) -> None: ...
50+
def deprecated_feature(self, message: str) -> None: ...
51+
def report_error(self, message: str, *args: object, **kwargs: object) -> None: ...
52+
def write_debug(self, message: str, only_once: bool = False) -> None: ...
53+
def report_file_already_downloaded(self, file_name: str) -> None: ...
54+
def report_file_delete(self, file_name: str) -> None: ...
55+
def raise_no_formats(self, info: str, forced: bool = False, *, msg: str | None = None) -> None: ...
56+
def get_output_path(self, dir_type: str = "", filename: str | None = None) -> str: ...
57+
@staticmethod
58+
def escape_outtmpl(outtmpl: str) -> str: ...
59+
@classmethod
60+
def validate_outtmpl(cls, outtmpl: str) -> ValueError | None: ...
61+
def prepare_outtmpl(self, outtmpl: str, info_dict: _InfoDict, sanitize: bool = False) -> tuple[str, dict[str, object]]: ...
62+
def evaluate_outtmpl(self, outtmpl: str, info_dict: _InfoDict, *args: object, **kwargs: object) -> str: ...
63+
def prepare_filename(
64+
self, info_dict: _InfoDict, dir_type: str = "", *, outtmpl: str | None = None, warn: bool = False
65+
) -> str: ...
66+
@staticmethod
67+
def add_extra_info(info_dict: _InfoDict, extra_info: Mapping[str, object]) -> None: ...
68+
def extract_info(
69+
self,
70+
url: str,
71+
download: bool = True,
72+
ie_key: str | None = None,
73+
extra_info: object | None = None,
74+
process: bool = True,
75+
force_generic_extractor: bool = False,
76+
) -> _InfoDict: ...
77+
def add_default_extra_info(self, ie_result: _InfoDict, ie: InfoExtractor, url: str) -> None: ...
78+
def process_ie_result(
79+
self, ie_result: _InfoDict, download: bool = True, extra_info: Mapping[str, object] | None = None
80+
) -> _InfoDict: ...
81+
def build_format_selector(self, format_spec: str) -> _FormatSelector: ...
82+
def sort_formats(self, info_dict: _InfoDict) -> None: ...
83+
def process_video_result(self, info_dict: _InfoDict, download: bool = True) -> _InfoDict: ...
84+
def process_subtitles(
85+
self, video_id: str, normal_subtitles: Mapping[str, object], automatic_captions: Mapping[str, object]
86+
) -> dict[str, object] | None: ...
87+
def dl(self, name: str, info: _InfoDict, subtitle: bool = False, test: bool = False) -> bool: ...
88+
def existing_file(self, filepaths: Iterable[str], *, default_overwrite: bool = True) -> object | None: ...
89+
def process_info(self, info_dict: _InfoDict) -> None: ...
90+
def download(self, url_list: Collection[str]) -> None: ...
91+
def download_with_info_file(self, info_filename: str) -> int: ...
92+
@staticmethod
93+
def sanitize_info(info_dict: _InfoDict, remove_private_keys: bool = False) -> _InfoDict | None: ...
94+
@staticmethod
95+
def filter_requested_info(info_dict: _InfoDict, actually_filter: bool = True) -> _InfoDict | None: ...
96+
@staticmethod
97+
def post_extract(info_dict: _InfoDict) -> None: ...
98+
def run_pp(self, pp: PostProcessor, infodict: _InfoDict) -> _InfoDict: ...
99+
def run_all_pps(self, key: str, info: _InfoDict, *, additional_pps: Collection[PostProcessor] | None = None) -> _InfoDict: ...
100+
def pre_process(
101+
self, ie_info: _InfoDict, key: str = "pre_process", files_to_move: Mapping[str, object] | None = None
102+
) -> tuple[_InfoDict, list[str] | None]: ...
103+
def post_process(self, filename: str, info: _InfoDict, files_to_move: Mapping[str, object] | None = None) -> _InfoDict: ...
104+
def in_download_archive(self, info_dict: _InfoDict) -> bool: ...
105+
def record_download_archive(self, info_dict: _InfoDict) -> None: ...
106+
@staticmethod
107+
def format_resolution(format: Mapping[str, object], default: str = "unknown") -> str: ...
108+
def render_formats_table(self, info_dict: _InfoDict) -> str | None: ...
109+
def render_thumbnails_table(self, info_dict: _InfoDict) -> str | None: ...
110+
def render_subtitles_table(self, video_id: str, subtitles: Iterable[Mapping[str, object]]) -> str | None: ...
111+
def list_formats(self, info_dict: _InfoDict) -> None: ...
112+
def list_thumbnails(self, info_dict: _InfoDict) -> None: ...
113+
def list_subtitles(self, video_id: str, subtitles: Iterable[Mapping[str, object]], name: str = "subtitles") -> None: ...
114+
def print_debug_header(self) -> None: ...
115+
@cached_property
116+
def proxies(self) -> dict[str, object]: ...
117+
@cached_property
118+
def cookiejar(self) -> YoutubeDLCookieJar: ...
119+
def urlopen(self, req: Request | str) -> Response: ...
120+
def build_request_director(
121+
self, handlers: Collection[RequestHandler], preferences: Collection[object] | None = None
122+
) -> RequestDirector: ...
123+
def encode(self, s: str) -> bytes: ...
124+
def get_encoding(self) -> str: ...

0 commit comments

Comments
 (0)