Skip to content

Commit d61f3aa

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

18 files changed

+835
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Extractors do not need to be stubbed.
2+
yt_dlp.extractor.*
3+
4+
# Incomplete
5+
yt_dlp.__main__
6+
yt_dlp.__pyinstaller.*
7+
yt_dlp.aes
8+
yt_dlp.cache
9+
yt_dlp.compat.*
10+
yt_dlp.dependencies.*
11+
yt_dlp.downloader.*
12+
yt_dlp.globals
13+
yt_dlp.jsinterp
14+
yt_dlp.networking._curlcffi
15+
yt_dlp.networking._requests
16+
yt_dlp.networking._urllib
17+
yt_dlp.networking._websockets
18+
yt_dlp.options
19+
yt_dlp.plugins
20+
yt_dlp.postprocessor.*
21+
yt_dlp.socks
22+
yt_dlp.update
23+
yt_dlp.utils._deprecated
24+
yt_dlp.utils._legacy
25+
yt_dlp.utils.progress
26+
yt_dlp.utils.traversal
27+
yt_dlp.version
28+
yt_dlp.webvtt

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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from collections.abc import Collection
2+
from typing_extensions import Self
3+
4+
from . import YDLOpts
5+
from .extractor.common import InfoExtractor
6+
7+
__all__ = ("YoutubeDL",)
8+
9+
class YoutubeDL:
10+
def __init__(self, options: YDLOpts) -> None: ...
11+
def __enter__(self) -> Self: ...
12+
def __exit__(self, *args: object) -> None: ...
13+
def download(self, urls: Collection[str]) -> None: ...
14+
def add_info_extractor(self, ie: InfoExtractor) -> None: ...
15+
def extract_info(self, url: str) -> dict[str, object]: ...

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 YDLOpts(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: YDLOpts
246+
247+
def parse_options(argv: Collection[str] | None = ...) -> _ParsedOptions: ...

stubs/yt-dlp/yt_dlp/_misc.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Protocol, type_check_only
2+
3+
from .YoutubeDL import YoutubeDL
4+
5+
@type_check_only
6+
class _LoggerProtocol(Protocol): # noqa: Y046
7+
def __init__(self, ydl: YoutubeDL | None = None) -> None: ...
8+
def debug(self, message: str) -> None: ...
9+
def info(self, message: str) -> None: ...
10+
def warning(self, message: str, *, once: bool = ..., only_once: bool = ...) -> None: ...
11+
def error(self, message: str) -> None: ...
12+
def stdout(self, message: str) -> None: ...
13+
def stderr(self, message: str) -> None: ...

stubs/yt-dlp/yt_dlp/cookies.pyi

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from collections.abc import Iterator
2+
from enum import Enum
3+
from http.cookiejar import Cookie, MozillaCookieJar
4+
from http.cookies import SimpleCookie
5+
from typing import TextIO
6+
7+
from ._misc import _LoggerProtocol
8+
from .minicurses import MultilinePrinter
9+
from .YoutubeDL import YoutubeDL
10+
11+
CHROMIUM_BASED_BROWSERS: set[str] = ...
12+
SUPPORTED_BROWSERS: set[str] = ...
13+
14+
class _LinuxKeyring(Enum):
15+
BASICTEXT = ...
16+
GNOMEKEYRING = ...
17+
KWALLET4 = ...
18+
KWALLET5 = ...
19+
KWALLET6 = ...
20+
21+
class YDLLogger(_LoggerProtocol):
22+
class ProgressBar(MultilinePrinter): ...
23+
24+
def progress_bar(self) -> ProgressBar: ...
25+
26+
class YoutubeDLCookieJar(MozillaCookieJar):
27+
def __init__(self, filename: str | None = ..., *args: object, **kwargs: object) -> None: ...
28+
def open(self, file: str, *, write: bool = ...) -> Iterator[TextIO]: ...
29+
def get_cookie_header(self, url: str) -> str: ...
30+
def get_cookies_for_url(self, url: str) -> list[Cookie]: ...
31+
32+
def load_cookies(cookie_file: str, browser_specification: str | None, ydl: YoutubeDL) -> YoutubeDLCookieJar: ...
33+
def extract_cookies_from_browser(
34+
browser: str,
35+
profile: str | None = ...,
36+
logger: _LoggerProtocol = ...,
37+
*,
38+
keyring: _LinuxKeyring | None = ...,
39+
container: str | None = ...,
40+
) -> YoutubeDLCookieJar: ...
41+
42+
class ChromeCookieDecryptor:
43+
def decrypt(self, encrypted_value: bytes) -> str: ...
44+
45+
class LinuxChromeCookieDecryptor(ChromeCookieDecryptor):
46+
def __init__(
47+
self,
48+
browser_keyring_name: str,
49+
logger: _LoggerProtocol,
50+
*,
51+
keyring: _LinuxKeyring | None = ...,
52+
meta_version: int | None = ...,
53+
) -> None: ...
54+
@staticmethod
55+
def derive_key(password: bytes) -> bytes: ...
56+
57+
class MacChromeCookieDecryptor(ChromeCookieDecryptor):
58+
@staticmethod
59+
def derive_key(password: bytes) -> bytes: ...
60+
61+
class WindowsChromeCookieDecryptor(ChromeCookieDecryptor):
62+
@staticmethod
63+
def derive_key(password: bytes) -> bytes: ...
64+
65+
def get_cookie_decryptor(
66+
browser_root: object,
67+
browser_keyring_name: str,
68+
logger: _LoggerProtocol,
69+
*,
70+
keyring: _LinuxKeyring | None = ...,
71+
meta_version: int | None = ...,
72+
) -> ChromeCookieDecryptor: ...
73+
74+
class ParserError(Exception): ...
75+
class DataParser: ...
76+
77+
def pbkdf2_sha1(password: bytes, salt: bytes, iterations: int, key_length: int) -> bytes: ...
78+
79+
class LenientSimpleCookie(SimpleCookie): ...

stubs/yt-dlp/yt_dlp/extractor/__init__.pyi

Whitespace-only changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy