summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-02-06 18:21:40 -0600
committerOmar Roth <omarroth@hotmail.com>2019-02-06 18:21:40 -0600
commita7b79824de7fdcadd5139a1e5ccf7870c194b305 (patch)
tree879a4b8e338a76093a4cdc1b89ac626bed3de73a
parentd625d0ffbdc23306e279c47fb55ef9d2b18990c6 (diff)
downloadinvidious-a7b79824de7fdcadd5139a1e5ccf7870c194b305.tar.gz
invidious-a7b79824de7fdcadd5139a1e5ccf7870c194b305.tar.bz2
invidious-a7b79824de7fdcadd5139a1e5ccf7870c194b305.zip
Add support for 'region' in search
-rw-r--r--src/invidious.cr7
-rw-r--r--src/invidious/search.cr4
2 files changed, 6 insertions, 5 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index ddd3084f..87305db6 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -596,6 +596,7 @@ end
get "/search" do |env|
locale = LOCALES[env.get("locale").as(String)]?
+ region = env.params.query["region"]?
query = env.params.query["search_query"]?
query ||= env.params.query["q"]?
@@ -671,7 +672,7 @@ get "/search" do |env|
next templated "error"
end
- count, videos = search(search_query, page, search_params).as(Tuple)
+ count, videos = search(search_query, page, search_params, proxies, region).as(Tuple)
end
templated "search"
@@ -3199,6 +3200,7 @@ end
get "/api/v1/search" do |env|
locale = LOCALES[env.get("locale").as(String)]?
+ region = env.params.query["region"]?
env.response.content_type = "application/json"
@@ -3220,7 +3222,6 @@ get "/api/v1/search" do |env|
features = env.params.query["features"]?.try &.split(",").map { |feature| feature.downcase }
features ||= [] of String
- # TODO: Support other content types
content_type = env.params.query["type"]?.try &.downcase
content_type ||= "video"
@@ -3235,7 +3236,7 @@ get "/api/v1/search" do |env|
end
end
- count, search_results = search(query, page, search_params).as(Tuple)
+ count, search_results = search(query, page, search_params, proxies, region).as(Tuple)
response = JSON.build do |json|
json.array do
search_results.each do |item|
diff --git a/src/invidious/search.cr b/src/invidious/search.cr
index 20e34c24..ce29abf2 100644
--- a/src/invidious/search.cr
+++ b/src/invidious/search.cr
@@ -85,8 +85,8 @@ def channel_search(query, page, channel)
return count, items
end
-def search(query, page = 1, search_params = produce_search_params(content_type: "all"))
- client = make_client(YT_URL)
+def search(query, page = 1, search_params = produce_search_params(content_type: "all"), proxies = nil, region = nil)
+ client = make_client(YT_URL, proxies, region)
if query.empty?
return {0, [] of SearchItem}
end