From 842f8b70cfc06b946c88c64d21266de0c908d914 Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 19 Mar 2023 20:18:09 +0000 Subject: [PATCH] browse/channel: fix popular sorting don't rely on the fallback to support most popular videos. --- app/browse/protobuf.py | 63 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/app/browse/protobuf.py b/app/browse/protobuf.py index 703aaf1..ce24f2c 100644 --- a/app/browse/protobuf.py +++ b/app/browse/protobuf.py @@ -68,6 +68,44 @@ class ChannelDataInner: @dataclass class ChannelDataContainer: data: str = field(1) # base64 of ChannelDataInner + +@message +@dataclass +class NewChannelUserInfoInner: + field1: int = field(1, default=0) +@message +@dataclass +class NewChannelUserInfo: + offset: int = field(7) + field2: NewChannelUserInfoInner = field(2, default=NewChannelUserInfoInner()) # otherwise page>=2 fails + field10: int = field(10, default=0) # otherwise 'newest' fails + # youtube sets those, but works without (values from invidious, yt's are dynamic): + #field5: int = field(5, default=50) + #field6: int = field(6, default=1) + #field9: int = field(9, default=1) +@message +@dataclass +class NewChannelDataUser: + data: str = field(1) # b64 + uuid: str = field(2) +@message +@dataclass +class NewChannelDataSort: + user: NewChannelDataUser = field(1) + sort: int64 = field(3, default=1) # newest +@message +@dataclass +class NewChannelDataInner: + data: NewChannelDataSort = field(15) +@message +@dataclass +class NewChannelDataContainer: + data: NewChannelDataInner = field(3) +@message +@dataclass +class NewChannelDataContainerOuter: + data: NewChannelDataContainer = field(110) + @message @dataclass class Subparams: @@ -90,6 +128,8 @@ class Params: subject: str = field(2) # ucid/plid params: str = field(3) # b64e encoded query: Optional[str] = field(11, default=None) # channel search + # defined by invidious, but not sent by youtube with NewChannel* structs: + #param35: Optional[str] = field(35, default=None) # "browse-feed#{ucid}videos102" @message @dataclass class Continuation: @@ -97,11 +137,32 @@ class Continuation: def make_channel_params(subject, typ="videos", page=1, sort=None, query=None, v3=False): typestr = dict(videos="videos", playlists="playlists", search="search") typeint = dict(videos=0, playlists=1, search=None) # not supporting autogen'd - sortorder = dict(popular=1, oldest=2, newest=3) + sortorder = dict(newest=1, popular=2) if typ == "playlists": sortorder = dict(newest=3, modified=4) elif typ == "search": sortorder = dict() + elif typ == "videos": # XXX: should be better integrated + return b64e(Continuation( + params=Params( + subject=subject, + params=b64e(NewChannelDataContainerOuter( + data=NewChannelDataContainer( + data=NewChannelDataInner( + data=NewChannelDataSort( + user=NewChannelDataUser( + data=b64e(NewChannelUserInfo( + offset= page*30, + ).dumps(), padding=False), + uuid="00000000-0000-0000-0000-000000000000" + ), + sort=sortorder.get(sort, 1) + ) + ) + ) + ).dumps()) + ) + ).dumps()) if page and typ=="search": _page = b64e(SearchOffset(offset=(page-1)*30).dumps(), padding=False) -- 2.39.3