API: Add "sort_by" parameter to channels/shorts endpoint (#5071)

Small follow up to PR 5059

No related issue
This commit is contained in:
Samantaz Fox 2024-11-10 17:50:00 +01:00
commit d42561d74a
No known key found for this signature in database
GPG Key ID: F42821059186176E
1 changed files with 2 additions and 1 deletions

View File

@ -197,6 +197,7 @@ module Invidious::Routes::API::V1::Channels
get_channel() get_channel()
# Retrieve continuation from URL parameters # Retrieve continuation from URL parameters
sort_by = env.params.query["sort_by"]?.try &.downcase || "newest"
continuation = env.params.query["continuation"]? continuation = env.params.query["continuation"]?
if channel.is_age_gated if channel.is_age_gated
@ -211,7 +212,7 @@ module Invidious::Routes::API::V1::Channels
else else
begin begin
videos, next_continuation = Channel::Tabs.get_shorts( videos, next_continuation = Channel::Tabs.get_shorts(
channel, continuation: continuation channel, continuation: continuation, sort_by: sort_by
) )
rescue ex rescue ex
return error_json(500, ex) return error_json(500, ex)