yt-dlp-utils 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of yt-dlp-utils might be problematic. Click here for more details.
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/PKG-INFO +10 -9
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/README.md +9 -8
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/pyproject.toml +1 -1
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/yt_dlp_utils/__init__.py +1 -1
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/yt_dlp_utils/lib.py +25 -8
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/LICENSE.txt +0 -0
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/yt_dlp_utils/constants.py +0 -0
- {yt_dlp_utils-0.0.2 → yt_dlp_utils-0.0.3}/yt_dlp_utils/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: yt-dlp-utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Utilities for programmatic use of yt-dlp.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: command line,yt-dlp
|
|
@@ -27,24 +27,25 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
# yt-dlp-utils
|
|
29
29
|
|
|
30
|
+
[](https://www.python.org/)
|
|
31
|
+
[](https://pypi.org/project/yt-dlp-utils/)
|
|
32
|
+
[](https://github.com/Tatsh/yt-dlp-utils/tags)
|
|
33
|
+
[](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
|
|
34
|
+
[](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.3...master)
|
|
30
35
|
[](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/qa.yml)
|
|
31
36
|
[](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/tests.yml)
|
|
32
37
|
[](https://coveralls.io/github/Tatsh/yt-dlp-utils?branch=master)
|
|
33
38
|
[](https://yt-dlp-utils.readthedocs.org/?badge=latest)
|
|
34
|
-
[](https://pypi.org/project/yt-dlp-utils/)
|
|
35
|
-
[](https://github.com/Tatsh/yt-dlp-utils/tags)
|
|
36
|
-
[](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
|
|
37
|
-
[](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.2...master)
|
|
38
|
-

|
|
39
39
|
[](http://mypy-lang.org/)
|
|
40
40
|
[](https://github.com/pre-commit/pre-commit)
|
|
41
41
|
[](http://www.pydocstyle.org/en/stable/)
|
|
42
42
|
[](https://docs.pytest.org/en/stable/)
|
|
43
|
-
[](https://www.python.org)
|
|
44
43
|
[](https://github.com/astral-sh/ruff)
|
|
44
|
+
[](https://pepy.tech/project/yt-dlp-utils)
|
|
45
|
+
[](https://github.com/Tatsh/yt-dlp-utils/stargazers)
|
|
45
46
|
|
|
46
|
-
[](https://bsky.app/profile/
|
|
47
|
-
[](https://hostux.social/@
|
|
47
|
+
[](https://bsky.app/profile/Tatsh.bsky.social)
|
|
48
|
+
[](https://hostux.social/@Tatsh)
|
|
48
49
|
|
|
49
50
|
Utilities for programmatic use of yt-dlp.
|
|
50
51
|
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
# yt-dlp-utils
|
|
2
2
|
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](https://pypi.org/project/yt-dlp-utils/)
|
|
5
|
+
[](https://github.com/Tatsh/yt-dlp-utils/tags)
|
|
6
|
+
[](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
|
|
7
|
+
[](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.3...master)
|
|
3
8
|
[](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/qa.yml)
|
|
4
9
|
[](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/tests.yml)
|
|
5
10
|
[](https://coveralls.io/github/Tatsh/yt-dlp-utils?branch=master)
|
|
6
11
|
[](https://yt-dlp-utils.readthedocs.org/?badge=latest)
|
|
7
|
-
[](https://pypi.org/project/yt-dlp-utils/)
|
|
8
|
-
[](https://github.com/Tatsh/yt-dlp-utils/tags)
|
|
9
|
-
[](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
|
|
10
|
-
[](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.2...master)
|
|
11
|
-

|
|
12
12
|
[](http://mypy-lang.org/)
|
|
13
13
|
[](https://github.com/pre-commit/pre-commit)
|
|
14
14
|
[](http://www.pydocstyle.org/en/stable/)
|
|
15
15
|
[](https://docs.pytest.org/en/stable/)
|
|
16
|
-
[](https://www.python.org)
|
|
17
16
|
[](https://github.com/astral-sh/ruff)
|
|
17
|
+
[](https://pepy.tech/project/yt-dlp-utils)
|
|
18
|
+
[](https://github.com/Tatsh/yt-dlp-utils/stargazers)
|
|
18
19
|
|
|
19
|
-
[](https://bsky.app/profile/
|
|
20
|
-
[](https://hostux.social/@
|
|
20
|
+
[](https://bsky.app/profile/Tatsh.bsky.social)
|
|
21
|
+
[](https://hostux.social/@Tatsh)
|
|
21
22
|
|
|
22
23
|
Utilities for programmatic use of yt-dlp.
|
|
23
24
|
|
|
@@ -15,14 +15,14 @@ import yt_dlp
|
|
|
15
15
|
from .constants import DEFAULT_RETRY_BACKOFF_FACTOR, DEFAULT_RETRY_STATUS_FORCELIST, SHARED_HEADERS
|
|
16
16
|
|
|
17
17
|
if TYPE_CHECKING:
|
|
18
|
-
from collections.abc import Collection, Mapping
|
|
18
|
+
from collections.abc import Collection, Iterable, Mapping
|
|
19
19
|
|
|
20
20
|
__all__ = ('YoutubeDLLogger', 'get_configured_yt_dlp', 'setup_session')
|
|
21
21
|
|
|
22
22
|
log = logging.getLogger(__name__)
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class YoutubeDLLogger:
|
|
25
|
+
class YoutubeDLLogger(yt_dlp.cookies.YDLLogger):
|
|
26
26
|
"""Logger for yt-dlp."""
|
|
27
27
|
def debug(self, message: str) -> None:
|
|
28
28
|
"""Log a debug message."""
|
|
@@ -34,7 +34,11 @@ class YoutubeDLLogger:
|
|
|
34
34
|
"""Log an info message."""
|
|
35
35
|
log.info('%s', re.sub(r'^\[info\]\s+', '', message))
|
|
36
36
|
|
|
37
|
-
def warning(
|
|
37
|
+
def warning(
|
|
38
|
+
self,
|
|
39
|
+
message: str,
|
|
40
|
+
once: bool = False, # noqa: FBT001, FBT002
|
|
41
|
+
only_once: bool = False) -> None: # noqa: FBT001, FBT002
|
|
38
42
|
"""Log a warning message."""
|
|
39
43
|
log.warning('%s', re.sub(r'^\[warn(?:ing)?\]\s+', '', message))
|
|
40
44
|
|
|
@@ -82,11 +86,12 @@ def get_configured_yt_dlp(sleep_time: int = 3,
|
|
|
82
86
|
|
|
83
87
|
def setup_session(browser: str,
|
|
84
88
|
profile: str,
|
|
85
|
-
headers: Mapping[str, str] | None = None,
|
|
86
89
|
add_headers: Mapping[str, str] | None = None,
|
|
87
90
|
backoff_factor: float = DEFAULT_RETRY_BACKOFF_FACTOR,
|
|
88
|
-
|
|
91
|
+
domains: Iterable[str] | None = None,
|
|
92
|
+
headers: Mapping[str, str] | None = None,
|
|
89
93
|
session: requests.Session | None = None,
|
|
94
|
+
status_forcelist: Collection[int] = DEFAULT_RETRY_STATUS_FORCELIST,
|
|
90
95
|
*,
|
|
91
96
|
setup_retry: bool = False) -> requests.Session:
|
|
92
97
|
"""
|
|
@@ -98,12 +103,14 @@ def setup_session(browser: str,
|
|
|
98
103
|
The browser to extract cookies from.
|
|
99
104
|
profile : str
|
|
100
105
|
The profile to extract cookies from.
|
|
101
|
-
headers : Mapping[str, str]
|
|
102
|
-
The headers to use for the requests session. If not specified, a default set will be used.
|
|
103
106
|
add_headers : Mapping[str, str]
|
|
104
107
|
Additional headers to add to the requests session.
|
|
105
108
|
backoff_factor : float
|
|
106
109
|
The backoff factor to use for the retry mechanism.
|
|
110
|
+
domains : Iterable[str]
|
|
111
|
+
Filter the cookies to only those that match the specified domains.
|
|
112
|
+
headers : Mapping[str, str]
|
|
113
|
+
The headers to use for the requests session. If not specified, a default set will be used.
|
|
107
114
|
status_forcelist : Collection[int]
|
|
108
115
|
The status codes to retry on.
|
|
109
116
|
setup_retry : bool
|
|
@@ -117,10 +124,20 @@ def setup_session(browser: str,
|
|
|
117
124
|
headers = headers or SHARED_HEADERS
|
|
118
125
|
add_headers = add_headers or {}
|
|
119
126
|
session = session or requests.Session()
|
|
127
|
+
session.headers.update(headers)
|
|
128
|
+
session.headers.update(add_headers)
|
|
120
129
|
if setup_retry:
|
|
121
130
|
session.mount(
|
|
122
131
|
'https://',
|
|
123
132
|
HTTPAdapter(max_retries=Retry(backoff_factor=backoff_factor,
|
|
124
133
|
status_forcelist=status_forcelist)))
|
|
125
|
-
|
|
134
|
+
extracted = extract_cookies_from_browser(browser, profile)
|
|
135
|
+
if not domains:
|
|
136
|
+
session.cookies.update(extracted)
|
|
137
|
+
else:
|
|
138
|
+
for domain in (d.lstrip('.') for d in domains):
|
|
139
|
+
for cookie in extracted.get_cookies_for_url(f'https://{domain}'):
|
|
140
|
+
if not isinstance(cookie.value, str):
|
|
141
|
+
continue
|
|
142
|
+
session.cookies.set(cookie.name, cookie.value, domain=domain)
|
|
126
143
|
return session
|
|
File without changes
|
|
File without changes
|
|
File without changes
|