Compare commits

..
7 Commits
Author SHA1 Message Date
Brahim Hadriche 6401a93420 Release v0.41.13 (#732) 2025-09-18 17:21:24 -04:00
Brahim Hadriche 3039c00fdb [skip ci] adjust thread count 2025-09-18 16:56:19 -04:00
Brahim Hadriche 8010765c8e Various fixes 2025-09-18 16:35:36 -04:00
Brahim Hadriche 62f96dea5e Release v0.41.12 (#731) 2025-09-17 18:25:09 -04:00
Brahim Hadriche 15a0177083 Fallback to 360p when dash streams are missing 2025-09-17 18:23:18 -04:00
Brahim Hadriche 9f83391e37 [skip ci] tweak 2025-09-17 16:37:54 -04:00
Brahim Hadriche f742826b8d [skip ci] tweak 2025-09-17 16:27:50 -04:00
24 changed files with 338 additions and 217 deletions

No files matched your search

+15
View File
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.41.13] - 2025-09-18
### Fixed
- Issue with `credentialTransferToken`s which caused "Login to confirm you're not a bot" even when logged in
- Adjust live video detection to reduce error rate happening on iOS client (another attempt)
- Attempt to play the next video when errors occur
- Remove manual video cache for Invidious to avoid stale streams
## [0.41.12] - 2025-09-17
### Fixed
- Fallback to 360p when dash streams are missing
## [0.41.11] - 2025-09-17
### Fixed
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet",
"version": "0.41.11",
"version": "0.41.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.41.11",
"version": "0.41.13",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.35",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet",
"version": "0.41.11",
"version": "0.41.13",
"description": "Unofficial YouTube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.35",
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.41.11",
"version": "0.41.13",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.41.11"
"version": "0.41.13"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.41.11",
"version": "0.41.13",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-app",
+1 -1
View File
@@ -3,7 +3,7 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=41
build_version=00011
build_version=00013
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.41.11",
"version": "0.41.13",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.41.11"
"version": "0.41.13"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.41.11",
"version": "0.41.13",
"description": "Unofficial YouTube client for Roku",
"scripts": {
"prebuild": "rm -rf ../build/playlet-lib",
@@ -3,7 +3,10 @@ import "pkg:/source/utils/MessagePortUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
' Maximum number of JobTasks that can be created
const MAX_JOB_TASK_COUNT = 25
' https://developer.roku.com/en-ca/docs/developer-program/core-concepts/threads.md
' "Developers should take steps to ensure that their apps always remain well under the 50-thread "warning" limit."
' Accounting for other types of long running Tasks in the app, this limit should be way lower than 50.
const MAX_JOB_TASK_COUNT = 30
' Minimum number of JobTasks that will be kept alive
const MIN_JOB_TASK_COUNT = 2
' Time in milliseconds to wait before scaling down JobTasks
@@ -185,8 +185,8 @@ class DashManifest
if xml.Node("Representation", representationAttributes)
m.AddColorInfo(stream, xml)
if stream.url = invalid
xml.Comment(`[ERROR] Stream.url is invalid for itag: ${stream.itag}`)
if StringUtils.IsNullOrEmpty(stream.url)
xml.Comment(`[ERROR] Stream.url is null or empty for itag: ${stream.itag}`)
else if stream.url.InStr("source=yt_live_broadcast") <> -1
xml.Comment(`[WARN] Stream URL indicates a live broadcast for itag: ${stream.itag}`)
end if
@@ -56,6 +56,7 @@ namespace Innertube
visitorData = OptionUtils.Get(options, "visitorData")
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
accessToken = OptionUtils.Get(options, "accessToken")
videoId = OptionUtils.Get(options, "videoId")
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
@@ -71,11 +72,16 @@ namespace Innertube
}
}
if not StringUtils.IsNullOrEmpty(credentialTransferToken)
context["user"]["credentialTransferTokens"] = [{
"token": credentialTransferToken
"scope": "VIDEO"
}]
if IsAssociativeArray(credentialTransferToken) and not StringUtils.IsNullOrEmpty(videoId)
cttCideoId = credentialTransferToken.videoId
cttToken = credentialTransferToken.token
if not StringUtils.IsNullOrEmpty(cttToken) and videoId = cttCideoId
context["user"]["credentialTransferTokens"] = [{
"token": cttToken
"scope": "VIDEO"
}]
end if
end if
if not StringUtils.IsNullOrEmpty(visitorData) and not useAccessToken
@@ -17,23 +17,14 @@ import "pkg:/source/utils/TimeUtils.bs"
namespace InnertubeService
function GetVideoMetadata(videoId as string, options = invalid as object) as object
options["videoId"] = videoId
cancellation = OptionUtils.Get(options, "cancellation")
fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
accessToken = OptionUtils.Get(options, "accessToken")
raw = OptionUtils.GetOrDefault(options, "raw", false)
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.Tv, options)
if not StringUtils.IsNullOrEmpty(accessToken)
playerRequest.Header("Authorization", "Bearer " + accessToken)
end if
playerRequest.Cancellation(cancellation)
if raw
playerRequest.LogCurlCommand(true)
end if
playerRequest.Send()
nextRequest = invalid
nextResponse = invalid
if fetchNext
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, options)
nextRequest.Cancellation(cancellation)
@@ -43,119 +34,142 @@ namespace InnertubeService
nextRequest.Send()
end if
playerResponse = playerRequest.Await()
if not playerResponse.IsSuccess()
return {
error: playerResponse.ErrorMessage()
}
end if
if CancellationUtils.IsCancelled(cancellation)
return {
error: "Cancelled"
}
end if
' For LIVE videos, we will need to fallback to iOS for HLS streams for now.
' Also, since we might have tracking urls in the player response (if logged in),
' we can keep them to avoid an extra request later.
' TODO:P0 figure out how to get DASH to work for live videos.
'
' # Start of iOS fallback
playbackTrackingUrls = invalid
responseJson = playerResponse.Json()
if ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "isLive"])) or ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "hasLiveStreamingData"]))
LogDebug("Live video detected, falling back to iOS for HLS streams.")
isLoggedIn = Innertube.ParseIsLoggedIn(responseJson)
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(responseJson, isLoggedIn)
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.IOS, options)
playerResponseJson = invalid
client = Innertube.ClientType.Tv
totalPlayerRequests = 0
while true
' We shouldn't be making more that 3 requests:
' 1. Make request with TV client, but turns out to be live -> fallback to iOS
' 2. Make request, but STS_MISMATCH error -> retry with new STS
' 3. Make request, it either succeeds or fails.
if totalPlayerRequests > 3
LogError("Too many player requests, aborting.")
return {
error: "Too many player requests"
}
end if
totalPlayerRequests += 1
playerRequest = Innertube.CreatePlayerRequest(client, options)
if not StringUtils.IsNullOrEmpty(accessToken) and client = Innertube.ClientType.Tv
playerRequest.Header("Authorization", "Bearer " + accessToken)
end if
playerRequest.Cancellation(cancellation)
if raw
playerRequest.LogCurlCommand(true)
end if
playerResponse = playerRequest.Await()
if not playerResponse.IsSuccess()
return {
error: playerResponse.ErrorMessage()
}
end if
if CancellationUtils.IsCancelled(cancellation)
return {
error: "Cancelled"
}
end if
end if
' # End of iOS fallback
if fetchNext
nextResponse = nextRequest.Await()
end if
if not playerResponse.IsSuccess()
parsedResponse = {
error: playerResponse.ErrorMessage()
}
parsedResponse = AwaitAndParseNextResponse(fetchNext, raw, parsedResponse, nextRequest)
return parsedResponse
end if
playerResponseJson = playerResponse.Json()
isLive = Innertube.IsLiveStream(playerResponseJson)
if isLive and client = Innertube.ClientType.Tv
LogDebug("Live video detected, falling back to iOS for HLS streams.")
isLoggedIn = Innertube.ParseIsLoggedIn(playerResponseJson)
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(playerResponseJson, isLoggedIn)
client = Innertube.ClientType.IOS
continue while
end if
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponseJson, {}, playerRequest.signatureTimestamp, cancellation)
if parsedResponse.error = invalid
exit while
end if
if parsedResponse.errorCode <> invalid
if parsedResponse.errorCode = "STS_MISMATCH"
LogInfo("STS_MISMATCH error, retrying...")
continue while
else if parsedResponse.errorCode = "MISSING_FORMAT_FIELD"
LogTelemetryEvent({
level: "error"
message: parsedResponse.errorCode
fingerprint: parsedResponse.errorCode
attachments: [{
filename: "request.txt"
content_type: "text/plain"
data: playerRequest.ToCurlCommand()
}, {
filename: "response.json"
content_type: "application/json"
data: playerResponse.Text()
}]
})
end if
end if
parsedResponse = AwaitAndParseNextResponse(fetchNext, raw, parsedResponse, nextRequest)
return parsedResponse
end while
if raw
rawResponse = {
"playerResponse": playerResponse.Json()
"playerResponse": playerResponseJson
}
if fetchNext
rawResponse["nextResponse"] = nextResponse.Json()
end if
rawResponse = AwaitAndParseNextResponse(fetchNext, raw, rawResponse, nextRequest)
return rawResponse
end if
parsedResponse = invalid
try
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json(), playerRequest.signatureTimestamp, cancellation)
catch exception
code = ValidString(exception.code)
if code = "STS_MISMATCH"
return GetVideoMetadata(videoId, options)
end if
if code = "MISSING_FORMAT_FIELD"
LogTelemetryEvent({
level: "error"
message: code
fingerprint: code
attachments: [{
filename: "request.txt"
content_type: "text/plain"
data: playerRequest.ToCurlCommand()
}, {
filename: "response.json"
content_type: "application/json"
data: playerResponse.Text()
}]
})
end if
throw exception
end try
if parsedResponse.error <> invalid
return parsedResponse
end if
parsedResponse = AwaitAndParseNextResponse(fetchNext, raw, parsedResponse, nextRequest)
if fetchNext
if nextResponse.IsSuccess()
parsedResponse = Innertube.ParseInnertubeNextResponse(nextResponse.Json(), parsedResponse, nextResponse)
else
LogWarn(nextResponse.ErrorMessage())
end if
end if
' If for some reason we missed the videoId, add it back
if parsedResponse.error = invalid and StringUtils.IsNullOrEmpty(parsedResponse.videoId)
if StringUtils.IsNullOrEmpty(parsedResponse.videoId)
parsedResponse["videoId"] = videoId
end if
' # Start of iOS fallback
' If we did capture tracking urls when we did the TV request, but now we're
' missing them because we switched to iOS, add them back.
if playbackTrackingUrls <> invalid and parsedResponse.playbackTrackingUrls = invalid
LogDebug("Adding playback tracking URLs from TV player response.")
parsedResponse["playbackTrackingUrls"] = playbackTrackingUrls
end if
' # End of iOS fallback
return parsedResponse
end function
function AwaitAndParseNextResponse(fetchNext as boolean, raw as boolean, parsedResponse as object, nextRequest as object) as object
if not fetchNext
return parsedResponse
end if
nextResponse = nextRequest.Await()
if not nextResponse.IsSuccess()
error = nextResponse.ErrorMessage()
LogWarn(error)
if raw
parsedResponse["nextError"] = error
end if
return parsedResponse
end if
if raw
parsedResponse["nextResponse"] = nextResponse.Json()
end if
return Innertube.ParseInnertubeNextResponse(nextResponse.Json(), parsedResponse, nextResponse)
end function
function GetVideoInfoBatched(videoIds as object, options = invalid as object) as object
if not IsArray(videoIds) or videoIds.Count() = 0
return {
@@ -362,7 +376,8 @@ namespace InnertubeService
cancellation = options.cancellation
end if
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.Tv, options)
options["videoId"] = videoId
playerRequest = Innertube.CreatePlayerRequest(Innertube.ClientType.Tv, options)
playerRequest.Cancellation(cancellation)
playerRequest.Header("Authorization", "Bearer " + accessToken)
@@ -34,12 +34,7 @@ namespace Innertube
})
end function
function ParseInnertubeNextResponse(payload as object, parsedResponse as object, response as object) as object
if parsedResponse.error <> invalid
LogWarn("Invalid parsed response", parsedResponse)
return parsedResponse
end if
function ParseInnertubeNextResponse(payload as object, parsedResponse as object, httpResponse as object) as object
if not IsAssociativeArray(payload)
LogWarn("Invalid payload", payload)
return parsedResponse
@@ -73,7 +68,7 @@ namespace Innertube
endscreen = playerOverlayRenderer["endScreen"]
feeds = Innertube.ParseResponseDataForFeeds(endscreen, {
response: response
response: httpResponse
noContainers: true
})
if feeds.Count() > 0
@@ -7,7 +7,8 @@ import "pkg:/source/utils/UrlUtils.bs"
namespace Innertube
function CreatePlayerRequest(videoId as string, client as Innertube.ClientType, options = invalid as object) as object
function CreatePlayerRequest(client as Innertube.ClientType, options = invalid as object) as object
videoId = OptionUtils.Get(options, "videoId")
cancellation = OptionUtils.Get(options, "cancellation")
visitorData = OptionUtils.Get(options, "visitorData")
accessToken = OptionUtils.Get(options, "accessToken")
@@ -62,60 +63,82 @@ namespace Innertube
return request
end function
function ParseInnertubePlayerResponse(payload as object, signatureTimestamp as dynamic, cancellation as object) as object
function ParseInnertubePlayerResponse(payload as object, parsedResponse as object, signatureTimestamp as dynamic, cancellation as object) as object
error = ParsePlayerResponseForError(payload)
if error <> ""
return {
error: error
}
parsedResponse["error"] = error
return parsedResponse
end if
videoDetails = payload["videoDetails"]
if not IsAssociativeArray(videoDetails)
return {
error: "Invalid video details"
}
parsedResponse["error"] = "Invalid videoDetails"
return parsedResponse
end if
streamingData = payload["streamingData"]
if not IsAssociativeArray(streamingData)
return {
error: "Invalid streaming data"
}
parsedResponse["error"] = "Invalid streamingData"
return parsedResponse
end if
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
isLive = ValidBool(videoDetails["isLive"])
adaptiveFormats = ParseAdaptiveFormats(payload, signatureTimestamp, isLive, cancellation)
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats)
videoInfo = {
"type": "video"
"title": videoDetails["title"]
"videoId": videoDetails["videoId"]
"videoThumbnails": videoDetails["thumbnail"]["thumbnails"]
"storyboards": ParseStoryboards(payload, lengthSeconds)
"author": videoDetails["author"]
"authorId": videoDetails["channelId"]
"lengthSeconds": lengthSeconds
"liveNow": isLive
"hasLiveStreamingData": hasLiveStreamingData
"hlsUrl": streamingData["hlsManifestUrl"]
"dashUrl": streamingData["dashManifestUrl"]
"adaptiveFormats": adaptiveFormats
"formatStreams": []
"captions": ParseCaptions(payload)
"recommendedVideos": []
}
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
if videoDetails.DoesExist("viewCount")
videoInfo["viewCount"] = videoDetails["viewCount"].ToInt()
if not isLive
error = DecipherUrls(formats, adaptiveFormats, signatureTimestamp, cancellation)
if error <> invalid
parsedResponse["error"] = error.error
if error.DoesExist("errorCode")
parsedResponse["errorCode"] = error.errorCode
end if
return parsedResponse
end if
end if
videoInfo["isLoggedIn"] = ParseIsLoggedIn(payload)
videoInfo["playbackTrackingUrls"] = ParsePlaybackTrackingUrls(payload, videoInfo.isLoggedIn)
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats) or FormatsHaveLiveStreamingData(formats)
return videoInfo
adaptiveFormats = TransformFormats(adaptiveFormats)
formats = TransformFormats(formats)
parsedResponse["type"] = "video"
parsedResponse["videoId"] = videoDetails["videoId"]
parsedResponse["videoThumbnails"] = videoDetails["thumbnail"]["thumbnails"]
parsedResponse["storyboards"] = ParseStoryboards(payload, lengthSeconds)
parsedResponse["author"] = videoDetails["author"]
parsedResponse["authorId"] = videoDetails["channelId"]
parsedResponse["lengthSeconds"] = lengthSeconds
parsedResponse["liveNow"] = isLive
parsedResponse["hasLiveStreamingData"] = hasLiveStreamingData
parsedResponse["hlsUrl"] = streamingData["hlsManifestUrl"]
parsedResponse["dashUrl"] = streamingData["dashManifestUrl"]
parsedResponse["adaptiveFormats"] = adaptiveFormats
parsedResponse["formatStreams"] = formats
parsedResponse["captions"] = ParseCaptions(payload)
if not IsArray(parsedResponse["recommendedVideos"])
parsedResponse["recommendedVideos"] = []
end if
if not StringUtils.IsNullOrEmpty(videoDetails["title"])
parsedResponse["title"] = videoDetails["title"]
end if
if not StringUtils.IsNullOrEmpty(videoDetails["author"])
parsedResponse["author"] = videoDetails["author"]
end if
if videoDetails.DoesExist("viewCount")
parsedResponse["viewCount"] = videoDetails["viewCount"].ToInt()
end if
parsedResponse["isLoggedIn"] = ParseIsLoggedIn(payload)
parsedResponse["playbackTrackingUrls"] = ParsePlaybackTrackingUrls(payload, parsedResponse.isLoggedIn)
return parsedResponse
end function
function ParsePlayerResponseForError(payload as object) as string
@@ -154,11 +177,6 @@ namespace Innertube
if status = "LOGIN_REQUIRED"
' TODO:P2 localize
errorLines.Push("Hint: Log in to the YouTube app on your phone, then cast the video to Playlet.")
isLoggedIn = Innertube.ParseIsLoggedIn(payload)
if isLoggedIn
LogError("Video requires login, but user is already logged in!")
end if
end if
return errorLines.Join(`\n`)
@@ -296,25 +314,14 @@ namespace Innertube
return captions
end function
function ParseAdaptiveFormats(payload as object, signatureTimestamp as dynamic, isLive as boolean, cancellation as object) as object
adaptiveFormats = ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"])
if not IsArray(adaptiveFormats)
return []
end if
if not isLive
adaptiveFormats = DecipherUrls(adaptiveFormats, signatureTimestamp, cancellation)
end if
formats = []
for each fmt in adaptiveFormats
formats.Push(GetAdaptiveFormat(fmt))
function TransformFormats(formats as object) as object
for i = 0 to formats.Count() - 1
formats[i] = TransformFormat(formats[i])
end for
return formats
end function
function GetAdaptiveFormat(fmt as object) as object
function TransformFormat(fmt as object) as object
itag = `${fmt["itag"]}`
result = {
"bitrate": `${fmt["bitrate"]}`
@@ -396,24 +403,34 @@ namespace Innertube
return json["sts"]
end function
function DecipherUrls(adaptiveFormats as object, signatureTimestamp as dynamic, cancellation as object) as object
function DecipherUrls(formats as object, adaptiveFormats as object, signatureTimestamp as dynamic, cancellation as object) as object
if signatureTimestamp = invalid
' No need to decipher if signatureTimestamp is not available
return adaptiveFormats
return invalid
end if
formats = []
for each fmt in adaptiveFormats
formats.push({
reqFormats = []
for each fmt in formats
reqFormats.push({
"url": fmt["url"]
"cipher": fmt["cipher"]
"signatureCipher": fmt["signatureCipher"]
})
end for
request = HttpClient.PostJson(`${PLAYLET_SUPPORT_SERVER}/v1/decipher`, {
reqAdaptiveFormats = []
for each fmt in adaptiveFormats
reqAdaptiveFormats.push({
"url": fmt["url"]
"cipher": fmt["cipher"]
"signatureCipher": fmt["signatureCipher"]
})
end for
request = HttpClient.PostJson(`${PLAYLET_SUPPORT_SERVER}/v2/decipher`, {
"sts": signatureTimestamp
"formats": formats
"formats": reqFormats
"adaptiveFormats": reqAdaptiveFormats
})
request.Cancellation(cancellation)
@@ -426,46 +443,64 @@ namespace Innertube
else
LogError(response.ErrorMessage())
end if
code = ""
errorCode = ""
if response.StatusCode() = 400
json = response.Json()
if IsAssociativeArray(json)
code = ValidString(json["code"])
if code = "STS_MISMATCH"
errorCode = ValidString(json["code"])
if errorCode = "STS_MISMATCH"
DeleteFile("tmp:/sts_cache.json")
end if
end if
end if
exception = { message: response.ErrorMessage() }
if code <> ""
exception.code = code
exception = {
error: response.ErrorMessage()
}
if errorCode <> ""
exception.errorCode = errorCode
end if
throw exception
return exception
end if
json = response.Json()
if not IsAssociativeArray(json) or not json.DoesExist("formats")
if not IsAssociativeArray(json) or not json.DoesExist("formats") or not json.DoesExist("adaptiveFormats")
error = "Invalid response from decipher service"
LogError(error)
throw error
return {
error: error
}
end if
decipheredFormats = json["formats"]
if not IsArray(decipheredFormats) or decipheredFormats.Count() <> adaptiveFormats.Count()
if not IsArray(decipheredFormats) or decipheredFormats.Count() <> formats.Count()
error = "Invalid formats in deciphered response"
LogError(error)
throw error
return {
error: error
}
end if
for i = 0 to decipheredFormats.Count() - 1
fmt = adaptiveFormats[i]
fmt = formats[i]
decipheredFmt = decipheredFormats[i]
fmt["url"] = decipheredFmt["url"]
end for
return adaptiveFormats
decipheredAdaptiveFormats = json["adaptiveFormats"]
if not IsArray(decipheredAdaptiveFormats) or decipheredAdaptiveFormats.Count() <> adaptiveFormats.Count()
error = "Invalid adaptiveFormats in deciphered response"
LogError(error)
return {
error: error
}
end if
for i = 0 to decipheredAdaptiveFormats.Count() - 1
fmt = adaptiveFormats[i]
decipheredFmt = decipheredAdaptiveFormats[i]
fmt["url"] = decipheredFmt["url"]
end for
return invalid
end function
function ParseIsLoggedIn(payload as object) as boolean
@@ -512,12 +547,28 @@ namespace Innertube
}
end function
function FormatsHaveLiveStreamingData(adaptiveFormats as object) as boolean
if not IsArray(adaptiveFormats)
return false
function IsLiveStream(payload as object) as boolean
if ValidBool(ObjectUtils.Dig(payload, ["videoDetails", "isLive"]))
return true
end if
for each fmt in adaptiveFormats
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
if FormatsHaveLiveStreamingData(adaptiveFormats)
return true
end if
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
if FormatsHaveLiveStreamingData(formats)
return true
end if
return false
end function
function FormatsHaveLiveStreamingData(formats as object) as boolean
if not IsArray(formats)
return false
end if
for each fmt in formats
url = fmt["url"]
if IsString(url) and url.InStr("yt_live_broadcast") <> -1
return true
@@ -128,9 +128,6 @@ namespace Invidious
end function
function GetVideoMetadata(videoId as string, options = invalid as object) as object
' 10 minutes cache.
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
cacheSeconds = OptionUtils.GetOrDefault(options, "cacheSeconds", 600) ' 10 minutes
cancellation = OptionUtils.Get(options, "cancellation")
tryCount = OptionUtils.GetOrDefault(options, "tryCount", 2)
@@ -139,7 +136,6 @@ namespace Invidious
request = HttpClient.Get(url)
request.CacheSeconds(cacheSeconds)
request.Cancellation(cancellation)
if tryCount > 1
@@ -59,6 +59,7 @@ class LoungeApi
commandHandlers[COMMAND_TYPE_GET_VOLUME] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_GET_SUBTITLES_TRACK] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_SET_SUBTITLES] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_SET_AUDIO_TRACK] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_DPAD_COMMAND] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand
commandHandlers[COMMAND_TYPE_ON_USER_ACTIVITY] = m.HandleIgnoreCommand
@@ -436,8 +437,11 @@ class LoungeApi
' 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[FIELD_CTT])
m.loungeServiceNode.credentialTransferToken = commandArgs[FIELD_CTT]
if not StringUtils.IsNullOrEmpty(commandArgs[FIELD_CTT]) and not StringUtils.IsNullOrEmpty(commandArgs[FIELD_VIDEO_ID])
m.loungeServiceNode.credentialTransferToken = {
"token": commandArgs[FIELD_CTT]
"videoId": commandArgs[FIELD_VIDEO_ID]
}
end if
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
end function
@@ -560,7 +564,7 @@ class LoungeApi
})
if not response.IsSuccess()
if response.StatusCode() = 400 and response.ErrorMessage().InStr("Unknown SID") <> -1
if response.StatusCode() = 410 or (response.StatusCode() = 400 and response.ErrorMessage().InStr("Unknown SID") <> -1)
LogErrorNoTelemetry(response.ErrorMessage())
else
LogError(response.ErrorMessage())
@@ -24,6 +24,7 @@ const COMMAND_TYPE_STOP_VIDEO = "stopVideo"
const COMMAND_TYPE_DPAD_COMMAND = "dpadCommand"
const COMMAND_TYPE_VOICE_COMMAND = "voiceCommand"
const COMMAND_TYPE_SET_SUBTITLES = "setSubtitlesTrack"
const COMMAND_TYPE_SET_AUDIO_TRACK = "setAudioTrack"
const COMMAND_TYPE_ON_USER_ACTIVITY = "onUserActivity"
const COMMAND_TYPE_GET_DISCOVERT_DEVICE_ID = "getDiscoveryDeviceId"
const COMMAND_TYPE_GRACEFUL_RECONNECT = "gracefulReconnect"
@@ -5,7 +5,7 @@
<field id="deviceName" type="string" />
<field id="screenId" type="string" />
<field id="loungeToken" type="string" />
<field id="credentialTransferToken" type="string" />
<field id="credentialTransferToken" type="assocarray" />
<field id="join" type="boolean" alwaysNotify="true" />
<field id="outgoingMessages" type="array" alwaysNotify="true" />
@@ -33,10 +33,11 @@ namespace Sentry
hasAttachments = IsArray(event.attachments) and event.attachments.Count() > 0
if (not SUPPORTS_ATTACHMENTS) and hasAttachments
message += `\nAttachments:`
message += `\nAttachments: (${event.attachments.Count()} files)`
for each attachment in event.attachments
message += `\nAttachment: ${attachment.filename} (${attachment.content_type})\n${attachment.data}`
end for
message += `\nEnd of attachments.`
end if
eventPayload = {
@@ -68,13 +68,13 @@ function ExecuteJob() as void
end if
end if
if metadata = invalid
JobError("Failed to get video metadata")
if JobIsCancelled()
JobCancel()
return
end if
if JobIsCancelled()
JobCancel()
if metadata = invalid
JobError("Failed to get video metadata")
return
end if
@@ -97,6 +97,12 @@ function ExecuteJob() as void
end if
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, backend, playletServerPort)
if streamUrls.Count() = 0
contentNode.addFields({ metadata: metadata })
JobError("No playable streams found for this video.")
return
end if
' Forwarding query params to HLS playlists is not needed. In fact, it can cause issues
' because the playlist is limited to 4MB, and on large playlists the query params
' significantly increase the size of the playlist, making it cropped.
@@ -126,18 +132,46 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
streamUrls = []
if not StringUtils.IsNullOrEmpty(metadata.hlsUrl)
if SupportsHls(metadata)
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
else
' Not that we're using dashUrl, but why not, it useful when testing it
metadata.dashUrl = AddInstanceToUrlIfNeeded(metadata.dashUrl, instance)
else if SupportsDash(metadata)
AddDashUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
else if SupportsMuxedFormats(metadata)
for each stream in metadata.formatStreams
if StringUtils.IsNullOrEmpty(stream.url)
continue for
end if
stream.url = AddInstanceToUrlIfNeeded(stream.url, instance)
streamUrls.push(stream.url)
end for
end if
return streamUrls
end function
function SupportsHls(metadata as object) as boolean
return not StringUtils.IsNullOrEmpty(metadata.hlsUrl)
end function
function SupportsDash(metadata as object) as boolean
if not IsArray(metadata.adaptiveFormats) or metadata.adaptiveFormats.Count() = 0
return false
end if
for each fmt in metadata.adaptiveFormats
if not StringUtils.IsNullOrEmpty(fmt.url)
return true
end if
end for
return false
end function
function SupportsMuxedFormats(metadata as object) as boolean
return IsArray(metadata.formatStreams) and metadata.formatStreams.Count() > 0
end function
function AddHlsUrls(streamUrls as object, metadata as object, preferredQuality as string, backend as string, proxyVideos as string, playletServerPort as integer)
hlsUrl = metadata.hlsUrl
hlsUrlLocal = invalid
@@ -66,7 +66,7 @@ end function
function LoadVideoDetail(videoNode as object, service as object, instance as string, requestOptions as object, backend as string) as boolean
videoId = videoNode.videoId
if backend = "playlet"
if backend = "playlet" or instance = Invidious.PLAYLET_BUILT_IN_INSTANCE
requestOptions["retry"] = false
metadata = InnertubeService.GetVideoInfoBatched([videoId], requestOptions)
if IsArray(metadata.videos) and metadata.videos.Count() > 0
+1 -1
View File
@@ -3,7 +3,7 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=41
build_version=00011
build_version=00013
ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-web",
"version": "0.41.11",
"version": "0.41.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet-web",
"version": "0.41.11",
"version": "0.41.13",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^6.2.0",
"@tailwindcss/postcss": "^4.1.13",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-web",
"version": "0.41.11",
"version": "0.41.13",
"type": "module",
"scripts": {
"dev": "vite",