summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com>2022-03-07 15:52:50 +0000
committerGitHub <noreply@github.com>2022-03-07 15:52:50 +0000
commit440549fcc52007fbc2968abbfe19d315fbd3993d (patch)
tree7fde418b3685cc024cca708a3f0bf0cb1c06ce9e
parentbdfe317e20c9cc5d9e972e51d995faf59b86197d (diff)
parentf7b557eed1c8e55002608ee9117cf9523b24bafd (diff)
downloadinvidious-440549fcc52007fbc2968abbfe19d315fbd3993d.tar.gz
invidious-440549fcc52007fbc2968abbfe19d315fbd3993d.tar.bz2
invidious-440549fcc52007fbc2968abbfe19d315fbd3993d.zip
Merge pull request #2952 from iv-org/SamantazFox-patch-1
API: fix suggestions not workin
-rw-r--r--src/invidious/routes/api/v1/search.cr16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/invidious/routes/api/v1/search.cr b/src/invidious/routes/api/v1/search.cr
index 0b0853b1..5666460d 100644
--- a/src/invidious/routes/api/v1/search.cr
+++ b/src/invidious/routes/api/v1/search.cr
@@ -43,20 +43,20 @@ module Invidious::Routes::API::V1::Search
end
def self.search_suggestions(env)
- locale = env.get("preferences").as(Preferences).locale
- region = env.params.query["region"]?
+ preferences = env.get("preferences").as(Preferences)
+ region = env.params.query["region"]? || preferences.region
env.response.content_type = "application/json"
- query = env.params.query["q"]?
- query ||= ""
+ query = env.params.query["q"]? || ""
begin
- headers = HTTP::Headers{":authority" => "suggestqueries.google.com"}
- response = YT_POOL.client &.get("/complete/search?hl=en&gl=#{region}&client=youtube&ds=yt&q=#{URI.encode_www_form(query)}&callback=suggestCallback", headers).body
+ client = HTTP::Client.new("suggestqueries-clients6.youtube.com")
+ url = "/complete/search?client=youtube&hl=en&gl=#{region}&q=#{URI.encode_www_form(query)}&xssi=t&gs_ri=youtube&ds=yt"
+
+ response = client.get(url).body
- body = response[35..-2]
- body = JSON.parse(body).as_a
+ body = JSON.parse(response[5..-1]).as_a
suggestions = body[1].as_a[0..-2]
JSON.build do |json|