Fix for recommended feed (UPCOMING) (#790)

* Fix for recommended feed (UPCOMING)

* Rename var

* typo
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2025-11-12 09:34:03 -05:00
1 parent d42d783738
commit 9e3363f22c
4 files changed
+33 -10

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Small change in post-live dvr detection - Small change in post-live dvr detection
- Issue where recommended videos are all "UPCOMING" paid content
## [0.44.0] - 2025-11-09 ## [0.44.0] - 2025-11-09
@@ -272,6 +272,7 @@ namespace InnertubeService
trendingType = LCase(OptionUtils.GetOrDefault(options, "type", "")) trendingType = LCase(OptionUtils.GetOrDefault(options, "type", ""))
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false) disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
raw = OptionUtils.GetOrDefault(options, "raw", false) raw = OptionUtils.GetOrDefault(options, "raw", false)
browseId = "FEtrending"
params = "" params = ""
if trendingType = "music" if trendingType = "music"
@@ -285,7 +286,7 @@ namespace InnertubeService
params = "4gIKGgh0cmFpbGVycw%3D%3D" params = "4gIKGgh0cmFpbGVycw%3D%3D"
end if end if
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, { params: params }) request = Innertube.CreateBrowseRequest(browseId, Innertube.ClientType.WEB, { params: params })
request.Cancellation(cancellation) request.Cancellation(cancellation)
if raw if raw
@@ -308,6 +309,7 @@ namespace InnertubeService
response: response response: response
disableCreatorOnTheRise: true disableCreatorOnTheRise: true
disableShorts: disableShorts disableShorts: disableShorts
browseId: browseId
}) })
result = { result = {
@@ -338,12 +340,12 @@ namespace InnertubeService
return GetBrowseAuthenticatedPage("FEplaylist_aggregation", options) return GetBrowseAuthenticatedPage("FEplaylist_aggregation", options)
end function end function
function GetBrowseAuthenticatedPage(browserId as string, options = invalid as object) as object function GetBrowseAuthenticatedPage(browseId as string, options = invalid as object) as object
cancellation = OptionUtils.Get(options, "cancellation") cancellation = OptionUtils.Get(options, "cancellation")
accessToken = OptionUtils.Get(options, "accessToken") accessToken = OptionUtils.Get(options, "accessToken")
disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false) disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, options) request = Innertube.CreateBrowseRequest(browseId, Innertube.ClientType.Tv, options)
if accessToken <> invalid if accessToken <> invalid
request.Header("Authorization", "Bearer " + accessToken) request.Header("Authorization", "Bearer " + accessToken)
@@ -360,6 +362,7 @@ namespace InnertubeService
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
response: response response: response
disableShorts: disableShorts disableShorts: disableShorts
browseId: browseId
}) })
result = { result = {
@@ -521,7 +524,7 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
result = Innertube.ParseChannelPageResponseData(response.Json(), response) result = Innertube.ParseChannelPageResponseData(channelId, response.Json(), response)
if result.authorId = invalid and result.error = invalid if result.authorId = invalid and result.error = invalid
result["authorId"] = channelId result["authorId"] = channelId
end if end if
@@ -663,7 +666,7 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
result = Innertube.ParsePlaylistPageResponseData(response.Json(), response) result = Innertube.ParsePlaylistPageResponseData(playlistId, response.Json(), response)
if result.playlistId = invalid and result.error = invalid if result.playlistId = invalid and result.error = invalid
result["playlistId"] = playlistId result["playlistId"] = playlistId
@@ -276,6 +276,17 @@ namespace Innertube
end if end if
end if end if
if ValidString(context.browseId) = "FEwhat_to_watch"
' shelfs with a heroCarouselHeaderRenderer are usually big carousels at the top of the home page
' to advertise some paid content.
' They hijack the shelf we want to parse (e.g. Recommended videos).
heroCarouselHeader = ObjectUtils.Dig(nodeData, ["headerRenderer", "heroCarouselHeaderRenderer"])
if heroCarouselHeader <> invalid
LogInfo("Skipping shelf with heroCarouselHeaderRenderer")
return invalid
end if
end if
' TODO: handle shelfRenderer.title ' TODO: handle shelfRenderer.title
' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title ' TODO: handle shelfRenderer.headerRenderer.shelfHeaderRenderer.avatarLockup.avatarLockupRenderer.title
return nodeData["content"] return nodeData["content"]
@@ -44,7 +44,7 @@ namespace Innertube
return context.feeds return context.feeds
end function end function
function ParseChannelPageResponseData(responseData as object, response as object) as object function ParseChannelPageResponseData(browseId as string, responseData as object, response as object) as object
if responseData = invalid if responseData = invalid
return { return {
error: "Invalid response data" error: "Invalid response data"
@@ -63,6 +63,9 @@ namespace Innertube
author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"]) author = ObjectUtils.Dig(responseData, ["header", "pageHeaderRenderer", "pageTitle"])
end if end if
authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"]) authorId = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "externalId"])
if StringUtils.IsNullOrEmpty(authorId)
authorId = browseId
end if
thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"]) thumbnails = ObjectUtils.Dig(responseData, ["metadata", "channelMetadataRenderer", "avatar", "thumbnails"])
if thumbnails = invalid if thumbnails = invalid
@@ -149,6 +152,7 @@ namespace Innertube
response: response response: response
"currentAuthor": author "currentAuthor": author
"currentAuthorId": authorId "currentAuthorId": authorId
browseId: browseId
}) })
if feeds.Count() > 0 if feeds.Count() > 0
items = ValidArray(feeds[0].items) items = ValidArray(feeds[0].items)
@@ -183,7 +187,7 @@ namespace Innertube
return channel return channel
end function end function
function ParsePlaylistPageResponseData(responseData as object, response as object) as object function ParsePlaylistPageResponseData(browseId as string, responseData as object, response as object) as object
if responseData = invalid if responseData = invalid
return { return {
error: "Invalid response data" error: "Invalid response data"
@@ -251,13 +255,16 @@ namespace Innertube
end if end if
end if end if
if StringUtils.IsNullOrEmpty(playlistId)
playlistId = browseId
end if
playlist = { playlist = {
"playlistId": playlistId
"videoCount": videoCount "videoCount": videoCount
"videos": [] "videos": []
} }
if playlistId <> invalid
playlist["playlistId"] = playlistId
end if
if title <> invalid if title <> invalid
playlist["title"] = title playlist["title"] = title
end if end if
@@ -279,6 +286,7 @@ namespace Innertube
feeds = ParseResponseDataForFeeds(responseData, { feeds = ParseResponseDataForFeeds(responseData, {
response: response response: response
browseId: browseId
}) })
if feeds.Count() > 0 if feeds.Count() > 0
playlist["videos"] = ValidArray(feeds[0].items) playlist["videos"] = ValidArray(feeds[0].items)