summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-11-12 00:09:03 +0100
committerSamantaz Fox <coding@samantaz.fr>2022-12-22 16:13:34 +0100
commit52ef89f02d0ab29fd0f218abc4051328b3d96809 (patch)
treeec7b650b23213a94140d36b1df0de7bcb249310e
parent2903e896ecf2404bf932438a33432125a6ad1fca (diff)
downloadinvidious-52ef89f02d0ab29fd0f218abc4051328b3d96809.tar.gz
invidious-52ef89f02d0ab29fd0f218abc4051328b3d96809.tar.bz2
invidious-52ef89f02d0ab29fd0f218abc4051328b3d96809.zip
channel: Add support for shorts and livestreams (backend only)
-rw-r--r--src/invidious/channels/videos.cr50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr
index 23ad4e02..bea406c1 100644
--- a/src/invidious/channels/videos.cr
+++ b/src/invidious/channels/videos.cr
@@ -122,4 +122,54 @@ module Invidious::Channel::Tabs
return items, next_continuation
end
+
+ # -------------------
+ # Shorts
+ # -------------------
+
+ def get_shorts(channel : AboutChannel, continuation : String? = nil)
+ if continuation.nil?
+ # EgZzaG9ydHPyBgUKA5oBAA%3D%3D is the protobuf object to load "shorts"
+ # TODO: try to extract the continuation tokens that allows other sorting options
+ initial_data = YoutubeAPI.browse(channel.ucid, params: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D")
+ else
+ initial_data = YoutubeAPI.browse(continuation: continuation)
+ end
+
+ return extract_items(initial_data, channel.author, channel.ucid)
+ end
+
+ # -------------------
+ # Livestreams
+ # -------------------
+
+ def get_livestreams(channel : AboutChannel, continuation : String? = nil)
+ if continuation.nil?
+ # EgdzdHJlYW1z8gYECgJ6AA%3D%3D is the protobuf object to load "streams"
+ initial_data = YoutubeAPI.browse(channel.ucid, params: "EgdzdHJlYW1z8gYECgJ6AA%3D%3D")
+ else
+ initial_data = YoutubeAPI.browse(continuation: continuation)
+ end
+
+ return extract_items(initial_data, channel.author, channel.ucid)
+ end
+
+ def get_60_livestreams(channel : AboutChannel, continuation : String? = nil)
+ if continuation.nil?
+ # Fetch the first "page" of streams
+ items, next_continuation = get_livestreams(channel)
+ else
+ # Fetch a "page" of streams using the given continuation token
+ items, next_continuation = get_livestreams(channel, continuation: continuation)
+ end
+
+ # If there is more to load, then load a second "page"
+ # and replace the previous continuation token
+ if !next_continuation.nil?
+ items_2, next_continuation = get_livestreams(channel, continuation: next_continuation)
+ items.concat items_2
+ end
+
+ return items, next_continuation
+ end
end