added youtube music cookies to settings
This commit is contained in:
parent
2900f4696a
commit
151cdf7831
@ -59,23 +59,11 @@ class YoutubeMusicConnection(Connection):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# cookie consent for youtube
|
# cookie consent for youtube
|
||||||
# https://stackoverflow.com/a/66940841/16804841
|
# https://stackoverflow.com/a/66940841/16804841 doesn't work
|
||||||
"""
|
for cookie_key, cookie_value in youtube_settings["youtube_music_consent_cookies"].items():
|
||||||
self.session.cookies.set(
|
self.session.cookies.set(
|
||||||
name='CONSENT',
|
name=cookie_key,
|
||||||
value='YES+cb.20250328-17-p0.en-GB+FX+{}'.format(random.randint(100, 999)),
|
value=cookie_value,
|
||||||
path='/', domain='.youtube.com'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.session.cookies.set(
|
|
||||||
name='CONSENT',
|
|
||||||
value='YES+cb.20250328-17-p0.en-GB+FX+{}'.format(random.randint(100, 999)),
|
|
||||||
path='/', domain='.youtube.com'
|
|
||||||
)
|
|
||||||
"""
|
|
||||||
self.session.cookies.set(
|
|
||||||
name='CONSENT',
|
|
||||||
value='PENDING+258',
|
|
||||||
path='/', domain='.youtube.com'
|
path='/', domain='.youtube.com'
|
||||||
)
|
)
|
||||||
# self.start_hearthbeat()
|
# self.start_hearthbeat()
|
||||||
@ -139,6 +127,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if urlparse(r.url).netloc == "consent.youtube.com":
|
if urlparse(r.url).netloc == "consent.youtube.com":
|
||||||
|
self.LOGGER.info(f"Making cookie consent request for {type(self).__name__}.")
|
||||||
r = self.connection.post("https://consent.youtube.com/save", data={
|
r = self.connection.post("https://consent.youtube.com/save", data={
|
||||||
'gl': 'DE',
|
'gl': 'DE',
|
||||||
'm': '0',
|
'm': '0',
|
||||||
@ -157,6 +146,17 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
if r is None:
|
if r is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# load cookie dict from settings
|
||||||
|
cookie_dict = youtube_settings["youtube_music_consent_cookies"]
|
||||||
|
|
||||||
|
for cookie in r.cookies:
|
||||||
|
cookie_dict[cookie.name] = cookie.value
|
||||||
|
for cookie in self.connection.session.cookies:
|
||||||
|
cookie_dict[cookie.name] = cookie.value
|
||||||
|
|
||||||
|
# save cookies in settings
|
||||||
|
youtube_settings["youtube_music_consent_cookies"] = cookie_dict
|
||||||
|
|
||||||
r = self.connection.get("https://music.youtube.com/")
|
r = self.connection.get("https://music.youtube.com/")
|
||||||
if r is None:
|
if r is None:
|
||||||
return
|
return
|
||||||
|
@ -32,6 +32,10 @@ Dw. if it is empty, Rachel will fetch it automatically for you <333
|
|||||||
If any instance seems to be missing, run music kraken with the -f flag."""),
|
If any instance seems to be missing, run music kraken with the -f flag."""),
|
||||||
Attribute(name="use_sponsor_block", default_value=True, description="Use sponsor block to remove adds or simmilar from the youtube videos."),
|
Attribute(name="use_sponsor_block", default_value=True, description="Use sponsor block to remove adds or simmilar from the youtube videos."),
|
||||||
|
|
||||||
|
Attribute(name="youtube_music_consent_cookies", default_value={
|
||||||
|
"CONSENT": "PENDING+258"
|
||||||
|
}, description="The cookie with the key CONSENT says to what stuff you agree. Per default you decline all cookies, but it honestly doesn't matter."),
|
||||||
|
|
||||||
Attribute(name="youtube_music_innertube_context", default_value={
|
Attribute(name="youtube_music_innertube_context", default_value={
|
||||||
"client": {
|
"client": {
|
||||||
"hl": "en",
|
"hl": "en",
|
||||||
@ -96,3 +100,4 @@ class SettingsStructure(TypedDict):
|
|||||||
youtube_url: List[ParseResult]
|
youtube_url: List[ParseResult]
|
||||||
use_sponsor_block: bool
|
use_sponsor_block: bool
|
||||||
youtube_music_innertube_context: dict
|
youtube_music_innertube_context: dict
|
||||||
|
youtube_music_consent_cookies: dict
|
||||||
|
Loading…
Reference in New Issue
Block a user