aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-12-03 22:38:58 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-12-03 22:38:58 +0100
commit1bcebadef3b0ac836b3f0b8ee5df30f7c493cf38 (patch)
tree3fd4b9b2cf86341558e2f648c3f953aefcdcd155 /src
parent5b00f59ba1451b9d1dfbe7cb8a3d0dbc28c7d170 (diff)
feat: add fallback tab to paginated channel api handler
Diffstat (limited to 'src')
-rw-r--r--src/backend/tubo/api.clj55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/backend/tubo/api.clj b/src/backend/tubo/api.clj
index 3c0ba2e..802057f 100644
--- a/src/backend/tubo/api.clj
+++ b/src/backend/tubo/api.clj
@@ -73,19 +73,19 @@
(defn get-channel
([url]
- (let [info (ChannelInfo/getInfo (url-decode url))
- service (NewPipe/getServiceByUrl (url-decode url))
- preloaded-videos-tab (->> (.getTabs info)
- (filter #(instance?
- ReadyChannelTabListLinkHandler
- %))
- (filter #(some #{ChannelTabs/VIDEOS}
- (.getContentFilters %)))
- first)
- tab-info (ChannelTabInfo/getInfo
- service
- (or preloaded-videos-tab
- (first (.getTabs info))))]
+ (let [info (ChannelInfo/getInfo (url-decode url))
+ service (NewPipe/getServiceByUrl (url-decode url))
+ videos-tab (->> (.getTabs info)
+ (filter #(instance?
+ ReadyChannelTabListLinkHandler
+ %))
+ (filter #(some #{ChannelTabs/VIDEOS}
+ (.getContentFilters %)))
+ first)
+ tab-info (ChannelTabInfo/getInfo
+ service
+ (or videos-tab
+ (first (.getTabs info))))]
{:name (.getName info)
:service-id (.getServiceId info)
:id (.getId info)
@@ -100,19 +100,20 @@
:related-streams (when tab-info
(get-items (.getRelatedItems tab-info)))}))
([url page-url]
- (let [channel-info (ChannelInfo/getInfo (url-decode url))
- service (NewPipe/getServiceByUrl (url-decode url))
- preloaded-videos-tab (->> (.getTabs channel-info)
- (filter #(instance?
- ReadyChannelTabListLinkHandler
- %))
- (filter #(some #{ChannelTabs/VIDEOS}
- (.getContentFilters %)))
- first)
- tab-info (ChannelTabInfo/getMoreItems service
- preloaded-videos-tab
- (Page. (url-decode
- page-url)))]
+ (let [channel-info (ChannelInfo/getInfo (url-decode url))
+ service (NewPipe/getServiceByUrl (url-decode url))
+ videos-tab (->> (.getTabs channel-info)
+ (filter #(instance?
+ ReadyChannelTabListLinkHandler
+ %))
+ (filter #(some #{ChannelTabs/VIDEOS}
+ (.getContentFilters %)))
+ first)
+ tab-info (ChannelTabInfo/getMoreItems
+ service
+ (or videos-tab (first (.getTabs channel-info)))
+ (Page. (url-decode
+ page-url)))]
{:related-streams (get-items (.getRelatedItems tab-info))
:next-page (j/from-java (.getNextPage tab-info))})))
@@ -207,6 +208,8 @@
:uploader-url (.getUploaderUrl item)
:uploader-avatars (j/from-java (.getUploaderAvatars item))
:uploader-verified? (.isUploaderVerified item)
+ :creator-reply? (.hasCreatorReply item)
+ :channel-owner? (.isChannelOwner item)
:like-count (non-negative (.getLikeCount item))
:reply-count (non-negative (.getReplyCount item))
:hearted-by-uploader? (.isHeartedByUploader item)