Private playlists, continuation
This commit is contained in:
1 parent
9b58bf47ad
commit
b38f105e02
7 files changed
+176
-16
No files matched your search
@@ -60,7 +60,12 @@ function PlaylistContentTask(input as object) as object
|
|||||||
videoCount = ValidInt(metadata.videoCount)
|
videoCount = ValidInt(metadata.videoCount)
|
||||||
|
|
||||||
hasContinuation = not StringUtils.IsNullOrEmpty(metadata.continuation)
|
hasContinuation = not StringUtils.IsNullOrEmpty(metadata.continuation)
|
||||||
if (hadContinuation and not hasContinuation) or (metadata.videos.Count() = 0 or childCount >= videoCount)
|
|
||||||
|
noMoreContinuation = hadContinuation and not hasContinuation
|
||||||
|
noVideosReturned = metadata.videos.Count() = 0
|
||||||
|
reachedVideoCount = videoCount <> -1 and childCount >= videoCount
|
||||||
|
|
||||||
|
if noMoreContinuation or noVideosReturned or reachedVideoCount
|
||||||
contentNode.loadState = FeedLoadState.Loaded
|
contentNode.loadState = FeedLoadState.Loaded
|
||||||
return {
|
return {
|
||||||
success: true
|
success: true
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ namespace InnertubeService
|
|||||||
continuation = ""
|
continuation = ""
|
||||||
cancellation = invalid
|
cancellation = invalid
|
||||||
raw = false
|
raw = false
|
||||||
|
accessToken = invalid
|
||||||
|
|
||||||
if options <> invalid
|
if options <> invalid
|
||||||
if options.DoesExist("continuation")
|
if options.DoesExist("continuation")
|
||||||
@@ -400,14 +401,25 @@ namespace InnertubeService
|
|||||||
if options.DoesExist("raw")
|
if options.DoesExist("raw")
|
||||||
raw = options.raw
|
raw = options.raw
|
||||||
end if
|
end if
|
||||||
|
if options.DoesExist("accessToken")
|
||||||
|
accessToken = options.accessToken
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if not playlistId.StartsWith("VL")
|
if not playlistId.StartsWith("VL")
|
||||||
playlistId = "VL" + playlistId
|
playlistId = "VL" + playlistId
|
||||||
end if
|
end if
|
||||||
|
|
||||||
request = Innertube.CreateBrowseRequest(playlistId, Innertube.ClientType.Web, "", continuation)
|
client = Innertube.ClientType.Web
|
||||||
|
if accessToken <> invalid
|
||||||
|
client = Innertube.ClientType.Tv
|
||||||
|
end if
|
||||||
|
|
||||||
|
request = Innertube.CreateBrowseRequest(playlistId, client, "", continuation)
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
if accessToken <> invalid
|
||||||
|
request.Header("Authorization", "Bearer " + accessToken)
|
||||||
|
end if
|
||||||
if raw
|
if raw
|
||||||
request.LogCurlCommand()
|
request.LogCurlCommand()
|
||||||
request.NoCache()
|
request.NoCache()
|
||||||
@@ -426,6 +438,10 @@ namespace InnertubeService
|
|||||||
|
|
||||||
result = Innertube.ParsePlaylistPageResponseData(response.Json())
|
result = Innertube.ParsePlaylistPageResponseData(response.Json())
|
||||||
|
|
||||||
|
if result.playlistId = invalid and result.error = invalid
|
||||||
|
result["playlistId"] = playlistId
|
||||||
|
end if
|
||||||
|
|
||||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||||
if cacheControl <> invalid
|
if cacheControl <> invalid
|
||||||
result["cache-control"] = cacheControl
|
result["cache-control"] = cacheControl
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace Innertube
|
|||||||
"expandedShelfContentsRenderer": ParseExpandedShelfContentsRenderer
|
"expandedShelfContentsRenderer": ParseExpandedShelfContentsRenderer
|
||||||
"channelFeaturedContentRenderer": ParseChannelFeaturedContentRenderer
|
"channelFeaturedContentRenderer": ParseChannelFeaturedContentRenderer
|
||||||
"playlistVideoListRenderer": ParsePlaylistVideoListRenderer
|
"playlistVideoListRenderer": ParsePlaylistVideoListRenderer
|
||||||
|
"playlistVideoListContinuation": ParsePlaylistVideoListContinuation
|
||||||
"videoRenderer": ParseVideoRenderer
|
"videoRenderer": ParseVideoRenderer
|
||||||
"gridVideoRenderer": ParseGridVideoRenderer
|
"gridVideoRenderer": ParseGridVideoRenderer
|
||||||
"channelVideoPlayerRenderer": ParseChannelVideoPlayerRenderer
|
"channelVideoPlayerRenderer": ParseChannelVideoPlayerRenderer
|
||||||
@@ -74,6 +75,7 @@ namespace Innertube
|
|||||||
"tvSurfaceContentRenderer": ParseTvSurfaceContentRenderer
|
"tvSurfaceContentRenderer": ParseTvSurfaceContentRenderer
|
||||||
"tvSecondaryNavRenderer": ParseTvSecondaryNavRenderer
|
"tvSecondaryNavRenderer": ParseTvSecondaryNavRenderer
|
||||||
"tvSecondaryNavSectionRenderer": ParseTvSecondaryNavSectionRenderer
|
"tvSecondaryNavSectionRenderer": ParseTvSecondaryNavSectionRenderer
|
||||||
|
"twoColumnRenderer": ParseTwoColumnRenderer
|
||||||
"tileRenderer": ParseTileRenderer
|
"tileRenderer": ParseTileRenderer
|
||||||
"gridRenderer": ParseGridRenderer
|
"gridRenderer": ParseGridRenderer
|
||||||
"richGridRenderer": ParseRichGridRenderer
|
"richGridRenderer": ParseRichGridRenderer
|
||||||
@@ -192,7 +194,19 @@ namespace Innertube
|
|||||||
return nodeData["items"]
|
return nodeData["items"]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ParsePlaylistVideoListRenderer(nodeData as object, _context as object) as object
|
function ParsePlaylistVideoListRenderer(nodeData as object, context as object) as object
|
||||||
|
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||||
|
if IsString(continuation)
|
||||||
|
context.currentFeed.continuation = continuation
|
||||||
|
end if
|
||||||
|
return nodeData["contents"]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParsePlaylistVideoListContinuation(nodeData as object, context as object) as object
|
||||||
|
continuation = ObjectUtils.Dig(nodeData, ["continuations", 0, "nextContinuationData", "continuation"])
|
||||||
|
if IsString(continuation)
|
||||||
|
context.currentFeed.continuation = continuation
|
||||||
|
end if
|
||||||
return nodeData["contents"]
|
return nodeData["contents"]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -882,6 +896,13 @@ namespace Innertube
|
|||||||
return nodeData["tabs"]
|
return nodeData["tabs"]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ParseTwoColumnRenderer(nodeData as object, context as object) as object
|
||||||
|
' twoColumnRenderer is used for Playlists on TV.
|
||||||
|
' The right column has the videos (and continuation)
|
||||||
|
' The left column has the playlist info (title, description, etc) which was already parsed
|
||||||
|
return nodeData["rightColumn"]
|
||||||
|
end function
|
||||||
|
|
||||||
function ParseTileRenderer(nodeData as object, context as object) as object
|
function ParseTileRenderer(nodeData as object, context as object) as object
|
||||||
contentType = ValidString(nodeData["contentType"])
|
contentType = ValidString(nodeData["contentType"])
|
||||||
if contentType = "TILE_CONTENT_TYPE_VIDEO"
|
if contentType = "TILE_CONTENT_TYPE_VIDEO"
|
||||||
@@ -1042,6 +1063,44 @@ namespace Innertube
|
|||||||
return ""
|
return ""
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ParseLineRenderer(data as object) as string
|
||||||
|
if data = invalid
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
if IsString(data)
|
||||||
|
return data
|
||||||
|
end if
|
||||||
|
if not IsAssociativeArray(data) or not data.DoesExist("items")
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
items = data["items"]
|
||||||
|
if not IsArray(items)
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
texts = []
|
||||||
|
for each item in items
|
||||||
|
if IsString(item)
|
||||||
|
texts.Push(item)
|
||||||
|
else if IsAssociativeArray(item) and item.DoesExist("lineItemRenderer")
|
||||||
|
texts.Push(ParseLineItemRenderer(item["lineItemRenderer"]))
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return texts.Join(" ")
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseLineItemRenderer(data as object) as string
|
||||||
|
if data = invalid
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
if IsString(data)
|
||||||
|
return data
|
||||||
|
end if
|
||||||
|
if not IsAssociativeArray(data) or not data.DoesExist("text")
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
return ParseText(data["text"])
|
||||||
|
end function
|
||||||
|
|
||||||
function StartNewFeed(title as string, context as object) as void
|
function StartNewFeed(title as string, context as object) as void
|
||||||
if context.currentFeed <> invalid
|
if context.currentFeed <> invalid
|
||||||
if context.currentFeed.items.Count() = 0 and context.currentFeed.title = ""
|
if context.currentFeed.items.Count() = 0 and context.currentFeed.title = ""
|
||||||
|
|||||||
@@ -184,8 +184,17 @@ namespace Innertube
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
playlistSidebarRendererItems = ObjectUtils.Dig(responseData, ["sidebar", "playlistSidebarRenderer", "items"])
|
playlistId = invalid
|
||||||
|
title = invalid
|
||||||
|
author = invalid
|
||||||
|
authorId = invalid
|
||||||
|
description = invalid
|
||||||
|
videoCount = -1
|
||||||
|
thumbnail = invalid
|
||||||
|
statsText = invalid
|
||||||
|
|
||||||
|
playlistSidebarRendererItems = ObjectUtils.Dig(responseData, ["sidebar", "playlistSidebarRenderer", "items"])
|
||||||
|
if playlistSidebarRendererItems <> invalid
|
||||||
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
|
primaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [0, "playlistSidebarPrimaryInfoRenderer"])
|
||||||
secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
|
secondaryInfo = ObjectUtils.Dig(playlistSidebarRendererItems, [1, "playlistSidebarSecondaryInfoRenderer"])
|
||||||
|
|
||||||
@@ -197,8 +206,6 @@ namespace Innertube
|
|||||||
|
|
||||||
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
|
author = ParseText(ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "title"]))
|
||||||
authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
|
authorId = ObjectUtils.Dig(secondaryInfo, ["videoOwner", "videoOwnerRenderer", "navigationEndpoint", "browseEndpoint", "browseId"])
|
||||||
|
|
||||||
statsText = ""
|
|
||||||
stats = ObjectUtils.Dig(primaryInfo, ["stats"])
|
stats = ObjectUtils.Dig(primaryInfo, ["stats"])
|
||||||
if IsArray(stats)
|
if IsArray(stats)
|
||||||
statsTexts = []
|
statsTexts = []
|
||||||
@@ -210,18 +217,52 @@ namespace Innertube
|
|||||||
end for
|
end for
|
||||||
statsText = statsTexts.Join(" • ")
|
statsText = statsTexts.Join(" • ")
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
twoColumnRenderer = ObjectUtils.Dig(responseData, ["contents", "tvBrowseRenderer", "content", "tvSurfaceContentRenderer", "content", "twoColumnRenderer"])
|
||||||
|
if twoColumnRenderer <> invalid
|
||||||
|
entityMetadataRenderer = ObjectUtils.Dig(twoColumnRenderer, ["leftColumn", "entityMetadataRenderer"])
|
||||||
|
if entityMetadataRenderer <> invalid
|
||||||
|
if title = invalid
|
||||||
|
title = ParseText(entityMetadataRenderer["title"])
|
||||||
|
end if
|
||||||
|
if statsText = invalid
|
||||||
|
statsText = ParseLineRenderer(ObjectUtils.Dig(entityMetadataRenderer, ["bylines", 0, "lineRenderer"]))
|
||||||
|
end if
|
||||||
|
if description = invalid
|
||||||
|
description = ParseText(entityMetadataRenderer["description"])
|
||||||
|
end if
|
||||||
|
if playlistId = invalid
|
||||||
|
playlistId = ObjectUtils.Dig(twoColumnRenderer, ["rightColumn", "playlistVideoListRenderer", "playlistId"])
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
playlist = {
|
playlist = {
|
||||||
"playlistId": playlistId
|
|
||||||
"title": title
|
|
||||||
"author": author
|
|
||||||
"authorId": authorId
|
|
||||||
"description": description
|
|
||||||
"videoCount": videoCount
|
"videoCount": videoCount
|
||||||
"thumbnail": thumbnail
|
|
||||||
"videos": []
|
"videos": []
|
||||||
"statsText": statsText
|
|
||||||
}
|
}
|
||||||
|
if playlistId <> invalid
|
||||||
|
playlist["playlistId"] = playlistId
|
||||||
|
end if
|
||||||
|
if title <> invalid
|
||||||
|
playlist["title"] = title
|
||||||
|
end if
|
||||||
|
if author <> invalid
|
||||||
|
playlist["author"] = author
|
||||||
|
end if
|
||||||
|
if authorId <> invalid
|
||||||
|
playlist["authorId"] = authorId
|
||||||
|
end if
|
||||||
|
if description <> invalid
|
||||||
|
playlist["description"] = description
|
||||||
|
end if
|
||||||
|
if thumbnail <> invalid
|
||||||
|
playlist["thumbnail"] = thumbnail
|
||||||
|
end if
|
||||||
|
if statsText <> invalid
|
||||||
|
playlist["statsText"] = statsText
|
||||||
|
end if
|
||||||
|
|
||||||
feeds = ParseResponseDataForFeeds(responseData)
|
feeds = ParseResponseDataForFeeds(responseData)
|
||||||
if feeds.Count() > 0
|
if feeds.Count() > 0
|
||||||
@@ -231,6 +272,10 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if playlist["thumbnail"] = invalid and playlist["videos"].Count() > 0
|
||||||
|
playlist["thumbnail"] = ObjectUtils.Dig(playlist, ["videos", 0, "thumbnails", 0, "url"])
|
||||||
|
end if
|
||||||
|
|
||||||
return playlist
|
return playlist
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -180,9 +180,7 @@ namespace Invidious
|
|||||||
|
|
||||||
function GetPlaylist(playlistId as string, index = 0 as integer, continuation = "" as string, cancellation = invalid as object) as object
|
function GetPlaylist(playlistId as string, index = 0 as integer, continuation = "" as string, cancellation = invalid as object) as object
|
||||||
authToken = m.invidiousNode.authToken
|
authToken = m.invidiousNode.authToken
|
||||||
' There's no need to use auth, unless the playlist is from Invidious
|
if authToken <> invalid
|
||||||
' (starts with "IV") because it can be a private playlist from logged user.
|
|
||||||
if playlistId.StartsWith("IV") and authToken <> invalid
|
|
||||||
url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}/${playlistId}`
|
url = `${authToken.instance}${Invidious.AUTH_PLAYLISTS}/${playlistId}`
|
||||||
request = HttpClient.Get(url)
|
request = HttpClient.Get(url)
|
||||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||||
|
|||||||
@@ -307,6 +307,10 @@ namespace InvidiousContent
|
|||||||
node.videoCountText = videoCountText
|
node.videoCountText = videoCountText
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
' If we already have this information, we should not override it.
|
||||||
|
if not StringUtils.IsNullOrEmpty(node.videoCountText)
|
||||||
|
return
|
||||||
|
end if
|
||||||
videoCount = ValidInt(item.videoCount)
|
videoCount = ValidInt(item.videoCount)
|
||||||
if videoCount = -1
|
if videoCount = -1
|
||||||
return
|
return
|
||||||
|
|||||||
+33
@@ -505,6 +505,8 @@ namespace Http
|
|||||||
return m.GetVideo(context)
|
return m.GetVideo(context)
|
||||||
else if route.StartsWith("/playlet-invidious-backend/api/v1/playlists/")
|
else if route.StartsWith("/playlet-invidious-backend/api/v1/playlists/")
|
||||||
return m.GetPlaylist(context)
|
return m.GetPlaylist(context)
|
||||||
|
else if route.StartsWith("/playlet-invidious-backend/api/v1/auth/playlists/")
|
||||||
|
return m.GetAuthPlaylist(context)
|
||||||
else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/")
|
else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/")
|
||||||
return m.GetChannel(context)
|
return m.GetChannel(context)
|
||||||
else if route.StartsWith("/playlet-invidious-backend/channel")
|
else if route.StartsWith("/playlet-invidious-backend/channel")
|
||||||
@@ -557,10 +559,13 @@ namespace Http
|
|||||||
response = context.response
|
response = context.response
|
||||||
route = request.route
|
route = request.route
|
||||||
|
|
||||||
|
playlistId = context.playlistId
|
||||||
|
if StringUtils.IsNullOrEmpty(playlistId)
|
||||||
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
|
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
|
||||||
if playlistId.InStr("?") > 0
|
if playlistId.InStr("?") > 0
|
||||||
playlistId = playlistId.Left(playlistId.InStr("?"))
|
playlistId = playlistId.Left(playlistId.InStr("?"))
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
continuation = request.query.continuation
|
continuation = request.query.continuation
|
||||||
raw = request.query.raw <> invalid
|
raw = request.query.raw <> invalid
|
||||||
|
|
||||||
@@ -568,6 +573,11 @@ namespace Http
|
|||||||
raw: raw
|
raw: raw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accessToken = request.headers["authorization"]
|
||||||
|
if not StringUtils.IsNullOrEmpty(accessToken) and accessToken.StartsWith("Bearer ")
|
||||||
|
options["accessToken"] = accessToken.Mid("Bearer ".Len())
|
||||||
|
end if
|
||||||
|
|
||||||
if playlistId.StartsWith("RD")
|
if playlistId.StartsWith("RD")
|
||||||
if not StringUtils.IsNullOrEmpty(continuation)
|
if not StringUtils.IsNullOrEmpty(continuation)
|
||||||
options.videoId = continuation
|
options.videoId = continuation
|
||||||
@@ -611,6 +621,29 @@ namespace Http
|
|||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function GetAuthPlaylist(context as object) as boolean
|
||||||
|
request = context.request
|
||||||
|
response = context.response
|
||||||
|
route = request.route
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
playlistId = route.Mid("/playlet-invidious-backend/api/v1/auth/playlists/".Len())
|
||||||
|
if playlistId.InStr("?") > 0
|
||||||
|
playlistId = playlistId.Left(playlistId.InStr("?"))
|
||||||
|
end if
|
||||||
|
|
||||||
|
context.playlistId = playlistId
|
||||||
|
return m.GetPlaylist(context)
|
||||||
|
end function
|
||||||
|
|
||||||
function GetChannel(context as object) as boolean
|
function GetChannel(context as object) as boolean
|
||||||
request = context.request
|
request = context.request
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|||||||
Reference in new issue
Block a user