Skip to content

Commit c85fb47

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

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

+3171
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.downloader.(common.)?FileDownloader.parse_bytes
15+
yt_dlp.networking.(common.)?Response.(code|info|get(code|url|header))
16+
yt_dlp.utils._legacy.decode_png
17+
# except IndexError is sufficient.
18+
yt_dlp.utils.(_utils.)?(PlaylistEntries|(Lazy|Paged)List).IndexError
19+
# Reports 'not a function'.
20+
yt_dlp.networking.(common.)?(HEAD|PATCH|PUT)Request

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

0 commit comments

Comments
 (0)