yt-dpl: fix missing dependencies and patching cookies usage.
This commit is contained in:
parent
36e3a9bcf8
commit
66c59ddc12
8 changed files with 190 additions and 10 deletions
|
|
@ -86,12 +86,15 @@ index 5675445a..7afd324b 100644
|
|||
if sys.platform in ('cygwin', 'win32'):
|
||||
yield from map(os.path.expandvars, (
|
||||
R'%APPDATA%\Mozilla\Firefox\Profiles',
|
||||
@@ -205,7 +205,7 @@ def _firefox_browser_dirs():
|
||||
|
||||
else:
|
||||
@@ -214,9 +214,9 @@ def _firefox_browser_dirs(browser_name='firefox'):
|
||||
yield from map(os.path.expanduser, (
|
||||
# New installations of FF147+ respect the XDG base directory specification
|
||||
# Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=259356
|
||||
- os.path.join(_config_home(), 'mozilla/firefox'),
|
||||
+ os.path.join(_config_home(), 'mozilla/{browser_name}'),
|
||||
# Existing FF version<=146 installations
|
||||
- '~/.mozilla/firefox',
|
||||
+ f'~/.mozilla/{browser_name}',
|
||||
'~/snap/firefox/common/.mozilla/firefox',
|
||||
+ '~/.mozilla/{browser_name}',
|
||||
# Flatpak XDG: https://docs.flatpak.org/en/latest/conventions.html#xdg-base-directories
|
||||
'~/.var/app/org.mozilla.firefox/config/mozilla/firefox',
|
||||
'~/.var/app/org.mozilla.firefox/.mozilla/firefox',
|
||||
))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py
|
||||
index 8c05a09f..8b6f6613 100644
|
||||
--- a/yt_dlp/cookies.py
|
||||
+++ b/yt_dlp/cookies.py
|
||||
@@ -1238,15 +1238,27 @@ def load(self, data):
|
||||
else:
|
||||
value, _ = self.value_decode(value)
|
||||
|
||||
- morsel[key] = value
|
||||
+ try:
|
||||
+ morsel[key] = value
|
||||
+ except http.cookies.CookieError:
|
||||
+ # Lenient mode: ignore invalid attributes
|
||||
+ pass
|
||||
|
||||
elif is_attribute:
|
||||
morsel = None
|
||||
|
||||
elif value is not None:
|
||||
- morsel = self.get(key, http.cookies.Morsel())
|
||||
+ morsel = self.get(key) or http.cookies.Morsel()
|
||||
real_value, coded_value = self.value_decode(value)
|
||||
- morsel.set(key, real_value, coded_value)
|
||||
+ try:
|
||||
+ morsel.set(key, real_value, coded_value)
|
||||
+ except http.cookies.CookieError:
|
||||
+ # Python 3.12+ rejects control characters in cookies.
|
||||
+ # LenientSimpleCookie should accept them (yt-dlp tests expect this), so
|
||||
+ # bypass Morsel.set() validation, assign underlying fields to read-only props.
|
||||
+ morsel._key = key
|
||||
+ morsel._value = real_value
|
||||
+ morsel._coded_value = coded_value
|
||||
self[key] = morsel
|
||||
|
||||
else:
|
||||
Loading…
Add table
Add a link
Reference in a new issue