summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-09-25 17:55:32 -0500
committerOmar Roth <omarroth@hotmail.com>2018-09-25 17:55:32 -0500
commit5b5d69a33b85f927306839556cfe494d9a3216e4 (patch)
tree5fd29370c00c37014d8357e58cd4bdf186705397
parent128906515130a6b032538dc17e0551645e8ddcdc (diff)
downloadinvidious-5b5d69a33b85f927306839556cfe494d9a3216e4.tar.gz
invidious-5b5d69a33b85f927306839556cfe494d9a3216e4.tar.bz2
invidious-5b5d69a33b85f927306839556cfe494d9a3216e4.zip
Add host language to YouTube requests
-rw-r--r--src/invidious.cr4
-rw-r--r--src/invidious/playlists.cr4
-rw-r--r--src/invidious/search.cr2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index d4b44558..7871ea3e 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -1817,7 +1817,7 @@ get "/api/v1/comments/:id" do |env|
if source == "youtube"
client = make_client(YT_URL)
headers = HTTP::Headers.new
- html = client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&disable_polymer=1")
+ html = client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&gl=US&hl=en&disable_polymer=1")
headers["cookie"] = html.cookies.add_request_headers(headers)["cookie"]
headers["content-type"] = "application/x-www-form-urlencoded"
@@ -2038,7 +2038,7 @@ get "/api/v1/insights/:id" do |env|
client = make_client(YT_URL)
headers = HTTP::Headers.new
- html = client.get("/watch?v=#{id}&disable_polymer=1")
+ html = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1")
headers["cookie"] = html.cookies.add_request_headers(headers)["cookie"]
headers["content-type"] = "application/x-www-form-urlencoded"
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index 326123b6..e6bc917b 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -46,7 +46,7 @@ def fetch_playlist_videos(plid, page, video_count)
if page > 1
videos = [] of PlaylistVideo
else
- response = client.get("/playlist?list=#{plid}&disable_polymer=1")
+ response = client.get("/playlist?list=#{plid}&gl=US&hl=en&disable_polymer=1")
document = XML.parse_html(response.body)
nodeset = document.xpath_nodes(%q(.//tr[contains(@class, "pl-video")]))
@@ -142,7 +142,7 @@ def fetch_playlist(plid)
plid = "UU#{plid.lchop("UC")}"
end
- response = client.get("/playlist?list=#{plid}&disable_polymer=1")
+ response = client.get("/playlist?list=#{plid}&hl=en&disable_polymer=1")
if response.status_code != 200
raise "Invalid playlist."
end
diff --git a/src/invidious/search.cr b/src/invidious/search.cr
index 244f16fd..98d1cdfb 100644
--- a/src/invidious/search.cr
+++ b/src/invidious/search.cr
@@ -89,7 +89,7 @@ def search(query, page = 1, search_params = produce_search_params(content_type:
return {0, [] of SearchItem}
end
- html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=#{search_params}&disable_polymer=1").body
+ html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=#{search_params}&hl=en&disable_polymer=1").body
if html.empty?
return {0, [] of SearchItem}
end