Skip to content

Commit 9386a7d

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

Some content is hidden

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

55 files changed

+3269
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
6+
# These are deprecated.
7+
yt_dlp.compat.compat_b64decode
8+
yt_dlp.compat.compat_os_name
9+
yt_dlp.compat.compat_parse_qs
10+
yt_dlp.compat.compat_realpath
11+
yt_dlp.compat.compat_shlex_quote
12+
yt_dlp.compat.compat_str
13+
yt_dlp.compat.compat_urllib_parse_unquote
14+
yt_dlp.compat.compat_urllib_parse_urlencode
15+
yt_dlp.compat.compat_urllib_parse_urlparse
16+
yt_dlp.compat.compat_urlparse
17+
yt_dlp.compat.functools
18+
yt_dlp.utils.bytes_to_intlist
19+
yt_dlp.utils.compiled_regex_type
20+
yt_dlp.utils.decodeArgument
21+
yt_dlp.utils.decodeFilename
22+
yt_dlp.utils.decodeOption
23+
yt_dlp.utils.encodeFilename
24+
yt_dlp.utils.error_to_compat_str
25+
yt_dlp.utils.intlist_to_bytes
26+
27+
# Won't be covered.
28+
yt_dlp.__main__
29+
yt_dlp.__pyinstaller.*

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

stubs/yt-dlp/yt_dlp/__init__.pyi

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
import optparse
2+
from collections.abc import Callable, Collection, Iterator, Mapping
3+
from typing import Literal, NamedTuple, TypedDict, type_check_only
4+
from typing_extensions import NotRequired
5+
6+
from ._misc import _LoggerProtocol
7+
from .networking.impersonate import ImpersonateTarget
8+
from .YoutubeDL import YoutubeDL
9+
10+
__all__ = ("YoutubeDL", "parse_options")
11+
12+
@type_check_only
13+
class _RetrySleepFunctions(TypedDict):
14+
default: NotRequired[Callable[[int], int]]
15+
file_access: NotRequired[Callable[[int], int]]
16+
fragment: NotRequired[Callable[[int], int]]
17+
18+
@type_check_only
19+
class _ProgressTemplateValue(TypedDict): # noqa: Y049
20+
info: NotRequired[str]
21+
progress: NotRequired[str]
22+
23+
@type_check_only
24+
class _ExternalDownloader(TypedDict):
25+
dash: NotRequired[str]
26+
default: NotRequired[str]
27+
ftp: NotRequired[str]
28+
http: NotRequired[str]
29+
m3u8: NotRequired[str]
30+
mms: NotRequired[str]
31+
rtmp: NotRequired[str]
32+
rtsp: NotRequired[str]
33+
34+
@type_check_only
35+
class _DownloadRange(TypedDict):
36+
end_time: int
37+
index: NotRequired[int]
38+
start_time: int
39+
title: NotRequired[str]
40+
41+
@type_check_only
42+
class _Color(TypedDict):
43+
stderr: NotRequired[Literal["always", "auto", "no_color", "never"]]
44+
stdout: NotRequired[Literal["always", "auto", "no_color", "never"]]
45+
46+
_ProgressTemplate = TypedDict(
47+
"_ProgressTemplate",
48+
{
49+
"download": _ProgressTemplateValue,
50+
"download-title": _ProgressTemplateValue,
51+
"postprocess": _ProgressTemplateValue,
52+
"postprocess-title": _ProgressTemplateValue,
53+
},
54+
)
55+
56+
@type_check_only
57+
class _Params(TypedDict):
58+
usenetrc: NotRequired[bool | None]
59+
netrc_location: NotRequired[str | None]
60+
netrc_cmd: NotRequired[str | None]
61+
username: NotRequired[str | None]
62+
password: NotRequired[str | None]
63+
twofactor: NotRequired[str | None]
64+
videopassword: NotRequired[str | None]
65+
ap_mso: NotRequired[str | None]
66+
ap_username: NotRequired[str | None]
67+
ap_password: NotRequired[str | None]
68+
client_certificate: NotRequired[str | None]
69+
client_certificate_key: NotRequired[str | None]
70+
client_certificate_password: NotRequired[str | None]
71+
quiet: NotRequired[bool | None]
72+
no_warnings: NotRequired[bool | None]
73+
forceurl: NotRequired[bool | None]
74+
forcetitle: NotRequired[str | None]
75+
forceid: NotRequired[bool | None]
76+
forcethumbnail: NotRequired[bool | None]
77+
forcedescription: NotRequired[bool | None]
78+
forceduration: NotRequired[str | None]
79+
forcefilename: NotRequired[bool | None]
80+
forceprint: NotRequired[Mapping[str, Collection[str]] | Collection[str] | None]
81+
print_to_file: NotRequired[Mapping[str, tuple[str, str]] | None]
82+
forcejson: NotRequired[bool | None]
83+
dump_single_json: NotRequired[bool | None]
84+
force_write_download_archive: NotRequired[str | None]
85+
simulate: NotRequired[str | None]
86+
skip_download: NotRequired[str | None]
87+
format: NotRequired[str | Callable[[Mapping[str, object]], Mapping[str, object]] | None]
88+
allow_unplayable_formats: NotRequired[bool | None]
89+
ignore_no_formats_error: NotRequired[bool | None]
90+
format_sort: NotRequired[Collection[str] | None]
91+
format_sort_force: NotRequired[str | None]
92+
allow_multiple_video_streams: NotRequired[bool | None]
93+
allow_multiple_audio_streams: NotRequired[bool | None]
94+
check_formats: NotRequired[bool | Literal["selected"] | None]
95+
listformats: NotRequired[bool | None]
96+
outtmpl: NotRequired[str | Mapping[str, str] | None]
97+
outtmpl_na_placeholder: NotRequired[str | None]
98+
paths: NotRequired[str | None]
99+
restrictfilenames: NotRequired[bool | None]
100+
windowsfilenames: NotRequired[bool | None]
101+
ignoreerrors: NotRequired[bool | Literal["only_download"] | None]
102+
force_generic_extractor: NotRequired[bool | None]
103+
allowed_extractors: NotRequired[Collection[str] | None]
104+
ratelimit: NotRequired[int | None]
105+
throttledratelimit: NotRequired[int | None]
106+
overwrites: NotRequired[bool | None]
107+
retries: NotRequired[int | None]
108+
file_access_retries: NotRequired[int | None]
109+
fragment_retries: NotRequired[int | None]
110+
extractor_retries: NotRequired[int | None]
111+
retry_sleep_functions: NotRequired[_RetrySleepFunctions | None]
112+
skip_unavailable_fragments: NotRequired[bool | None]
113+
keep_fragments: NotRequired[bool | None]
114+
concurrent_fragment_downloads: NotRequired[int | None]
115+
buffersize: NotRequired[int | None]
116+
noresizebuffer: NotRequired[bool | None]
117+
http_chunk_size: NotRequired[int | None]
118+
continuedl: NotRequired[bool | None]
119+
noprogress: NotRequired[bool | None]
120+
progress_with_newline: NotRequired[bool | None]
121+
progress_template: NotRequired[_ProgressTemplate | None]
122+
playliststart: NotRequired[int | None]
123+
playlistend: NotRequired[int | None]
124+
playlistreverse: NotRequired[bool | None]
125+
playlistrandom: NotRequired[bool | None]
126+
lazy_playlist: NotRequired[bool | None]
127+
noplaylist: NotRequired[bool | None]
128+
logtostderr: NotRequired[bool | None]
129+
consoletitle: NotRequired[str | None]
130+
nopart: NotRequired[bool | None]
131+
updatetime: NotRequired[bool | None]
132+
writedescription: NotRequired[bool | None]
133+
writeannotations: NotRequired[bool | None]
134+
writeinfojson: NotRequired[bool | None]
135+
allow_playlist_files: NotRequired[bool | None]
136+
clean_infojson: NotRequired[bool | None]
137+
getcomments: NotRequired[bool | None]
138+
writethumbnail: NotRequired[bool | None]
139+
write_all_thumbnails: NotRequired[bool | None]
140+
writelink: NotRequired[bool | None]
141+
writeurllink: NotRequired[bool | None]
142+
writewebloclink: NotRequired[bool | None]
143+
writedesktoplink: NotRequired[bool | None]
144+
writesubtitles: NotRequired[bool | None]
145+
writeautomaticsub: NotRequired[bool | None]
146+
allsubtitles: NotRequired[bool | None]
147+
listsubtitles: NotRequired[bool | None]
148+
subtitlesformat: NotRequired[str | None]
149+
subtitleslangs: NotRequired[Collection[str] | None]
150+
matchtitle: NotRequired[bool | None]
151+
rejecttitle: NotRequired[bool | None]
152+
prefer_free_formats: NotRequired[bool | None]
153+
trim_file_name: NotRequired[int | None]
154+
verbose: NotRequired[bool | None]
155+
test: NotRequired[bool | None]
156+
keepvideo: NotRequired[str | None]
157+
min_filesize: NotRequired[int | None]
158+
max_filesize: NotRequired[int | None]
159+
min_views: NotRequired[str | None]
160+
max_views: NotRequired[str | None]
161+
daterange: NotRequired[str | None]
162+
cachedir: NotRequired[str | None]
163+
age_limit: NotRequired[str | None]
164+
download_archive: NotRequired[str | None]
165+
break_on_existing: NotRequired[str | None]
166+
break_on_reject: NotRequired[bool | None]
167+
break_per_url: NotRequired[bool | None]
168+
skip_playlist_after_errors: NotRequired[bool | None]
169+
cookiefile: NotRequired[str | None]
170+
cookiesfrombrowser: NotRequired[tuple[str, ...] | None]
171+
legacyserverconnect: NotRequired[bool | None]
172+
nocheckcertificate: NotRequired[bool | None]
173+
prefer_insecure: NotRequired[str | None]
174+
enable_file_urls: NotRequired[str | None]
175+
http_headers: NotRequired[Mapping[str, str] | None]
176+
proxy: NotRequired[str | None]
177+
socket_timeout: NotRequired[int | None]
178+
bidi_workaround: NotRequired[bool | None]
179+
debug_printtraffic: NotRequired[bool | None]
180+
prefer_ffmpeg: NotRequired[bool | None]
181+
include_ads: NotRequired[bool | None]
182+
default_search: NotRequired[str | None]
183+
dynamic_mpd: NotRequired[bool | None]
184+
extractor_args: NotRequired[Mapping[str, Mapping[str, object]] | None]
185+
youtube_include_dash_manifest: NotRequired[bool | None]
186+
youtube_include_hls_manifest: NotRequired[bool | None]
187+
encoding: NotRequired[str | None]
188+
extract_flat: NotRequired[bool | Literal["in_playlist", "discard", "discard_in_playlist"] | None]
189+
live_from_start: NotRequired[bool | None]
190+
wait_for_video: NotRequired[tuple[int, int] | None]
191+
mark_watched: NotRequired[bool | None]
192+
merge_output_format: NotRequired[str | None]
193+
final_ext: NotRequired[str | None]
194+
postprocessors: NotRequired[Collection[Mapping[str, object]]]
195+
fixup: NotRequired[Literal["never", "warn", "detect_or_warn"] | None]
196+
source_address: NotRequired[str | None]
197+
call_home: NotRequired[bool | None]
198+
sleep_interval_requests: NotRequired[int | None]
199+
sleep_interval: NotRequired[int | None]
200+
max_sleep_interval: NotRequired[int | None]
201+
sleep_interval_subtitles: NotRequired[int | None]
202+
external_downloader: NotRequired[_ExternalDownloader | None]
203+
download_ranges: NotRequired[Callable[[object, YoutubeDL], Iterator[_DownloadRange]] | None]
204+
force_keyframes_at_cuts: NotRequired[bool | None]
205+
list_thumbnails: NotRequired[str | None]
206+
playlist_items: NotRequired[Collection[int] | None]
207+
xattr_set_filesize: NotRequired[bool | None]
208+
match_filter: NotRequired[
209+
Callable[[Mapping[str, object], bool], str | None] | Callable[[Mapping[str, object]], str | None] | None
210+
]
211+
color: NotRequired[_Color | None]
212+
ffmpeg_location: NotRequired[str | None]
213+
hls_prefer_native: NotRequired[bool | None]
214+
hls_use_mpegts: NotRequired[bool | None]
215+
hls_split_discontinuity: NotRequired[bool | None]
216+
max_downloads: NotRequired[int | None]
217+
dump_intermediate_pages: NotRequired[bool | None]
218+
listformats_table: NotRequired[bool | None]
219+
write_pages: NotRequired[bool | None]
220+
external_downloader_args: NotRequired[Literal["default"] | Mapping[str, Collection[str]] | Collection[str] | None]
221+
postprocessor_args: NotRequired[Mapping[str, Collection[str]] | Collection[str] | None]
222+
geo_verification_proxy: NotRequired[str | None]
223+
geo_bypass: NotRequired[bool | None]
224+
geo_bypass_country: NotRequired[str | None]
225+
geo_bypass_ip_block: NotRequired[str | None]
226+
compat_opts: NotRequired[dict[str, object] | None]
227+
# Undocumented fields below.
228+
_deprecation_warnings: NotRequired[Collection[str] | None]
229+
_warnings: NotRequired[Collection[str] | None]
230+
autonumber_size: NotRequired[int | None]
231+
autonumber_start: NotRequired[int | None]
232+
cn_verification_proxy: NotRequired[str | None]
233+
forceformat: NotRequired[object]
234+
load_pages: NotRequired[bool | None]
235+
logger: NotRequired[_LoggerProtocol]
236+
youtube_print_sig_code: NotRequired[bool | None]
237+
progress_hooks: NotRequired[list[Callable[[object], object]]]
238+
impersonate: NotRequired[ImpersonateTarget]
239+
240+
@type_check_only
241+
class _ParsedOptions(NamedTuple):
242+
parser: object
243+
options: optparse.Values
244+
urls: Collection[str]
245+
ydl_opts: _Params
246+
247+
def parse_options(argv: Collection[str] | None = ...) -> _ParsedOptions: ...

0 commit comments

Comments
 (0)