|
|
@ -20,15 +20,17 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
|
|
|
|
|
|
|
|
|
|
|
|
query = env.params.query["search_query"]?
|
|
|
|
query = env.params.query["search_query"]?
|
|
|
|
query ||= env.params.query["q"]?
|
|
|
|
query ||= env.params.query["q"]?
|
|
|
|
query ||= ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
page = env.params.query["page"]?.try &.to_i?
|
|
|
|
page = env.params.query["page"]?
|
|
|
|
page ||= 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if query
|
|
|
|
if query && !query.empty?
|
|
|
|
env.redirect "/search?q=#{URI.encode_www_form(query)}&page=#{page}"
|
|
|
|
if page && !page.empty?
|
|
|
|
|
|
|
|
env.redirect "/search?q=" + URI.encode_www_form(query) + "&page=" + page
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
env.redirect "/search?q=" + URI.encode_www_form(query)
|
|
|
|
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
env.redirect "/"
|
|
|
|
env.redirect "/search"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -38,28 +40,31 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
|
|
|
|
|
|
|
|
|
|
|
|
query = env.params.query["search_query"]?
|
|
|
|
query = env.params.query["search_query"]?
|
|
|
|
query ||= env.params.query["q"]?
|
|
|
|
query ||= env.params.query["q"]?
|
|
|
|
query ||= ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return env.redirect "/" if query.empty?
|
|
|
|
if !query || query.empty?
|
|
|
|
|
|
|
|
# Display the full page search box implemented in #1977
|
|
|
|
|
|
|
|
env.set "search", ""
|
|
|
|
|
|
|
|
templated "search_homepage", navbar_search: false
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
page = env.params.query["page"]?.try &.to_i?
|
|
|
|
|
|
|
|
page ||= 1
|
|
|
|
|
|
|
|
|
|
|
|
page = env.params.query["page"]?.try &.to_i?
|
|
|
|
user = env.get? "user"
|
|
|
|
page ||= 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = env.get? "user"
|
|
|
|
begin
|
|
|
|
|
|
|
|
search_query, count, videos, operators = process_search_query(query, page, user, region: region)
|
|
|
|
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
return error_template(500, ex)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
operator_hash = {} of String => String
|
|
|
|
search_query, count, videos, operators = process_search_query(query, page, user, region: nil)
|
|
|
|
operators.each do |operator|
|
|
|
|
rescue ex
|
|
|
|
key, value = operator.downcase.split(":")
|
|
|
|
return error_template(500, ex)
|
|
|
|
operator_hash[key] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
operator_hash = {} of String => String
|
|
|
|
env.set "search", query
|
|
|
|
operators.each do |operator|
|
|
|
|
templated "search"
|
|
|
|
key, value = operator.downcase.split(":")
|
|
|
|
|
|
|
|
operator_hash[key] = value
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
env.set "search", query
|
|
|
|
|
|
|
|
templated "search"
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|