mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Fix provided author for '/videos' endpoint
This commit is contained in:
parent
501b523680
commit
2df97cd2f5
2 changed files with 7 additions and 10 deletions
|
@ -2908,7 +2908,7 @@ get "/channel/:ucid" do |env|
|
||||||
sort_options = {"newest", "oldest", "popular"}
|
sort_options = {"newest", "oldest", "popular"}
|
||||||
sort_by ||= "newest"
|
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 }
|
items.select! { |item| !item.paid }
|
||||||
|
|
||||||
env.set "search", "channel:#{channel.ucid} "
|
env.set "search", "channel:#{channel.ucid} "
|
||||||
|
@ -3544,7 +3544,7 @@ get "/api/v1/channels/:ucid" do |env|
|
||||||
count = 0
|
count = 0
|
||||||
else
|
else
|
||||||
begin
|
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
|
rescue ex
|
||||||
error_message = {"error" => ex.message}.to_json
|
error_message = {"error" => ex.message}.to_json
|
||||||
env.response.status_code = 500
|
env.response.status_code = 500
|
||||||
|
@ -3669,7 +3669,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
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
|
rescue ex
|
||||||
error_message = {"error" => ex.message}.to_json
|
error_message = {"error" => ex.message}.to_json
|
||||||
env.response.status_code = 500
|
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)
|
search_params = produce_search_params(sort_by, date, content_type, duration, features)
|
||||||
rescue ex
|
rescue ex
|
||||||
env.response.status_code = 400
|
env.response.status_code = 400
|
||||||
next JSON.build do |json|
|
error_message = {"error" => ex.message}.to_json
|
||||||
json.object do
|
next error_message
|
||||||
json.field "error", ex.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
count, search_results = search(query, page, search_params, region).as(Tuple)
|
count, search_results = search(query, page, search_params, region).as(Tuple)
|
||||||
|
|
|
@ -729,7 +729,7 @@ def get_about_info(ucid, locale)
|
||||||
)
|
)
|
||||||
end
|
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
|
count = 0
|
||||||
videos = [] of SearchVideo
|
videos = [] of SearchVideo
|
||||||
|
|
||||||
|
@ -751,7 +751,7 @@ def get_60_videos(ucid, page, auto_generated, sort_by = "newest")
|
||||||
if auto_generated
|
if auto_generated
|
||||||
videos += extract_videos(nodeset)
|
videos += extract_videos(nodeset)
|
||||||
else
|
else
|
||||||
videos += extract_videos(nodeset, ucid)
|
videos += extract_videos(nodeset, ucid, author)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue