yt-dlp-utils 0.0.1__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yt-dlp-utils
3
- Version: 0.0.1
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
+ [![Python versions](https://img.shields.io/pypi/pyversions/yt-dlp-utils.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
31
+ [![PyPI - Version](https://img.shields.io/pypi/v/yt-dlp-utils)](https://pypi.org/project/yt-dlp-utils/)
32
+ [![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/tags)
33
+ [![License](https://img.shields.io/github/license/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
34
+ [![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/yt-dlp-utils/v0.0.3/master)](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.3...master)
30
35
  [![QA](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/qa.yml/badge.svg)](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/qa.yml)
31
36
  [![Tests](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/tests.yml/badge.svg)](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/tests.yml)
32
37
  [![Coverage Status](https://coveralls.io/repos/github/Tatsh/yt-dlp-utils/badge.svg?branch=master)](https://coveralls.io/github/Tatsh/yt-dlp-utils?branch=master)
33
38
  [![Documentation Status](https://readthedocs.org/projects/yt-dlp-utils/badge/?version=latest)](https://yt-dlp-utils.readthedocs.org/?badge=latest)
34
- [![PyPI - Version](https://img.shields.io/pypi/v/yt-dlp-utils)](https://pypi.org/project/yt-dlp-utils/)
35
- [![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/tags)
36
- [![License](https://img.shields.io/github/license/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
37
- [![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/yt-dlp-utils/v0.0.1/master)](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.1...master)
38
- ![License](https://img.shields.io/badge/License-MIT-success.svg)
39
39
  [![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
40
40
  [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
41
41
  [![pydocstyle](https://img.shields.io/badge/pydocstyle-enabled-AD4CD3)](http://www.pydocstyle.org/en/stable/)
42
42
  [![pytest](https://img.shields.io/badge/pytest-zz?logo=Pytest&labelColor=black&color=black)](https://docs.pytest.org/en/stable/)
43
- [![Python](https://img.shields.io/badge/Python-3.12-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
44
43
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
44
+ [![Downloads](https://static.pepy.tech/badge/yt-dlp-utils/month)](https://pepy.tech/project/yt-dlp-utils)
45
+ [![Stargazers](https://img.shields.io/github/stars/Tatsh/yt-dlp-utils?logo=github&style=flat)](https://github.com/Tatsh/yt-dlp-utils/stargazers)
45
46
 
46
- [![@Tatsh](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor%3Ddid%3Aplc%3Auq42idtvuccnmtl57nsucz72%26query%3D%24.followersCount%26style%3Dsocial%26logo%3Dbluesky%26label%3DFollow%2520%40Tatsh&query=%24.followersCount&style=social&logo=bluesky&label=Follow%20%40Tatsh)](https://bsky.app/profile/tatsh.bsky.social)
47
- [![Mastodon Follow](https://img.shields.io/mastodon/follow/109370961877277568?domain=hostux.social&style=social)](https://hostux.social/@tatsh)
47
+ [![@Tatsh](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor%3Ddid%3Aplc%3Auq42idtvuccnmtl57nsucz72%26query%3D%24.followersCount%26style%3Dsocial%26logo%3Dbluesky%26label%3DFollow%2520%40Tatsh&query=%24.followersCount&style=social&logo=bluesky&label=Follow%20%40Tatsh)](https://bsky.app/profile/Tatsh.bsky.social)
48
+ [![Mastodon Follow](https://img.shields.io/mastodon/follow/109370961877277568?domain=hostux.social&style=social)](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
+ [![Python versions](https://img.shields.io/pypi/pyversions/yt-dlp-utils.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
4
+ [![PyPI - Version](https://img.shields.io/pypi/v/yt-dlp-utils)](https://pypi.org/project/yt-dlp-utils/)
5
+ [![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/tags)
6
+ [![License](https://img.shields.io/github/license/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
7
+ [![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/yt-dlp-utils/v0.0.3/master)](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.3...master)
3
8
  [![QA](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/qa.yml/badge.svg)](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/qa.yml)
4
9
  [![Tests](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/tests.yml/badge.svg)](https://github.com/Tatsh/yt-dlp-utils/actions/workflows/tests.yml)
5
10
  [![Coverage Status](https://coveralls.io/repos/github/Tatsh/yt-dlp-utils/badge.svg?branch=master)](https://coveralls.io/github/Tatsh/yt-dlp-utils?branch=master)
6
11
  [![Documentation Status](https://readthedocs.org/projects/yt-dlp-utils/badge/?version=latest)](https://yt-dlp-utils.readthedocs.org/?badge=latest)
7
- [![PyPI - Version](https://img.shields.io/pypi/v/yt-dlp-utils)](https://pypi.org/project/yt-dlp-utils/)
8
- [![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/tags)
9
- [![License](https://img.shields.io/github/license/Tatsh/yt-dlp-utils)](https://github.com/Tatsh/yt-dlp-utils/blob/master/LICENSE.txt)
10
- [![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/yt-dlp-utils/v0.0.1/master)](https://github.com/Tatsh/yt-dlp-utils/compare/v0.0.1...master)
11
- ![License](https://img.shields.io/badge/License-MIT-success.svg)
12
12
  [![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
13
13
  [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
14
14
  [![pydocstyle](https://img.shields.io/badge/pydocstyle-enabled-AD4CD3)](http://www.pydocstyle.org/en/stable/)
15
15
  [![pytest](https://img.shields.io/badge/pytest-zz?logo=Pytest&labelColor=black&color=black)](https://docs.pytest.org/en/stable/)
16
- [![Python](https://img.shields.io/badge/Python-3.12-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
17
16
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
17
+ [![Downloads](https://static.pepy.tech/badge/yt-dlp-utils/month)](https://pepy.tech/project/yt-dlp-utils)
18
+ [![Stargazers](https://img.shields.io/github/stars/Tatsh/yt-dlp-utils?logo=github&style=flat)](https://github.com/Tatsh/yt-dlp-utils/stargazers)
18
19
 
19
- [![@Tatsh](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor%3Ddid%3Aplc%3Auq42idtvuccnmtl57nsucz72%26query%3D%24.followersCount%26style%3Dsocial%26logo%3Dbluesky%26label%3DFollow%2520%40Tatsh&query=%24.followersCount&style=social&logo=bluesky&label=Follow%20%40Tatsh)](https://bsky.app/profile/tatsh.bsky.social)
20
- [![Mastodon Follow](https://img.shields.io/mastodon/follow/109370961877277568?domain=hostux.social&style=social)](https://hostux.social/@tatsh)
20
+ [![@Tatsh](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor%3Ddid%3Aplc%3Auq42idtvuccnmtl57nsucz72%26query%3D%24.followersCount%26style%3Dsocial%26logo%3Dbluesky%26label%3DFollow%2520%40Tatsh&query=%24.followersCount&style=social&logo=bluesky&label=Follow%20%40Tatsh)](https://bsky.app/profile/Tatsh.bsky.social)
21
+ [![Mastodon Follow](https://img.shields.io/mastodon/follow/109370961877277568?domain=hostux.social&style=social)](https://hostux.social/@Tatsh)
21
22
 
22
23
  Utilities for programmatic use of yt-dlp.
23
24
 
@@ -20,7 +20,7 @@ keywords = ["command line", "yt-dlp"]
20
20
  license = "MIT"
21
21
  name = "yt-dlp-utils"
22
22
  readme = "README.md"
23
- version = "0.0.1"
23
+ version = "0.0.3"
24
24
 
25
25
  [[project.authors]]
26
26
  email = "audvare@gmail.com"
@@ -4,4 +4,4 @@ from __future__ import annotations
4
4
  from .lib import YoutubeDLLogger, get_configured_yt_dlp, setup_session
5
5
 
6
6
  __all__ = ('YoutubeDLLogger', 'get_configured_yt_dlp', 'setup_session')
7
- __version__ = '0.0.1'
7
+ __version__ = '0.0.3'
@@ -22,7 +22,7 @@ __all__ = ('YoutubeDLLogger', 'get_configured_yt_dlp', 'setup_session')
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(self, message: str) -> None:
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,12 +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
- domains: Iterable[str],
86
- headers: Mapping[str, str] | None = None,
87
89
  add_headers: Mapping[str, str] | None = None,
88
90
  backoff_factor: float = DEFAULT_RETRY_BACKOFF_FACTOR,
89
- status_forcelist: Collection[int] = DEFAULT_RETRY_STATUS_FORCELIST,
91
+ domains: Iterable[str] | None = None,
92
+ headers: Mapping[str, str] | None = None,
90
93
  session: requests.Session | None = None,
94
+ status_forcelist: Collection[int] = DEFAULT_RETRY_STATUS_FORCELIST,
91
95
  *,
92
96
  setup_retry: bool = False) -> requests.Session:
93
97
  """
@@ -99,14 +103,14 @@ def setup_session(browser: str,
99
103
  The browser to extract cookies from.
100
104
  profile : str
101
105
  The profile to extract cookies from.
102
- domains : Iterable[str]
103
- The domains of which to extract cookies.
104
- headers : Mapping[str, str]
105
- The headers to use for the requests session. If not specified, a default set will be used.
106
106
  add_headers : Mapping[str, str]
107
107
  Additional headers to add to the requests session.
108
108
  backoff_factor : float
109
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.
110
114
  status_forcelist : Collection[int]
111
115
  The status codes to retry on.
112
116
  setup_retry : bool
@@ -120,14 +124,20 @@ def setup_session(browser: str,
120
124
  headers = headers or SHARED_HEADERS
121
125
  add_headers = add_headers or {}
122
126
  session = session or requests.Session()
127
+ session.headers.update(headers)
128
+ session.headers.update(add_headers)
123
129
  if setup_retry:
124
130
  session.mount(
125
131
  'https://',
126
132
  HTTPAdapter(max_retries=Retry(backoff_factor=backoff_factor,
127
133
  status_forcelist=status_forcelist)))
128
134
  extracted = extract_cookies_from_browser(browser, profile)
129
- cookies = '; '.join('; '.join(f'{cookie.name}={cookie.value}' for cookie in extracted
130
- if domain in cookie.domain) for domain in domains)
131
- # | does not work for Mapping
132
- session.headers.update({**headers, **add_headers, 'cookie': cookies})
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)
133
143
  return session
File without changes