Add host language to YouTube requests
This commit is contained in:
parent
1289065151
commit
5b5d69a33b
@ -1817,7 +1817,7 @@ get "/api/v1/comments/:id" do |env|
|
|||||||
if source == "youtube"
|
if source == "youtube"
|
||||||
client = make_client(YT_URL)
|
client = make_client(YT_URL)
|
||||||
headers = HTTP::Headers.new
|
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["cookie"] = html.cookies.add_request_headers(headers)["cookie"]
|
||||||
headers["content-type"] = "application/x-www-form-urlencoded"
|
headers["content-type"] = "application/x-www-form-urlencoded"
|
||||||
@ -2038,7 +2038,7 @@ get "/api/v1/insights/:id" do |env|
|
|||||||
|
|
||||||
client = make_client(YT_URL)
|
client = make_client(YT_URL)
|
||||||
headers = HTTP::Headers.new
|
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["cookie"] = html.cookies.add_request_headers(headers)["cookie"]
|
||||||
headers["content-type"] = "application/x-www-form-urlencoded"
|
headers["content-type"] = "application/x-www-form-urlencoded"
|
||||||
|
@ -46,7 +46,7 @@ def fetch_playlist_videos(plid, page, video_count)
|
|||||||
if page > 1
|
if page > 1
|
||||||
videos = [] of PlaylistVideo
|
videos = [] of PlaylistVideo
|
||||||
else
|
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)
|
document = XML.parse_html(response.body)
|
||||||
nodeset = document.xpath_nodes(%q(.//tr[contains(@class, "pl-video")]))
|
nodeset = document.xpath_nodes(%q(.//tr[contains(@class, "pl-video")]))
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ def fetch_playlist(plid)
|
|||||||
plid = "UU#{plid.lchop("UC")}"
|
plid = "UU#{plid.lchop("UC")}"
|
||||||
end
|
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
|
if response.status_code != 200
|
||||||
raise "Invalid playlist."
|
raise "Invalid playlist."
|
||||||
end
|
end
|
||||||
|
@ -89,7 +89,7 @@ def search(query, page = 1, search_params = produce_search_params(content_type:
|
|||||||
return {0, [] of SearchItem}
|
return {0, [] of SearchItem}
|
||||||
end
|
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?
|
if html.empty?
|
||||||
return {0, [] of SearchItem}
|
return {0, [] of SearchItem}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user