Add #to_http_params method to Query (Fixes #3148)

This commit is contained in:
Samantaz Fox
2022-06-14 00:04:19 +02:00
parent 6c73614a47
commit 0e3820b634
4 changed files with 59 additions and 11 deletions

View File

@@ -57,7 +57,7 @@ module Invidious::Search
# Get the page number (also common to all search types)
@page = params["page"]?.try &.to_i? || 1
# Stop here is raw query in empty
# Stop here if raw query is empty
# NOTE: maybe raise in the future?
return if self.empty_raw_query?
@@ -127,6 +127,16 @@ module Invidious::Search
return items
end
# Return the HTTP::Params corresponding to this Query (invidious format)
def to_http_params : HTTP::Params
params = @filters.to_iv_params
params["q"] = @query
params["channel"] = @channel if !@channel.empty?
return params
end
# TODO: clean code
private def unnest_items(all_items) : Array(SearchItem)
items = [] of SearchItem