mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-03-24 21:31:36 +00:00
Change cookies to skip EU cookie consent page
See https://github.com/benbusby/whoogle-search/issues/311 for some
context.
We're now implementing
a726009987/youtube_dl/extractor/youtube.py (L263-L264)
This commit is contained in:
parent
18f5ef4c62
commit
7d3b79b1cd
3 changed files with 8 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ import requests
|
|||
import traceback
|
||||
import yt_dlp
|
||||
from tools.converters import *
|
||||
from tools.extractors import extract_yt_initial_data
|
||||
from tools.extractors import extract_yt_initial_data, eu_consent_cookie
|
||||
from cachetools import TTLCache
|
||||
|
||||
search_cache = TTLCache(maxsize=50, ttl=300)
|
||||
|
|
@ -17,7 +17,7 @@ ytdl = yt_dlp.YoutubeDL(ytdl_opts)
|
|||
|
||||
def extract_search(q):
|
||||
try:
|
||||
with requests.get("https://www.youtube.com/results", params={"q": q, "hl": "en"}, cookies={"CONSENT": "PENDING+999"}) as r:
|
||||
with requests.get("https://www.youtube.com/results", params={"q": q, "hl": "en"}, cookies=eu_consent_cookie()) as r:
|
||||
r.raise_for_status()
|
||||
content = r.content.decode("utf8")
|
||||
yt_initial_data = extract_yt_initial_data(content)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue