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
|
||||
|
||||
Reference in new issue
Block a user