summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-09-16 21:28:00 -0500
committerOmar Roth <omarroth@hotmail.com>2018-09-16 21:28:00 -0500
commitf39ed3d145a58aa967b194805fd616769b5a9b21 (patch)
tree782bc47126c34a3454e89a46f50e1eba98113c54
parentf38aac851e3ca0a5db2ec80ddf110cb5ea9d6722 (diff)
downloadinvidious-f39ed3d145a58aa967b194805fd616769b5a9b21.tar.gz
invidious-f39ed3d145a58aa967b194805fd616769b5a9b21.tar.bz2
invidious-f39ed3d145a58aa967b194805fd616769b5a9b21.zip
Add subscriptions search filter
-rw-r--r--src/invidious.cr12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index df0ea978..36c104dc 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -435,6 +435,7 @@ get "/search" do |env|
duration = ""
features = [] of String
sort = "relevance"
+ subscriptions = nil
operators = query.split(" ").select { |a| a.match(/\w+:[\w,]+/) }
operators.each do |operator|
@@ -451,6 +452,8 @@ get "/search" do |env|
features = value.split(",")
when "sort"
sort = value
+ when "subscriptions"
+ subscriptions = value == "true"
end
end
@@ -458,6 +461,15 @@ get "/search" do |env|
if channel
count, videos = channel_search(search_query, page, channel)
+ elsif subscriptions
+ videos = PG_DB.query_all("SELECT id,title,published,updated,ucid,author FROM (
+ SELECT *,
+ to_tsvector(channel_videos.title) ||
+ to_tsvector(channel_videos.author)
+ as document
+ FROM channel_videos
+ ) v_search WHERE v_search.document @@ plainto_tsquery($1) LIMIT 20 OFFSET $2;", search_query, (page - 1) * 20, as: ChannelVideo)
+ count = videos.size
else
search_params = build_search_params(sort: sort, date: date, content_type: "video",
duration: duration, features: features)