From 2df97cd2f51e4f0f313d90a2a476ccf28b3c9870 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Tue, 2 Jul 2019 07:29:01 -0500 Subject: [PATCH] Fix provided author for '/videos' endpoint --- src/invidious.cr | 13 +++++-------- src/invidious/channels.cr | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index a170ded7..967bfa66 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2908,7 +2908,7 @@ get "/channel/:ucid" do |env| sort_options = {"newest", "oldest", "popular"} sort_by ||= "newest" - items, count = get_60_videos(channel.ucid, page, channel.auto_generated, sort_by) + items, count = get_60_videos(channel.ucid, channel.author, page, channel.auto_generated, sort_by) items.select! { |item| !item.paid } env.set "search", "channel:#{channel.ucid} " @@ -3544,7 +3544,7 @@ get "/api/v1/channels/:ucid" do |env| count = 0 else begin - videos, count = get_60_videos(channel.ucid, page, channel.auto_generated, sort_by) + videos, count = get_60_videos(channel.ucid, channel.author,page, channel.auto_generated, sort_by) rescue ex error_message = {"error" => ex.message}.to_json env.response.status_code = 500 @@ -3669,7 +3669,7 @@ end end begin - videos, count = get_60_videos(channel.ucid, page, channel.auto_generated, sort_by) + videos, count = get_60_videos(channel.ucid, channel.author, page, channel.auto_generated, sort_by) rescue ex error_message = {"error" => ex.message}.to_json env.response.status_code = 500 @@ -3806,11 +3806,8 @@ get "/api/v1/search" do |env| search_params = produce_search_params(sort_by, date, content_type, duration, features) rescue ex env.response.status_code = 400 - next JSON.build do |json| - json.object do - json.field "error", ex.message - end - end + error_message = {"error" => ex.message}.to_json + next error_message end count, search_results = search(query, page, search_params, region).as(Tuple) diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 598ca294..4837a70c 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -729,7 +729,7 @@ def get_about_info(ucid, locale) ) end -def get_60_videos(ucid, page, auto_generated, sort_by = "newest") +def get_60_videos(ucid, author, page, auto_generated, sort_by = "newest") count = 0 videos = [] of SearchVideo @@ -751,7 +751,7 @@ def get_60_videos(ucid, page, auto_generated, sort_by = "newest") if auto_generated videos += extract_videos(nodeset) else - videos += extract_videos(nodeset, ucid) + videos += extract_videos(nodeset, ucid, author) end else break