1
0
Fork 0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2026-03-22 20:31:36 +00:00

Fix extracting with cookie consent page in EU

Fix #27 use maintained yt-dlp lib instead of youtube-dlc

Because of the following changes in YT, we have to switch to a
maintained library https://github.com/ytdl-org/youtube-dl/issues/28604
While yt-dlp is not fixed today, youtube-dl is fixed in master and as
yt-dlp is quick to merge upstream changes back to their repo, we can
hope the issue will also be fixed there timely.

For requests sent by us directly, we include the cookies.

Ref https://github.com/ytdl-org/youtube-dl/issues/28604
This commit is contained in:
Lomanic 2021-04-01 00:31:33 +02:00 committed by Cadence Ember
parent fe04a4dbd6
commit 5f47e1a71b
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
5 changed files with 9 additions and 9 deletions

View file

@ -18,7 +18,7 @@ def extract_channel(ucid):
return channel_cache[ucid]
channel_type = "channel" if len(ucid) == 24 and ucid[:2] == "UC" else "user"
with requests.get("https://www.youtube.com/{}/{}/videos?hl=en".format(channel_type, ucid)) as r:
with requests.get("https://www.youtube.com/{}/{}/videos?hl=en".format(channel_type, ucid), cookies={"CONSENT": "YES+cb.20210328-17-p0.en+FX+101"}) as r:
r.raise_for_status()
yt_initial_data = extract_yt_initial_data(r.content.decode("utf8"))