OAuth: recommended feed
This commit is contained in:
1 parent
fb030cee97
commit
e821464451
9 files changed
+138
-3
No files matched your search
+1
-1
@@ -19,7 +19,7 @@
|
||||
<CheckList
|
||||
id="checkList"
|
||||
vertFocusAnimationStyle="floatingFocus"
|
||||
translation="[164,70]">
|
||||
translation="[164,40]">
|
||||
|
||||
<ContentNode role="content" />
|
||||
</CheckList>
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Innertube
|
||||
"reelShelfRenderer": ParseReelShelfRenderer
|
||||
"verticalListRenderer": ParseVerticalListRenderer
|
||||
"horizontalListRenderer": ParseHorizontalListRenderer
|
||||
"horizontalListContinuation": ParseHorizontalListContinuation
|
||||
"expandedShelfContentsRenderer": ParseExpandedShelfContentsRenderer
|
||||
"channelFeaturedContentRenderer": ParseChannelFeaturedContentRenderer
|
||||
"playlistVideoListRenderer": ParsePlaylistVideoListRenderer
|
||||
@@ -103,6 +104,9 @@ namespace Innertube
|
||||
"messageRenderer": ParseNotImplemented
|
||||
' Messages like "Videos you watch will be saved here"
|
||||
"genericPromoRenderer": ParseNotImplemented
|
||||
' "Sign in to see the latest videos tailored to your interests"
|
||||
"feedNudgeRenderer": ParseNotImplemented
|
||||
"searchBarRenderer": ParseNotImplemented
|
||||
"clickTrackingParams": ParseNotImplemented
|
||||
"promoShelfRenderer": ParseNotImplemented
|
||||
"adSlotRenderer": ParseNotImplemented
|
||||
@@ -181,8 +185,25 @@ namespace Innertube
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
function ParseHorizontalListRenderer(nodeData as object, _context as object) as object
|
||||
' TODO: handle continuations
|
||||
function ParseHorizontalListRenderer(nodeData as object, context as object) as object
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
|
||||
StartNewFeed("", context)
|
||||
end if
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
function ParseHorizontalListContinuation(nodeData as object, context as object) as object
|
||||
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||
if IsString(continuation)
|
||||
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
|
||||
StartNewFeed("", context)
|
||||
end if
|
||||
context.currentFeed.continuation = continuation
|
||||
end if
|
||||
return nodeData["items"]
|
||||
end function
|
||||
|
||||
|
||||
@@ -122,6 +122,29 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
||||
isDirty = true
|
||||
end if
|
||||
|
||||
#if YT_OAUTH_SUPPORT
|
||||
if userPrefs.__version = 2
|
||||
if IsArray(userPrefs["misc.home_screen_layout"])
|
||||
homeScreenLayout = userPrefs["misc.home_screen_layout"]
|
||||
hasRecommended = false
|
||||
for each item in homeScreenLayout
|
||||
if item.id = "recommended"
|
||||
hasRecommended = true
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
if not hasRecommended
|
||||
homeScreenLayout.Unshift({
|
||||
id: "recommended"
|
||||
enabled: true
|
||||
})
|
||||
end if
|
||||
end if
|
||||
userPrefs.__version = 3
|
||||
isDirty = true
|
||||
end if
|
||||
#end if
|
||||
|
||||
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
||||
return isDirty
|
||||
end function
|
||||
|
||||
+60
@@ -284,6 +284,11 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
isRecommended = request.query.recommended = "true"
|
||||
if isRecommended
|
||||
return m.GetAuthRecommended(context)
|
||||
end if
|
||||
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
@@ -319,6 +324,61 @@ namespace Http
|
||||
return true
|
||||
end function
|
||||
|
||||
function GetAuthRecommended(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
accessToken = request.headers["authorization"]
|
||||
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
|
||||
response.Json({
|
||||
"error": "Missing or invalid 'Authorization' header"
|
||||
})
|
||||
response.http_code = 403
|
||||
return true
|
||||
end if
|
||||
|
||||
options = {
|
||||
"accessToken": accessToken.Mid("Bearer ".Len())
|
||||
}
|
||||
|
||||
continuation = request.query.continuation
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
options.continuation = continuation
|
||||
end if
|
||||
|
||||
feeds = InnertubeService.GetHome(options)
|
||||
if feeds = invalid
|
||||
response.Json({
|
||||
"error": "Failed to get auth home feed"
|
||||
})
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
|
||||
if IsAssociativeArray(feeds)
|
||||
if feeds.error <> invalid
|
||||
response.Json(feeds)
|
||||
response.http_code = 500
|
||||
return true
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
|
||||
result = {
|
||||
"items": []
|
||||
}
|
||||
|
||||
if feeds.Count() > 0
|
||||
result["items"] = ValidArray(feeds[0].items)
|
||||
if feeds[0].DoesExist("continuation")
|
||||
result["continuation"] = feeds[0].continuation
|
||||
end if
|
||||
end if
|
||||
|
||||
response.Json(result)
|
||||
return true
|
||||
end function
|
||||
|
||||
@get("/playlet-invidious-backend/api/v1/search/suggestions")
|
||||
function GetSearchSuggestions(context as object) as boolean
|
||||
request = context.request
|
||||
|
||||
@@ -6,6 +6,14 @@
|
||||
apiType: Invidious
|
||||
endpoint: auth_feed
|
||||
|
||||
- title: Recommended
|
||||
id: recommended
|
||||
feedSources:
|
||||
- id: inv_auth_recommended
|
||||
title: Recommended
|
||||
apiType: Invidious
|
||||
endpoint: auth_recommended
|
||||
|
||||
- title: Trending
|
||||
id: trending
|
||||
feedSources:
|
||||
|
||||
@@ -187,3 +187,16 @@ watch_history:
|
||||
authenticated: true
|
||||
paginationType: Pages
|
||||
responseHandler: WatchHistoryHandler
|
||||
|
||||
# Recommended is not a thing for Invidious, but we can use
|
||||
# /api/v1/popular?recommended=true and handle it in Playlet
|
||||
# backend. Invidious will just ignore the query param.
|
||||
auth_recommended:
|
||||
title: Recommended
|
||||
url: /api/v1/popular
|
||||
authenticated: true
|
||||
paginationType: Continuation
|
||||
queryParams:
|
||||
recommended:
|
||||
type: boolean
|
||||
default: true
|
||||
@@ -152,6 +152,11 @@
|
||||
id: "subscriptions",
|
||||
enabled: true,
|
||||
},
|
||||
// YT_OAUTH_SUPPORT
|
||||
// {
|
||||
// id: "recommended",
|
||||
// enabled: true,
|
||||
// },
|
||||
{
|
||||
id: "trending",
|
||||
enabled: true,
|
||||
|
||||
@@ -76,6 +76,10 @@
|
||||
<source>Subscriptions</source>
|
||||
<translation>Subscriptions</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Recommended</source>
|
||||
<translation>Recommended</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Playlists</source>
|
||||
<translation>Playlists</translation>
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Locale
|
||||
@locale
|
||||
enum Feed
|
||||
Subscriptions = "Subscriptions"
|
||||
Recommended = "Recommended"
|
||||
Playlists = "Playlists"
|
||||
WatchHistory = "Watch history"
|
||||
Trending = "Trending"
|
||||
|
||||
Reference in new issue
Block a user