From 87c7730fbc89ba576b4015a11e3caf841dd852c2 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 25 Oct 2020 18:02:05 +1300 Subject: [PATCH] Fetch pages using en locale --- extractors/channel.py | 2 +- extractors/search.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extractors/channel.py b/extractors/channel.py index 967d79a..6a969e0 100644 --- a/extractors/channel.py +++ b/extractors/channel.py @@ -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".format(channel_type, ucid)) as r: + with requests.get("https://www.youtube.com/{}/{}/videos?hl=en".format(channel_type, ucid)) as r: r.raise_for_status() yt_initial_data = extract_yt_initial_data(r.content.decode("utf8")) diff --git a/extractors/search.py b/extractors/search.py index 8b9dd2e..9c3fef2 100644 --- a/extractors/search.py +++ b/extractors/search.py @@ -17,7 +17,7 @@ ytdl = youtube_dl.YoutubeDL(ytdl_opts) def extract_search(q): try: - with requests.get("https://www.youtube.com/results", params={"q": q}) as r: + with requests.get("https://www.youtube.com/results", params={"q": q, "hl": "en"}) as r: r.raise_for_status() content = r.content.decode("utf8") yt_initial_data = extract_yt_initial_data(content)