summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrahim Hadriche <brahim.hadriche@gmail.com>2024-10-30 13:38:13 -0400
committerBrahim Hadriche <brahim.hadriche@gmail.com>2024-10-30 13:38:13 -0400
commitc243d08afb8509f7a98cd7aa1b77d4f409a7a823 (patch)
treee3d9670d69cd5a4307fdf800001b354ee48920b9
parentee728092823d8e82f71f35c31da8a27efec0f1b5 (diff)
downloadinvidious-c243d08afb8509f7a98cd7aa1b77d4f409a7a823.tar.gz
invidious-c243d08afb8509f7a98cd7aa1b77d4f409a7a823.tar.bz2
invidious-c243d08afb8509f7a98cd7aa1b77d4f409a7a823.zip
refactor
-rw-r--r--src/invidious/channels/videos.cr47
1 files changed, 18 insertions, 29 deletions
diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr
index e29d80ed..bcdc8d8f 100644
--- a/src/invidious/channels/videos.cr
+++ b/src/invidious/channels/videos.cr
@@ -23,6 +23,13 @@ def produce_channel_content_continuation(ucid, content_type, page = 1, auto_gene
else 15 # Fallback to "videos"
end
+ sort_type_numerical =
+ case content_type
+ when "videos" then 3
+ when "livestreams" then 5
+ else 3 # Fallback to "videos"
+ end
+
if content_type == "livestreams"
sort_by_numerical =
case sort_by
@@ -41,39 +48,21 @@ def produce_channel_content_continuation(ucid, content_type, page = 1, auto_gene
end
end
- if content_type == "livestreams"
- object_inner_1 = {
- "110:embedded" => {
- "3:embedded" => {
- "#{content_type_numerical}:embedded" => {
- "1:embedded" => {
- "1:string" => object_inner_2_encoded,
- },
- "2:embedded" => {
- "1:string" => "00000000-0000-0000-0000-000000000000",
- },
- "5:varint" => sort_by_numerical,
+ object_inner_1 = {
+ "110:embedded" => {
+ "3:embedded" => {
+ "#{content_type_numerical}:embedded" => {
+ "1:embedded" => {
+ "1:string" => object_inner_2_encoded,
},
- },
- },
- }
- else
- object_inner_1 = {
- "110:embedded" => {
- "3:embedded" => {
- "#{content_type_numerical}:embedded" => {
- "1:embedded" => {
- "1:string" => object_inner_2_encoded,
- },
- "2:embedded" => {
- "1:string" => "00000000-0000-0000-0000-000000000000",
- },
- "3:varint" => sort_by_numerical,
+ "2:embedded" => {
+ "1:string" => "00000000-0000-0000-0000-000000000000",
},
+ "#{sort_type_numerical}:varint" => sort_by_numerical,
},
},
- }
- end
+ },
+ }
object_inner_1_encoded = object_inner_1
.try { |i| Protodec::Any.cast_json(i) }