Use credentialTransferToken to play age restricted videos (#498)
* Use credentialTransferToken to play age restricted videos * changelog
This commit is contained in:
1 parent
ee239c3ea9
commit
1e161e8a77
6 files changed
+41
-5
No files matched your search
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Search suggestions to Playlet backend
|
- Search suggestions to Playlet backend
|
||||||
|
- Support for age restrcited videos and private videos when cast from YouTube app (logged in)
|
||||||
|
|
||||||
## [0.32.1] - 2024-12-03
|
## [0.32.1] - 2024-12-03
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace InnertubeService
|
|||||||
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
||||||
cancellation = invalid
|
cancellation = invalid
|
||||||
fetchNext = true
|
fetchNext = true
|
||||||
|
ctt = ""
|
||||||
|
|
||||||
if options <> invalid
|
if options <> invalid
|
||||||
if options.DoesExist("cancellation")
|
if options.DoesExist("cancellation")
|
||||||
@@ -26,16 +27,19 @@ namespace InnertubeService
|
|||||||
if options.DoesExist("fetchNext")
|
if options.DoesExist("fetchNext")
|
||||||
fetchNext = options.fetchNext
|
fetchNext = options.fetchNext
|
||||||
end if
|
end if
|
||||||
|
if options.DoesExist("ctt")
|
||||||
|
ctt = options.ctt
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
playerRequest = CreatePlayerRequest(videoId)
|
playerRequest = CreatePlayerRequest(videoId, ctt)
|
||||||
playerRequest.Cancellation(cancellation)
|
playerRequest.Cancellation(cancellation)
|
||||||
playerRequest.Send()
|
playerRequest.Send()
|
||||||
|
|
||||||
nextRequest = invalid
|
nextRequest = invalid
|
||||||
nextResponse = invalid
|
nextResponse = invalid
|
||||||
if fetchNext
|
if fetchNext
|
||||||
nextRequest = CreateNextRequest(videoId)
|
nextRequest = CreateNextRequest(videoId, ctt)
|
||||||
nextRequest.Cancellation(cancellation)
|
nextRequest.Cancellation(cancellation)
|
||||||
nextRequest.Send()
|
nextRequest.Send()
|
||||||
end if
|
end if
|
||||||
@@ -67,7 +71,7 @@ namespace InnertubeService
|
|||||||
return playerResponse
|
return playerResponse
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CreatePlayerRequest(videoId as string) as object
|
function CreatePlayerRequest(videoId as string, ctt as string) as object
|
||||||
deviceInfo = CreateObject("roDeviceInfo")
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
@@ -124,6 +128,13 @@ namespace InnertubeService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(ctt)
|
||||||
|
payload["context"]["user"]["credentialTransferTokens"] = [{
|
||||||
|
"token": ctt
|
||||||
|
"scope": "VIDEO"
|
||||||
|
}]
|
||||||
|
end if
|
||||||
|
|
||||||
request = HttpClient.Post("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", FormatJson(payload))
|
request = HttpClient.Post("https://www.youtube.com/youtubei/v1/player?prettyPrint=false&alt=json", FormatJson(payload))
|
||||||
request.Headers({
|
request.Headers({
|
||||||
"accept": "*/*"
|
"accept": "*/*"
|
||||||
@@ -137,7 +148,7 @@ namespace InnertubeService
|
|||||||
return request
|
return request
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CreateNextRequest(videoId as string) as object
|
function CreateNextRequest(videoId as string, ctt as string) as object
|
||||||
deviceInfo = CreateObject("roDeviceInfo")
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
@@ -185,6 +196,13 @@ namespace InnertubeService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(ctt)
|
||||||
|
payload["context"]["user"]["credentialTransferTokens"] = [{
|
||||||
|
"token": ctt
|
||||||
|
"scope": "VIDEO"
|
||||||
|
}]
|
||||||
|
end if
|
||||||
|
|
||||||
request = HttpClient.Post("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", FormatJson(payload))
|
request = HttpClient.Post("https://www.youtube.com/youtubei/v1/next?prettyPrint=false&alt=json", FormatJson(payload))
|
||||||
request.Headers({
|
request.Headers({
|
||||||
"accept": "*/*"
|
"accept": "*/*"
|
||||||
|
|||||||
@@ -404,6 +404,17 @@ class LoungeApi
|
|||||||
|
|
||||||
function HandleSetPlaylist(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object)
|
function HandleSetPlaylist(_commandId as integer, commandType as string, commandArgs as object, _messagesToSend as object)
|
||||||
LogDebug(commandType, commandArgs)
|
LogDebug(commandType, commandArgs)
|
||||||
|
' TODO:P2 ctt: credentialTransferToken
|
||||||
|
' We receive credentialTransferTokens here that can be attached to innertube requests.
|
||||||
|
' The tokens belong to the user logged in on the mobile app.
|
||||||
|
' These allow us to watch age restricted videos and private videos.
|
||||||
|
' They are scoped by video.
|
||||||
|
' Right now we just store only the last ctt, which works ok if we're casting one video at a time.
|
||||||
|
' But if the age restrcited video is added to the queue, we don't capture a token and playing the video would fail.
|
||||||
|
' These tokens need to be managed better, based on the video they belong to.
|
||||||
|
if not StringUtils.IsNullOrEmpty(commandArgs.ctt)
|
||||||
|
m.loungeServiceNode.ctt = commandArgs.ctt
|
||||||
|
end if
|
||||||
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
|
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<field id="deviceName" type="string" />
|
<field id="deviceName" type="string" />
|
||||||
<field id="screenId" type="string" />
|
<field id="screenId" type="string" />
|
||||||
<field id="loungeToken" type="string" />
|
<field id="loungeToken" type="string" />
|
||||||
|
<field id="ctt" type="string" />
|
||||||
|
|
||||||
<field id="join" type="boolean" alwaysNotify="true" />
|
<field id="join" type="boolean" alwaysNotify="true" />
|
||||||
<field id="outgoingMessages" type="array" alwaysNotify="true" />
|
<field id="outgoingMessages" type="array" alwaysNotify="true" />
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ function VideoContentTask(input as object) as object
|
|||||||
contentNode = input.content
|
contentNode = input.content
|
||||||
invidiousNode = input.invidious
|
invidiousNode = input.invidious
|
||||||
preferencesNode = input.preferences
|
preferencesNode = input.preferences
|
||||||
|
loungeServiceNode = input.loungeService
|
||||||
playletServerPort = input.playletServerPort
|
playletServerPort = input.playletServerPort
|
||||||
|
|
||||||
if m.top.cancel
|
if m.top.cancel
|
||||||
@@ -20,7 +21,10 @@ function VideoContentTask(input as object) as object
|
|||||||
|
|
||||||
backend = preferencesNode["playback.backend"]
|
backend = preferencesNode["playback.backend"]
|
||||||
if backend = "playlet"
|
if backend = "playlet"
|
||||||
response = InnertubeService.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
response = InnertubeService.GetVideoMetadata(contentNode.videoId, {
|
||||||
|
cancellation: m.top.cancellation
|
||||||
|
ctt: loungeServiceNode.ctt
|
||||||
|
})
|
||||||
else
|
else
|
||||||
response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ function StartVideoContentTask(videoContentNode as object)
|
|||||||
content: videoContentNode
|
content: videoContentNode
|
||||||
invidious: m.top.invidious
|
invidious: m.top.invidious
|
||||||
preferences: m.top.preferences
|
preferences: m.top.preferences
|
||||||
|
loungeService: m.top.loungeService
|
||||||
playletServerPort: m.top.webServer.port
|
playletServerPort: m.top.webServer.port
|
||||||
}, OnVideoContentTaskResults)
|
}, OnVideoContentTaskResults)
|
||||||
end function
|
end function
|
||||||
|
|||||||
Reference in new issue
Block a user