diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2024-02-12 22:03:33 +0100 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2024-02-12 22:03:33 +0100 |
| commit | bd5df3af5f230ee3e62a894f1944932ff799df90 (patch) | |
| tree | 86ef7c30685f9132e5a4dbc22ebb8dc3e709c2e1 /src | |
| parent | 9bd2072e1d3829bed24c552696f1dee2bb5eb95e (diff) | |
| parent | 090b470bfcadce192439500ff89598fc6ba3faac (diff) | |
| download | invidious-bd5df3af5f230ee3e62a894f1944932ff799df90.tar.gz invidious-bd5df3af5f230ee3e62a894f1944932ff799df90.tar.bz2 invidious-bd5df3af5f230ee3e62a894f1944932ff799df90.zip | |
API: Unescape search suggestions (#4218)
Previously, the suggestion were HTML encoded. This PR fixes that.
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/routes/api/v1/search.cr | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/invidious/routes/api/v1/search.cr b/src/invidious/routes/api/v1/search.cr index 9fb283c2..2922b060 100644 --- a/src/invidious/routes/api/v1/search.cr +++ b/src/invidious/routes/api/v1/search.cr @@ -32,11 +32,14 @@ module Invidious::Routes::API::V1::Search begin 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" + client.before_request { |r| add_yt_headers(r) } + + url = "/complete/search?client=youtube&hl=en&gl=#{region}&q=#{URI.encode_www_form(query)}&gs_ri=youtube&ds=yt" response = client.get(url).body + client.close - body = JSON.parse(response[5..-1]).as_a + body = JSON.parse(response[19..-2]).as_a suggestions = body[1].as_a[0..-2] JSON.build do |json| |
