Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f58809737 | ||
|
|
6748390ac4 | ||
|
|
d2fac255ed | ||
|
|
dbcfc46dad | ||
|
|
671719905b | ||
|
|
5417f5d61d | ||
|
|
ee0abc9891 | ||
|
|
bb7407f75f | ||
|
|
b101872906 | ||
|
|
8f42bfa675 | ||
|
|
b8d2008b98 | ||
|
|
36910ab5cf | ||
|
|
ae09f711df | ||
|
|
6401a93420 | ||
|
|
3039c00fdb | ||
|
|
8010765c8e | ||
|
|
62f96dea5e | ||
|
|
15a0177083 | ||
|
|
9f83391e37 | ||
|
|
f742826b8d | ||
|
|
763d7e1309 | ||
|
|
9ae59a1bd7 | ||
|
|
ae64f73c67 | ||
|
|
8329fef6c1 |
No files matched your search
+39
-1
@@ -5,9 +5,47 @@ 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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.41.15] - 2025-09-19
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Rare crash when loading video feed
|
||||||
|
- Improve session data error handling
|
||||||
|
|
||||||
|
## [0.41.14] - 2025-09-18
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Try fetching multiple pages in the search, in case results are filtered out (e.g. shorts)
|
||||||
|
- Regression for `Attempt to play the next video when errors occur`
|
||||||
|
- Better handling for lounge lost sessions
|
||||||
|
|
||||||
|
## [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
|
||||||
|
|
||||||
|
- Small fixes related to events
|
||||||
|
|
||||||
## [0.41.10] - 2025-09-16
|
## [0.41.10] - 2025-09-16
|
||||||
|
|
||||||
- Nothing worth mentioning yet.
|
### Fixed
|
||||||
|
|
||||||
|
- Disabled event batching
|
||||||
|
|
||||||
## [0.41.9] - 2025-09-16
|
## [0.41.9] - 2025-09-16
|
||||||
|
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.35",
|
"@rokucommunity/bslint": "^0.8.35",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.35",
|
"@rokucommunity/bslint": "^0.8.35",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.41.10"
|
"version": "0.41.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf ../build/playlet-app",
|
"prebuild": "rm -rf ../build/playlet-app",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title=Playlet
|
|||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=41
|
minor_version=41
|
||||||
build_version=00010
|
build_version=00015
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.41.10"
|
"version": "0.41.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"description": "Unofficial YouTube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf ../build/playlet-lib",
|
"prebuild": "rm -rf ../build/playlet-lib",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function ExecuteJob() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
isInnertubeProfile = authToken.profileNode.type = "youtube"
|
isInnertubeProfile = authToken.profileNode.type = "youtube"
|
||||||
if isInnertubeProfile
|
if isInnertubeProfile
|
||||||
subscriptionStatus = InnertubeService.GetSubscriptionStatusForChannel(ucid, {
|
subscriptionStatus = InnertubeService.GetSubscriptionStatusForChannel(ucid, {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function ExecuteJob() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
|
||||||
if subscribe
|
if subscribe
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function ExecuteJob() as void
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
response = service.GetChannel(contentNode.authorId, cancellation)
|
response = service.GetChannel(contentNode.authorId, cancellation)
|
||||||
|
|
||||||
if JobIsCancelled()
|
if JobIsCancelled()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function ExecuteJob() as void
|
|||||||
|
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
instance = service.GetInstance()
|
instance = service.GetInstance()
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
|
|
||||||
while true
|
while true
|
||||||
playlistId = contentNode.playlistId
|
playlistId = contentNode.playlistId
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function ExecuteJob() as void
|
|||||||
accessTokenObject = input.accessTokenObject
|
accessTokenObject = input.accessTokenObject
|
||||||
profilesService = input.profilesService
|
profilesService = input.profilesService
|
||||||
try
|
try
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
if InnertubeService.AuthRefreshAccessToken(accessTokenObject, cancellation)
|
if InnertubeService.AuthRefreshAccessToken(accessTokenObject, cancellation)
|
||||||
profileNode.expiresIn = accessTokenObject.expiresIn
|
profileNode.expiresIn = accessTokenObject.expiresIn
|
||||||
profileNode.expiresTimestamp = accessTokenObject.expiresTimestamp
|
profileNode.expiresTimestamp = accessTokenObject.expiresTimestamp
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function ExecuteJob() as void
|
|||||||
profilesNode = input.profilesService
|
profilesNode = input.profilesService
|
||||||
dialogNode = input.dialog
|
dialogNode = input.dialog
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
' TODO:P2 cache client identity
|
' TODO:P2 cache client identity
|
||||||
authCode = InnertubeService.AuthGetCode(cancellation)
|
authCode = InnertubeService.AuthGetCode(cancellation)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import "pkg:/source/utils/AssertUtils.bs"
|
import "pkg:/source/utils/AssertUtils.bs"
|
||||||
|
import "pkg:/source/utils/CancellationUtils.bs"
|
||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/MessagePortUtils.bs"
|
import "pkg:/source/utils/MessagePortUtils.bs"
|
||||||
@@ -22,6 +23,10 @@ function JobGetCallbackNode() as dynamic
|
|||||||
return m._callback
|
return m._callback
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function JobGetCancellation() as dynamic
|
||||||
|
return CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
||||||
|
end function
|
||||||
|
|
||||||
function JobSuccess() as void
|
function JobSuccess() as void
|
||||||
callbackNode = JobGetCallbackNode()
|
callbackNode = JobGetCallbackNode()
|
||||||
if callbackNode = invalid
|
if callbackNode = invalid
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import "pkg:/source/utils/MessagePortUtils.bs"
|
|||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
' Maximum number of JobTasks that can be created
|
' 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
|
' Minimum number of JobTasks that will be kept alive
|
||||||
const MIN_JOB_TASK_COUNT = 2
|
const MIN_JOB_TASK_COUNT = 2
|
||||||
' Time in milliseconds to wait before scaling down JobTasks
|
' Time in milliseconds to wait before scaling down JobTasks
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ function ExecuteJob() as void
|
|||||||
content = PrepareTests()
|
content = PrepareTests()
|
||||||
listNode.content = content
|
listNode.content = content
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
RunTests(instance, content, cancellation)
|
RunTests(instance, content, cancellation)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ function ExecuteJob() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
response = HttpClient.Get(Invidious.INSTANCES_API).Cancellation(cancellation).Await()
|
response = HttpClient.Get(Invidious.INSTANCES_API).Cancellation(cancellation).Await()
|
||||||
if response.IsCancelled()
|
if response.IsCancelled()
|
||||||
JobCancel()
|
JobCancel()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import "pkg:/source/utils/CancellationUtils.bs"
|
|||||||
|
|
||||||
@job("LatestLibVersionJob")
|
@job("LatestLibVersionJob")
|
||||||
function ExecuteJob() as void
|
function ExecuteJob() as void
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
latest = GetLatestPlayletLibVersionFromGithubReleases(cancellation)
|
latest = GetLatestPlayletLibVersionFromGithubReleases(cancellation)
|
||||||
JobSuccessData({
|
JobSuccessData({
|
||||||
latest: latest
|
latest: latest
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ class DashManifest
|
|||||||
if xml.Node("Representation", representationAttributes)
|
if xml.Node("Representation", representationAttributes)
|
||||||
m.AddColorInfo(stream, xml)
|
m.AddColorInfo(stream, xml)
|
||||||
|
|
||||||
if stream.url = invalid
|
if StringUtils.IsNullOrEmpty(stream.url)
|
||||||
xml.Comment(`[ERROR] Stream.url is invalid for itag: ${stream.itag}`)
|
xml.Comment(`[ERROR] Stream.url is null or empty for itag: ${stream.itag}`)
|
||||||
else if stream.url.InStr("source=yt_live_broadcast") <> -1
|
else if stream.url.InStr("source=yt_live_broadcast") <> -1
|
||||||
xml.Comment(`[WARN] Stream URL indicates a live broadcast for itag: ${stream.itag}`)
|
xml.Comment(`[WARN] Stream URL indicates a live broadcast for itag: ${stream.itag}`)
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace Innertube
|
|||||||
visitorData = OptionUtils.Get(options, "visitorData")
|
visitorData = OptionUtils.Get(options, "visitorData")
|
||||||
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
onBehalfOfUser = OptionUtils.Get(options, "onBehalfOfUser")
|
||||||
accessToken = OptionUtils.Get(options, "accessToken")
|
accessToken = OptionUtils.Get(options, "accessToken")
|
||||||
|
videoId = OptionUtils.Get(options, "videoId")
|
||||||
|
|
||||||
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
|
useAccessToken = client = Innertube.ClientType.TV and not StringUtils.IsNullOrEmpty(accessToken)
|
||||||
|
|
||||||
@@ -71,12 +72,17 @@ namespace Innertube
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not StringUtils.IsNullOrEmpty(credentialTransferToken)
|
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"] = [{
|
context["user"]["credentialTransferTokens"] = [{
|
||||||
"token": credentialTransferToken
|
"token": cttToken
|
||||||
"scope": "VIDEO"
|
"scope": "VIDEO"
|
||||||
}]
|
}]
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
if not StringUtils.IsNullOrEmpty(visitorData) and not useAccessToken
|
if not StringUtils.IsNullOrEmpty(visitorData) and not useAccessToken
|
||||||
context["client"]["visitorData"] = visitorData
|
context["client"]["visitorData"] = visitorData
|
||||||
|
|||||||
@@ -17,23 +17,14 @@ import "pkg:/source/utils/TimeUtils.bs"
|
|||||||
namespace InnertubeService
|
namespace InnertubeService
|
||||||
|
|
||||||
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
||||||
|
options["videoId"] = videoId
|
||||||
|
|
||||||
cancellation = OptionUtils.Get(options, "cancellation")
|
cancellation = OptionUtils.Get(options, "cancellation")
|
||||||
fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
|
fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
|
||||||
accessToken = OptionUtils.Get(options, "accessToken")
|
accessToken = OptionUtils.Get(options, "accessToken")
|
||||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
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
|
nextRequest = invalid
|
||||||
nextResponse = invalid
|
|
||||||
if fetchNext
|
if fetchNext
|
||||||
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, options)
|
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, options)
|
||||||
nextRequest.Cancellation(cancellation)
|
nextRequest.Cancellation(cancellation)
|
||||||
@@ -43,79 +34,76 @@ namespace InnertubeService
|
|||||||
nextRequest.Send()
|
nextRequest.Send()
|
||||||
end if
|
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.
|
' 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),
|
' Also, since we might have tracking urls in the player response (if logged in),
|
||||||
' we can keep them to avoid an extra request later.
|
' we can keep them to avoid an extra request later.
|
||||||
' TODO:P0 figure out how to get DASH to work for live videos.
|
' TODO:P0 figure out how to get DASH to work for live videos.
|
||||||
'
|
|
||||||
' # Start of iOS fallback
|
|
||||||
playbackTrackingUrls = invalid
|
playbackTrackingUrls = invalid
|
||||||
responseJson = playerResponse.Json()
|
playerResponseJson = invalid
|
||||||
if ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "isLive"])) or ValidBool(ObjectUtils.Dig(responseJson, ["videoDetails", "hasLiveStreamingData"]))
|
client = Innertube.ClientType.Tv
|
||||||
LogDebug("Live video detected, falling back to iOS for HLS streams.")
|
totalPlayerRequests = 0
|
||||||
isLoggedIn = Innertube.ParseIsLoggedIn(responseJson)
|
while true
|
||||||
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(responseJson, isLoggedIn)
|
' We shouldn't be making more that 3 requests:
|
||||||
|
' 1. Make request with TV client, but turns out to be live -> fallback to iOS
|
||||||
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.IOS, options)
|
' 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)
|
playerRequest.Cancellation(cancellation)
|
||||||
if raw
|
if raw
|
||||||
playerRequest.LogCurlCommand(true)
|
playerRequest.LogCurlCommand(true)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
playerResponse = playerRequest.Await()
|
playerResponse = playerRequest.Await()
|
||||||
if not playerResponse.IsSuccess()
|
|
||||||
return {
|
|
||||||
error: playerResponse.ErrorMessage()
|
|
||||||
}
|
|
||||||
end if
|
|
||||||
|
|
||||||
if CancellationUtils.IsCancelled(cancellation)
|
if CancellationUtils.IsCancelled(cancellation)
|
||||||
return {
|
return {
|
||||||
error: "Cancelled"
|
error: "Cancelled"
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
end if
|
|
||||||
' # End of iOS fallback
|
|
||||||
|
|
||||||
if fetchNext
|
if not playerResponse.IsSuccess()
|
||||||
nextResponse = nextRequest.Await()
|
parsedResponse = {
|
||||||
end if
|
error: playerResponse.ErrorMessage()
|
||||||
|
|
||||||
if raw
|
|
||||||
rawResponse = {
|
|
||||||
"playerResponse": playerResponse.Json()
|
|
||||||
}
|
}
|
||||||
if fetchNext
|
parsedResponse = AwaitAndParseNextResponse(fetchNext, raw, parsedResponse, nextRequest)
|
||||||
rawResponse["nextResponse"] = nextResponse.Json()
|
return parsedResponse
|
||||||
end if
|
|
||||||
return rawResponse
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
parsedResponse = invalid
|
playerResponseJson = playerResponse.Json()
|
||||||
try
|
isLive = Innertube.IsLiveStream(playerResponseJson)
|
||||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json(), playerRequest.signatureTimestamp, cancellation)
|
if isLive and client = Innertube.ClientType.Tv
|
||||||
catch exception
|
LogDebug("Live video detected, falling back to iOS for HLS streams.")
|
||||||
code = ValidString(exception.code)
|
isLoggedIn = Innertube.ParseIsLoggedIn(playerResponseJson)
|
||||||
if code = "STS_MISMATCH"
|
playbackTrackingUrls = Innertube.ParsePlaybackTrackingUrls(playerResponseJson, isLoggedIn)
|
||||||
return GetVideoMetadata(videoId, options)
|
client = Innertube.ClientType.IOS
|
||||||
|
continue while
|
||||||
end if
|
end if
|
||||||
if code = "MISSING_FORMAT_FIELD"
|
|
||||||
|
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({
|
LogTelemetryEvent({
|
||||||
level: "error"
|
level: "error"
|
||||||
message: code
|
message: parsedResponse.errorCode
|
||||||
fingerprint: code
|
fingerprint: parsedResponse.errorCode
|
||||||
attachments: [{
|
attachments: [{
|
||||||
filename: "request.txt"
|
filename: "request.txt"
|
||||||
content_type: "text/plain"
|
content_type: "text/plain"
|
||||||
@@ -127,35 +115,65 @@ namespace InnertubeService
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
end if
|
end if
|
||||||
throw exception
|
end if
|
||||||
end try
|
|
||||||
if parsedResponse.error <> invalid
|
parsedResponse = AwaitAndParseNextResponse(fetchNext, raw, parsedResponse, nextRequest)
|
||||||
return parsedResponse
|
return parsedResponse
|
||||||
|
end while
|
||||||
|
|
||||||
|
if raw
|
||||||
|
rawResponse = {
|
||||||
|
"playerResponse": playerResponseJson
|
||||||
|
}
|
||||||
|
rawResponse = AwaitAndParseNextResponse(fetchNext, raw, rawResponse, nextRequest)
|
||||||
|
return rawResponse
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if fetchNext
|
parsedResponse = AwaitAndParseNextResponse(fetchNext, raw, parsedResponse, nextRequest)
|
||||||
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 StringUtils.IsNullOrEmpty(parsedResponse.videoId)
|
||||||
if parsedResponse.error = invalid and StringUtils.IsNullOrEmpty(parsedResponse.videoId)
|
|
||||||
parsedResponse["videoId"] = videoId
|
parsedResponse["videoId"] = videoId
|
||||||
end if
|
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
|
if playbackTrackingUrls <> invalid and parsedResponse.playbackTrackingUrls = invalid
|
||||||
LogDebug("Adding playback tracking URLs from TV player response.")
|
LogDebug("Adding playback tracking URLs from TV player response.")
|
||||||
parsedResponse["playbackTrackingUrls"] = playbackTrackingUrls
|
parsedResponse["playbackTrackingUrls"] = playbackTrackingUrls
|
||||||
end if
|
end if
|
||||||
' # End of iOS fallback
|
|
||||||
|
|
||||||
return parsedResponse
|
return parsedResponse
|
||||||
end function
|
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()
|
||||||
|
if nextResponse.IsCancelled()
|
||||||
|
return parsedResponse
|
||||||
|
end if
|
||||||
|
|
||||||
|
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
|
function GetVideoInfoBatched(videoIds as object, options = invalid as object) as object
|
||||||
if not IsArray(videoIds) or videoIds.Count() = 0
|
if not IsArray(videoIds) or videoIds.Count() = 0
|
||||||
return {
|
return {
|
||||||
@@ -362,7 +380,8 @@ namespace InnertubeService
|
|||||||
cancellation = options.cancellation
|
cancellation = options.cancellation
|
||||||
end if
|
end if
|
||||||
|
|
||||||
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.Tv, options)
|
options["videoId"] = videoId
|
||||||
|
playerRequest = Innertube.CreatePlayerRequest(Innertube.ClientType.Tv, options)
|
||||||
playerRequest.Cancellation(cancellation)
|
playerRequest.Cancellation(cancellation)
|
||||||
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
playerRequest.Header("Authorization", "Bearer " + accessToken)
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ function ExecuteJob() as void
|
|||||||
|
|
||||||
innertubeNode = input.innertube
|
innertubeNode = input.innertube
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
sessionData = Innertube.GetSessionData(cancellation)
|
sessionData = Innertube.GetSessionData(cancellation)
|
||||||
if sessionData = invalid
|
if sessionData.error <> invalid
|
||||||
JobError("Failed to fetch session data")
|
JobError(sessionData.error)
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,9 @@ namespace Innertube
|
|||||||
})
|
})
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ParseInnertubeNextResponse(payload as object, parsedResponse as object, response as object) as object
|
function ParseInnertubeNextResponse(payload as object, parsedResponse as object, httpResponse as object) as object
|
||||||
if parsedResponse.error <> invalid
|
if not IsArray(parsedResponse["recommendedVideos"])
|
||||||
LogWarn("Invalid parsed response", parsedResponse)
|
parsedResponse["recommendedVideos"] = []
|
||||||
return parsedResponse
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if not IsAssociativeArray(payload)
|
if not IsAssociativeArray(payload)
|
||||||
@@ -65,15 +64,10 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if not IsArray(parsedResponse.recommendedVideos)
|
|
||||||
LogWarn("Invalid recommended videos", parsedResponse.recommendedVideos)
|
|
||||||
return parsedResponse
|
|
||||||
end if
|
|
||||||
|
|
||||||
endscreen = playerOverlayRenderer["endScreen"]
|
endscreen = playerOverlayRenderer["endScreen"]
|
||||||
|
|
||||||
feeds = Innertube.ParseResponseDataForFeeds(endscreen, {
|
feeds = Innertube.ParseResponseDataForFeeds(endscreen, {
|
||||||
response: response
|
response: httpResponse
|
||||||
noContainers: true
|
noContainers: true
|
||||||
})
|
})
|
||||||
if feeds.Count() > 0
|
if feeds.Count() > 0
|
||||||
|
|||||||
@@ -32,10 +32,15 @@ namespace Innertube
|
|||||||
|
|
||||||
Innertube.ParseNode(containers, context)
|
Innertube.ParseNode(containers, context)
|
||||||
|
|
||||||
if context.currentFeed <> invalid and (context.currentFeed.items.Count() > 0 or context.currentFeed.title <> "")
|
if context.currentFeed <> invalid
|
||||||
|
hasTitle = context.currentFeed.title <> ""
|
||||||
|
hasItems = context.currentFeed.items.Count() > 0
|
||||||
|
hasContinuation = context.currentFeed.DoesExist("continuation")
|
||||||
|
if hasTitle or hasItems or hasContinuation
|
||||||
context.feeds.Push(context.currentFeed)
|
context.feeds.Push(context.currentFeed)
|
||||||
context.currentFeed = invalid
|
context.currentFeed = invalid
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
return context.feeds
|
return context.feeds
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import "pkg:/source/utils/UrlUtils.bs"
|
|||||||
|
|
||||||
namespace Innertube
|
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")
|
cancellation = OptionUtils.Get(options, "cancellation")
|
||||||
visitorData = OptionUtils.Get(options, "visitorData")
|
visitorData = OptionUtils.Get(options, "visitorData")
|
||||||
accessToken = OptionUtils.Get(options, "accessToken")
|
accessToken = OptionUtils.Get(options, "accessToken")
|
||||||
@@ -62,60 +63,82 @@ namespace Innertube
|
|||||||
return request
|
return request
|
||||||
end function
|
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)
|
error = ParsePlayerResponseForError(payload)
|
||||||
if error <> ""
|
if error <> ""
|
||||||
return {
|
parsedResponse["error"] = error
|
||||||
error: error
|
return parsedResponse
|
||||||
}
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
videoDetails = payload["videoDetails"]
|
videoDetails = payload["videoDetails"]
|
||||||
if not IsAssociativeArray(videoDetails)
|
if not IsAssociativeArray(videoDetails)
|
||||||
return {
|
parsedResponse["error"] = "Invalid videoDetails"
|
||||||
error: "Invalid video details"
|
return parsedResponse
|
||||||
}
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
streamingData = payload["streamingData"]
|
streamingData = payload["streamingData"]
|
||||||
if not IsAssociativeArray(streamingData)
|
if not IsAssociativeArray(streamingData)
|
||||||
return {
|
parsedResponse["error"] = "Invalid streamingData"
|
||||||
error: "Invalid streaming data"
|
return parsedResponse
|
||||||
}
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
lengthSeconds = videoDetails["lengthSeconds"].ToInt()
|
||||||
isLive = ValidBool(videoDetails["isLive"])
|
isLive = ValidBool(videoDetails["isLive"])
|
||||||
adaptiveFormats = ParseAdaptiveFormats(payload, signatureTimestamp, isLive, cancellation)
|
|
||||||
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats)
|
|
||||||
|
|
||||||
videoInfo = {
|
adaptiveFormats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"]))
|
||||||
"type": "video"
|
formats = ValidArray(ObjectUtils.Dig(payload, ["streamingData", "formats"]))
|
||||||
"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": []
|
|
||||||
}
|
|
||||||
|
|
||||||
if videoDetails.DoesExist("viewCount")
|
if not isLive
|
||||||
videoInfo["viewCount"] = videoDetails["viewCount"].ToInt()
|
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
|
end if
|
||||||
|
|
||||||
videoInfo["isLoggedIn"] = ParseIsLoggedIn(payload)
|
hasLiveStreamingData = FormatsHaveLiveStreamingData(adaptiveFormats) or FormatsHaveLiveStreamingData(formats)
|
||||||
videoInfo["playbackTrackingUrls"] = ParsePlaybackTrackingUrls(payload, videoInfo.isLoggedIn)
|
|
||||||
|
|
||||||
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
|
end function
|
||||||
|
|
||||||
function ParsePlayerResponseForError(payload as object) as string
|
function ParsePlayerResponseForError(payload as object) as string
|
||||||
@@ -154,11 +177,6 @@ namespace Innertube
|
|||||||
if status = "LOGIN_REQUIRED"
|
if status = "LOGIN_REQUIRED"
|
||||||
' TODO:P2 localize
|
' TODO:P2 localize
|
||||||
errorLines.Push("Hint: Log in to the YouTube app on your phone, then cast the video to Playlet.")
|
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
|
end if
|
||||||
|
|
||||||
return errorLines.Join(`\n`)
|
return errorLines.Join(`\n`)
|
||||||
@@ -296,25 +314,14 @@ namespace Innertube
|
|||||||
return captions
|
return captions
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ParseAdaptiveFormats(payload as object, signatureTimestamp as dynamic, isLive as boolean, cancellation as object) as object
|
function TransformFormats(formats as object) as object
|
||||||
adaptiveFormats = ObjectUtils.Dig(payload, ["streamingData", "adaptiveFormats"])
|
for i = 0 to formats.Count() - 1
|
||||||
if not IsArray(adaptiveFormats)
|
formats[i] = TransformFormat(formats[i])
|
||||||
return []
|
|
||||||
end if
|
|
||||||
|
|
||||||
if not isLive
|
|
||||||
adaptiveFormats = DecipherUrls(adaptiveFormats, signatureTimestamp, cancellation)
|
|
||||||
end if
|
|
||||||
|
|
||||||
formats = []
|
|
||||||
for each fmt in adaptiveFormats
|
|
||||||
formats.Push(GetAdaptiveFormat(fmt))
|
|
||||||
end for
|
end for
|
||||||
|
|
||||||
return formats
|
return formats
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetAdaptiveFormat(fmt as object) as object
|
function TransformFormat(fmt as object) as object
|
||||||
itag = `${fmt["itag"]}`
|
itag = `${fmt["itag"]}`
|
||||||
result = {
|
result = {
|
||||||
"bitrate": `${fmt["bitrate"]}`
|
"bitrate": `${fmt["bitrate"]}`
|
||||||
@@ -396,24 +403,34 @@ namespace Innertube
|
|||||||
return json["sts"]
|
return json["sts"]
|
||||||
end function
|
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
|
if signatureTimestamp = invalid
|
||||||
' No need to decipher if signatureTimestamp is not available
|
' No need to decipher if signatureTimestamp is not available
|
||||||
return adaptiveFormats
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
formats = []
|
reqFormats = []
|
||||||
for each fmt in adaptiveFormats
|
for each fmt in formats
|
||||||
formats.push({
|
reqFormats.push({
|
||||||
"url": fmt["url"]
|
"url": fmt["url"]
|
||||||
"cipher": fmt["cipher"]
|
"cipher": fmt["cipher"]
|
||||||
"signatureCipher": fmt["signatureCipher"]
|
"signatureCipher": fmt["signatureCipher"]
|
||||||
})
|
})
|
||||||
end for
|
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
|
"sts": signatureTimestamp
|
||||||
"formats": formats
|
"formats": reqFormats
|
||||||
|
"adaptiveFormats": reqAdaptiveFormats
|
||||||
})
|
})
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
|
||||||
@@ -426,46 +443,64 @@ namespace Innertube
|
|||||||
else
|
else
|
||||||
LogError(response.ErrorMessage())
|
LogError(response.ErrorMessage())
|
||||||
end if
|
end if
|
||||||
code = ""
|
errorCode = ""
|
||||||
if response.StatusCode() = 400
|
if response.StatusCode() = 400
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
if IsAssociativeArray(json)
|
if IsAssociativeArray(json)
|
||||||
code = ValidString(json["code"])
|
errorCode = ValidString(json["code"])
|
||||||
if code = "STS_MISMATCH"
|
if errorCode = "STS_MISMATCH"
|
||||||
DeleteFile("tmp:/sts_cache.json")
|
DeleteFile("tmp:/sts_cache.json")
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
exception = { message: response.ErrorMessage() }
|
exception = {
|
||||||
if code <> ""
|
error: response.ErrorMessage()
|
||||||
exception.code = code
|
}
|
||||||
|
if errorCode <> ""
|
||||||
|
exception.errorCode = errorCode
|
||||||
end if
|
end if
|
||||||
throw exception
|
return exception
|
||||||
end if
|
end if
|
||||||
|
|
||||||
json = response.Json()
|
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"
|
error = "Invalid response from decipher service"
|
||||||
LogError(error)
|
LogError(error)
|
||||||
throw error
|
return {
|
||||||
|
error: error
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
decipheredFormats = json["formats"]
|
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"
|
error = "Invalid formats in deciphered response"
|
||||||
LogError(error)
|
LogError(error)
|
||||||
throw error
|
return {
|
||||||
|
error: error
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
for i = 0 to decipheredFormats.Count() - 1
|
for i = 0 to decipheredFormats.Count() - 1
|
||||||
fmt = adaptiveFormats[i]
|
fmt = formats[i]
|
||||||
decipheredFmt = decipheredFormats[i]
|
decipheredFmt = decipheredFormats[i]
|
||||||
|
|
||||||
fmt["url"] = decipheredFmt["url"]
|
fmt["url"] = decipheredFmt["url"]
|
||||||
end for
|
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
|
end function
|
||||||
|
|
||||||
function ParseIsLoggedIn(payload as object) as boolean
|
function ParseIsLoggedIn(payload as object) as boolean
|
||||||
@@ -512,12 +547,28 @@ namespace Innertube
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function FormatsHaveLiveStreamingData(adaptiveFormats as object) as boolean
|
function IsLiveStream(payload as object) as boolean
|
||||||
if not IsArray(adaptiveFormats)
|
if ValidBool(ObjectUtils.Dig(payload, ["videoDetails", "isLive"]))
|
||||||
return false
|
return true
|
||||||
end if
|
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"]
|
url = fmt["url"]
|
||||||
if IsString(url) and url.InStr("yt_live_broadcast") <> -1
|
if IsString(url) and url.InStr("yt_live_broadcast") <> -1
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ namespace Innertube
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
sessionData = RequestSessionData(cancellation)
|
sessionData = RequestSessionData(cancellation)
|
||||||
|
if sessionData.error <> invalid
|
||||||
|
return sessionData
|
||||||
|
end if
|
||||||
SaveSessionDataToRegistry(sessionData)
|
SaveSessionDataToRegistry(sessionData)
|
||||||
return sessionData
|
return sessionData
|
||||||
end function
|
end function
|
||||||
@@ -31,11 +34,13 @@ namespace Innertube
|
|||||||
"Referer": "https://www.youtube.com/sw.js"
|
"Referer": "https://www.youtube.com/sw.js"
|
||||||
})
|
})
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
request.TryCount(2)
|
||||||
|
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
LogError("Failed to fetch session data", response.ErrorMessage())
|
return {
|
||||||
return invalid
|
"error": "Failed to fetch session data: " + response.ErrorMessage()
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
text = response.Text()
|
text = response.Text()
|
||||||
@@ -43,14 +48,16 @@ namespace Innertube
|
|||||||
|
|
||||||
json = ParseJson(text)
|
json = ParseJson(text)
|
||||||
if json = invalid
|
if json = invalid
|
||||||
LogError("Failed to parse session data", text)
|
return {
|
||||||
return invalid
|
"error": "Failed to parse session data: " + text
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
visitorData = ObjectUtils.Dig(json, [0, 2, 0, 0, 13])
|
visitorData = ObjectUtils.Dig(json, [0, 2, 0, 0, 13])
|
||||||
if StringUtils.IsNullOrEmpty(visitorData)
|
if StringUtils.IsNullOrEmpty(visitorData)
|
||||||
LogError("Visitor data not found", text)
|
return {
|
||||||
return invalid
|
"error": "Failed to find visitorData in session data: " + text
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -60,10 +67,6 @@ namespace Innertube
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function SaveSessionDataToRegistry(sessionData as object) as void
|
function SaveSessionDataToRegistry(sessionData as object) as void
|
||||||
if sessionData = invalid
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
sessionData.__version = SESSION_DATA_VERSION
|
sessionData.__version = SESSION_DATA_VERSION
|
||||||
|
|
||||||
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
|
RegistryUtils.Write(RegistryUtils.INNERTUBE_SESSION_DATA, FormatJson(sessionData))
|
||||||
|
|||||||
@@ -128,9 +128,6 @@ namespace Invidious
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
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")
|
cancellation = OptionUtils.Get(options, "cancellation")
|
||||||
tryCount = OptionUtils.GetOrDefault(options, "tryCount", 2)
|
tryCount = OptionUtils.GetOrDefault(options, "tryCount", 2)
|
||||||
|
|
||||||
@@ -139,7 +136,6 @@ namespace Invidious
|
|||||||
|
|
||||||
request = HttpClient.Get(url)
|
request = HttpClient.Get(url)
|
||||||
|
|
||||||
request.CacheSeconds(cacheSeconds)
|
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
|
||||||
if tryCount > 1
|
if tryCount > 1
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class LongPoller
|
|||||||
m.status_code = Val(statusCode)
|
m.status_code = Val(statusCode)
|
||||||
m.status_text = status.Mid(spaceIndex + 1)
|
m.status_text = status.Mid(spaceIndex + 1)
|
||||||
if m.status_code <> 200
|
if m.status_code <> 200
|
||||||
if m.status_code = 400 and m.status_text = "Unknown SID"
|
if m.status_code = 410 or (m.status_code = 400 and m.status_text = "Unknown SID")
|
||||||
LogErrorNoTelemetry("Invalid status code:", m.status_code, m.status_text, `\nResponse data:`, m.socket_buffer)
|
LogErrorNoTelemetry("Invalid status code:", m.status_code, m.status_text, `\nResponse data:`, m.socket_buffer)
|
||||||
else
|
else
|
||||||
LogError("Invalid status code:", m.status_code, m.status_text, `\nResponse data:`, m.socket_buffer)
|
LogError("Invalid status code:", m.status_code, m.status_text, `\nResponse data:`, m.socket_buffer)
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class LoungeApi
|
|||||||
commandHandlers[COMMAND_TYPE_GET_VOLUME] = m.HandleIgnoreCommand
|
commandHandlers[COMMAND_TYPE_GET_VOLUME] = m.HandleIgnoreCommand
|
||||||
commandHandlers[COMMAND_TYPE_GET_SUBTITLES_TRACK] = m.HandleIgnoreCommand
|
commandHandlers[COMMAND_TYPE_GET_SUBTITLES_TRACK] = m.HandleIgnoreCommand
|
||||||
commandHandlers[COMMAND_TYPE_SET_SUBTITLES] = 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_DPAD_COMMAND] = m.HandleIgnoreCommand
|
||||||
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand
|
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand
|
||||||
commandHandlers[COMMAND_TYPE_ON_USER_ACTIVITY] = 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.
|
' 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.
|
' 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.
|
' These tokens need to be managed better, based on the video they belong to.
|
||||||
if not StringUtils.IsNullOrEmpty(commandArgs[FIELD_CTT])
|
if not StringUtils.IsNullOrEmpty(commandArgs[FIELD_CTT]) and not StringUtils.IsNullOrEmpty(commandArgs[FIELD_VIDEO_ID])
|
||||||
m.loungeServiceNode.credentialTransferToken = commandArgs[FIELD_CTT]
|
m.loungeServiceNode.credentialTransferToken = {
|
||||||
|
"token": commandArgs[FIELD_CTT]
|
||||||
|
"videoId": commandArgs[FIELD_VIDEO_ID]
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
|
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
|
||||||
end function
|
end function
|
||||||
@@ -560,7 +564,7 @@ class LoungeApi
|
|||||||
})
|
})
|
||||||
|
|
||||||
if not response.IsSuccess()
|
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())
|
LogErrorNoTelemetry(response.ErrorMessage())
|
||||||
else
|
else
|
||||||
LogError(response.ErrorMessage())
|
LogError(response.ErrorMessage())
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const COMMAND_TYPE_STOP_VIDEO = "stopVideo"
|
|||||||
const COMMAND_TYPE_DPAD_COMMAND = "dpadCommand"
|
const COMMAND_TYPE_DPAD_COMMAND = "dpadCommand"
|
||||||
const COMMAND_TYPE_VOICE_COMMAND = "voiceCommand"
|
const COMMAND_TYPE_VOICE_COMMAND = "voiceCommand"
|
||||||
const COMMAND_TYPE_SET_SUBTITLES = "setSubtitlesTrack"
|
const COMMAND_TYPE_SET_SUBTITLES = "setSubtitlesTrack"
|
||||||
|
const COMMAND_TYPE_SET_AUDIO_TRACK = "setAudioTrack"
|
||||||
const COMMAND_TYPE_ON_USER_ACTIVITY = "onUserActivity"
|
const COMMAND_TYPE_ON_USER_ACTIVITY = "onUserActivity"
|
||||||
const COMMAND_TYPE_GET_DISCOVERT_DEVICE_ID = "getDiscoveryDeviceId"
|
const COMMAND_TYPE_GET_DISCOVERT_DEVICE_ID = "getDiscoveryDeviceId"
|
||||||
const COMMAND_TYPE_GRACEFUL_RECONNECT = "gracefulReconnect"
|
const COMMAND_TYPE_GRACEFUL_RECONNECT = "gracefulReconnect"
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ function ExecuteJob() as void
|
|||||||
form["access_type"] = "permanent"
|
form["access_type"] = "permanent"
|
||||||
form["app"] = "Playlet"
|
form["app"] = "Playlet"
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair", "")
|
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair", "")
|
||||||
request.UrlEncodedForm(form)
|
request.UrlEncodedForm(form)
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ function LoungeServiceLoop() as void
|
|||||||
|
|
||||||
unknownSid = false
|
unknownSid = false
|
||||||
' TODO:P2 move this check somewhere else
|
' TODO:P2 move this check somewhere else
|
||||||
if api.poller.status_code = 400 and ValidString(api.poller.status_text) = "Unknown SID"
|
if (api.poller.status_code = 410) or (api.poller.status_code = 400 and ValidString(api.poller.status_text) = "Unknown SID")
|
||||||
api.poller.status_code = 0
|
api.poller.status_code = 0
|
||||||
unknownSid = true
|
unknownSid = true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if not unknownSid
|
if not unknownSid
|
||||||
for each result in outgoingLoungeMessagesResults
|
for each result in outgoingLoungeMessagesResults
|
||||||
if result.status = 400 and result.error.InStr("Unknown SID") <> -1
|
if result.status = 410 or (result.status = 400 and result.error.InStr("Unknown SID") <> -1)
|
||||||
unknownSid = true
|
unknownSid = true
|
||||||
exit for
|
exit for
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -5,7 +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="credentialTransferToken" type="string" />
|
<field id="credentialTransferToken" type="assocarray" />
|
||||||
|
|
||||||
<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" />
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function ExecuteJob() as void
|
|||||||
categories = input.categories
|
categories = input.categories
|
||||||
|
|
||||||
service = new SponsorBlock.SponsorBlockService()
|
service = new SponsorBlock.SponsorBlockService()
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
skipSegments = service.GetSkipSegmentsForVideo(videoId, cancellation)
|
skipSegments = service.GetSkipSegmentsForVideo(videoId, cancellation)
|
||||||
|
|
||||||
skipSegments = ProcessSkipSegments(skipSegments, showNotifications, categories, service)
|
skipSegments = ProcessSkipSegments(skipSegments, showNotifications, categories, service)
|
||||||
|
|||||||
@@ -28,17 +28,6 @@ namespace Sentry
|
|||||||
event.timestamp = timestamp
|
event.timestamp = timestamp
|
||||||
end if
|
end if
|
||||||
|
|
||||||
message = event.message
|
|
||||||
|
|
||||||
hasAttachments = IsArray(event.attachments) and event.attachments.Count() > 0
|
|
||||||
|
|
||||||
if (not SUPPORTS_ATTACHMENTS) and hasAttachments
|
|
||||||
message += `\nAttachments:`
|
|
||||||
for each attachment in event.attachments
|
|
||||||
message += `\nAttachment: ${attachment.filename} (${attachment.content_type})\n${attachment.data}`
|
|
||||||
end for
|
|
||||||
end if
|
|
||||||
|
|
||||||
eventPayload = {
|
eventPayload = {
|
||||||
event_id: event.event_id
|
event_id: event.event_id
|
||||||
timestamp: event.timestamp
|
timestamp: event.timestamp
|
||||||
@@ -51,21 +40,43 @@ namespace Sentry
|
|||||||
release: event.release
|
release: event.release
|
||||||
tags: event.tags
|
tags: event.tags
|
||||||
level: event.level
|
level: event.level
|
||||||
logentry: {
|
|
||||||
formatted: message
|
|
||||||
}
|
|
||||||
user: {
|
user: {
|
||||||
id: event.userId
|
id: event.userId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message = event.message
|
||||||
|
|
||||||
|
if event.fingerprint = invalid
|
||||||
|
event.fingerprint = GetFingerprint(message)
|
||||||
|
end if
|
||||||
|
|
||||||
if event.fingerprint <> invalid
|
if event.fingerprint <> invalid
|
||||||
if IsString(event.fingerprint)
|
fingerprint = event.fingerprint
|
||||||
eventPayload.fingerprint = [event.fingerprint]
|
if not IsArray(fingerprint)
|
||||||
else if IsArray(event.fingerprint)
|
fingerprint = [fingerprint]
|
||||||
eventPayload.fingerprint = event.fingerprint
|
|
||||||
end if
|
end if
|
||||||
|
for i = 0 to fingerprint.Count() - 1
|
||||||
|
if not IsString(fingerprint[i])
|
||||||
|
fingerprint[i] = ToString(fingerprint[i])
|
||||||
end if
|
end if
|
||||||
|
end for
|
||||||
|
eventPayload.fingerprint = fingerprint
|
||||||
|
end if
|
||||||
|
|
||||||
|
hasAttachments = IsArray(event.attachments) and event.attachments.Count() > 0
|
||||||
|
|
||||||
|
if (not SUPPORTS_ATTACHMENTS) and hasAttachments
|
||||||
|
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.logentry = {
|
||||||
|
formatted: message
|
||||||
|
}
|
||||||
|
|
||||||
payload += FormatJson(eventPayload) + `\n`
|
payload += FormatJson(eventPayload) + `\n`
|
||||||
|
|
||||||
@@ -113,4 +124,37 @@ namespace Sentry
|
|||||||
return eventId
|
return eventId
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function GetFingerprint(message as dynamic) as dynamic
|
||||||
|
if StringUtils.IsNullOrEmpty(message)
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
' Replaces `\nRequestId: 12345678\n` with `\nRequestId: <REQUEST_ID>\n`
|
||||||
|
fingerprint = ReplaceRequestId(message)
|
||||||
|
if fingerprint = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
return [fingerprint]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ReplaceRequestId(message as string) as string
|
||||||
|
reqIdStart = `\nRequestId: `
|
||||||
|
requestIdIndex = message.InStr(reqIdStart)
|
||||||
|
if requestIdIndex = -1
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
newLineIndex = message.InStr(requestIdIndex + reqIdStart.Len(), `\n`)
|
||||||
|
if newLineIndex = -1
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
reqIdStartIndex = requestIdIndex + reqIdStart.Len()
|
||||||
|
reqIdEndIndex = newLineIndex - 1
|
||||||
|
if (reqIdEndIndex <= reqIdStartIndex) or ((reqIdEndIndex - reqIdStartIndex) > 20)
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
fingerprint = message.Mid(0, reqIdStartIndex) + "<REQUEST_ID>" + message.Mid(reqIdEndIndex + 1)
|
||||||
|
return fingerprint
|
||||||
|
end function
|
||||||
end namespace
|
end namespace
|
||||||
@@ -68,7 +68,9 @@ function ExecuteJob() as void
|
|||||||
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
|
if response.error = Invidious.ERROR_NOT_AUTHENTICATED
|
||||||
if feedSources.Count() = 1
|
if feedSources.Count() = 1
|
||||||
parent = feedContentNode.getParent()
|
parent = feedContentNode.getParent()
|
||||||
|
if parent <> invalid
|
||||||
parent.removeChild(feedContentNode)
|
parent.removeChild(feedContentNode)
|
||||||
|
end if
|
||||||
JobSuccess()
|
JobSuccess()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
@@ -80,7 +82,9 @@ function ExecuteJob() as void
|
|||||||
LogWarnNoTelemetry(feedSource.endpoint, "feedSource not available:", response.error)
|
LogWarnNoTelemetry(feedSource.endpoint, "feedSource not available:", response.error)
|
||||||
if feedSources.Count() = 1
|
if feedSources.Count() = 1
|
||||||
parent = feedContentNode.getParent()
|
parent = feedContentNode.getParent()
|
||||||
|
if parent <> invalid
|
||||||
parent.removeChild(feedContentNode)
|
parent.removeChild(feedContentNode)
|
||||||
|
end if
|
||||||
JobSuccess()
|
JobSuccess()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function ExecuteJob() as void
|
|||||||
profileType = input.profileType
|
profileType = input.profileType
|
||||||
playbackTrackingUrls = input.playbackTrackingUrls
|
playbackTrackingUrls = input.playbackTrackingUrls
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
|
|
||||||
if profileType = "invidious"
|
if profileType = "invidious"
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function ExecuteJob() as void
|
|||||||
|
|
||||||
metadata = contentNode.metadata
|
metadata = contentNode.metadata
|
||||||
if not IsAssociativeArray(metadata)
|
if not IsAssociativeArray(metadata)
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
if backend = "playlet"
|
if backend = "playlet"
|
||||||
visitorData = innertubeNode.visitorData
|
visitorData = innertubeNode.visitorData
|
||||||
if StringUtils.IsNullOrEmpty(visitorData)
|
if StringUtils.IsNullOrEmpty(visitorData)
|
||||||
@@ -68,13 +68,13 @@ function ExecuteJob() as void
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if metadata = invalid
|
if JobIsCancelled()
|
||||||
JobError("Failed to get video metadata")
|
JobCancel()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if JobIsCancelled()
|
if metadata = invalid
|
||||||
JobCancel()
|
JobError("Failed to get video metadata")
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -97,6 +97,12 @@ function ExecuteJob() as void
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, backend, playletServerPort)
|
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
|
' 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
|
' because the playlist is limited to 4MB, and on large playlists the query params
|
||||||
' significantly increase the size of the playlist, making it cropped.
|
' significantly increase the size of the playlist, making it cropped.
|
||||||
@@ -126,18 +132,46 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
|
|||||||
|
|
||||||
streamUrls = []
|
streamUrls = []
|
||||||
|
|
||||||
if not StringUtils.IsNullOrEmpty(metadata.hlsUrl)
|
if SupportsHls(metadata)
|
||||||
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
|
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
|
||||||
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
||||||
else
|
else if SupportsDash(metadata)
|
||||||
' Not that we're using dashUrl, but why not, it useful when testing it
|
|
||||||
metadata.dashUrl = AddInstanceToUrlIfNeeded(metadata.dashUrl, instance)
|
|
||||||
AddDashUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
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
|
end if
|
||||||
|
|
||||||
return streamUrls
|
return streamUrls
|
||||||
end function
|
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)
|
function AddHlsUrls(streamUrls as object, metadata as object, preferredQuality as string, backend as string, proxyVideos as string, playletServerPort as integer)
|
||||||
hlsUrl = metadata.hlsUrl
|
hlsUrl = metadata.hlsUrl
|
||||||
hlsUrlLocal = invalid
|
hlsUrlLocal = invalid
|
||||||
|
|||||||
@@ -566,7 +566,6 @@ function ReportVideoError(errorData as object, url as string) as void
|
|||||||
content_type: "plain/text"
|
content_type: "plain/text"
|
||||||
data: lastGeneratedDash
|
data: lastGeneratedDash
|
||||||
}]
|
}]
|
||||||
DeleteFile("tmp:/last_generated_dash.xml")
|
|
||||||
else
|
else
|
||||||
lastGeneratedHls = ReadAsciiFile("tmp:/last_generated_hls.m3u8")
|
lastGeneratedHls = ReadAsciiFile("tmp:/last_generated_hls.m3u8")
|
||||||
if not StringUtils.IsNullOrEmpty(lastGeneratedHls)
|
if not StringUtils.IsNullOrEmpty(lastGeneratedHls)
|
||||||
@@ -575,7 +574,6 @@ function ReportVideoError(errorData as object, url as string) as void
|
|||||||
content_type: "plain/text"
|
content_type: "plain/text"
|
||||||
data: lastGeneratedHls
|
data: lastGeneratedHls
|
||||||
}]
|
}]
|
||||||
DeleteFile("tmp:/last_generated_hls.m3u8")
|
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function ExecuteJob() as void
|
|||||||
|
|
||||||
backgroundPoster.uri = `${instance}/vi/${videoId}/maxresdefault.jpg`
|
backgroundPoster.uri = `${instance}/vi/${videoId}/maxresdefault.jpg`
|
||||||
|
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
backend = preferencesNode["backend.selected"]
|
backend = preferencesNode["backend.selected"]
|
||||||
if backend = "playlet"
|
if backend = "playlet"
|
||||||
metadata = InnertubeService.GetVideoMetadata(videoId, { cancellation: cancellation })
|
metadata = InnertubeService.GetVideoMetadata(videoId, { cancellation: cancellation })
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function ExecuteJob() as void
|
|||||||
preferencesNode = input.preferences
|
preferencesNode = input.preferences
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
instance = service.GetInstance()
|
instance = service.GetInstance()
|
||||||
cancellation = CancellationUtils.CreateCancellation(JobGetCallbackNode(), "cancel", true)
|
cancellation = JobGetCancellation()
|
||||||
|
|
||||||
index = MathUtils.Clamp(input.index - 2, 0, videoNodes.Count() - 1)
|
index = MathUtils.Clamp(input.index - 2, 0, videoNodes.Count() - 1)
|
||||||
|
|
||||||
@@ -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
|
function LoadVideoDetail(videoNode as object, service as object, instance as string, requestOptions as object, backend as string) as boolean
|
||||||
videoId = videoNode.videoId
|
videoId = videoNode.videoId
|
||||||
|
|
||||||
if backend = "playlet"
|
if backend = "playlet" or instance = Invidious.PLAYLET_BUILT_IN_INSTANCE
|
||||||
requestOptions["retry"] = false
|
requestOptions["retry"] = false
|
||||||
metadata = InnertubeService.GetVideoInfoBatched([videoId], requestOptions)
|
metadata = InnertubeService.GetVideoInfoBatched([videoId], requestOptions)
|
||||||
if IsArray(metadata.videos) and metadata.videos.Count() > 0
|
if IsArray(metadata.videos) and metadata.videos.Count() > 0
|
||||||
|
|||||||
+30
-2
@@ -420,7 +420,19 @@ namespace Http
|
|||||||
options.continuation = continuation
|
options.continuation = continuation
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
fetchedPages = 0
|
||||||
|
while true
|
||||||
|
' Content can be filtered (for example, shorts removed)
|
||||||
|
' so we could be fetching multiple pages.
|
||||||
|
if fetchedPages > 3
|
||||||
|
response.Json({
|
||||||
|
"error": "Failed to search: no results found"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
|
return true
|
||||||
|
end if
|
||||||
result = InnertubeService.Search(query, options)
|
result = InnertubeService.Search(query, options)
|
||||||
|
fetchedPages += 1
|
||||||
|
|
||||||
if raw
|
if raw
|
||||||
response.Json(result)
|
response.Json(result)
|
||||||
@@ -441,10 +453,26 @@ namespace Http
|
|||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
response.Json(result.feeds[0])
|
feed = result.feeds[0]
|
||||||
if result.DoesExist("cache-control")
|
if feed.items.Count() > 0
|
||||||
|
response.Json(feed)
|
||||||
|
if fetchedPages = 1 and result.DoesExist("cache-control")
|
||||||
response.headers["cache-control"] = result["cache-control"]
|
response.headers["cache-control"] = result["cache-control"]
|
||||||
end if
|
end if
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(feed.continuation)
|
||||||
|
response.Json({
|
||||||
|
"error": "Failed to search: no results found"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogDebug("Search returned no results, fetching next page with continuation")
|
||||||
|
options.continuation = feed.continuation
|
||||||
|
end while
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title=PlayletLib
|
|||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=41
|
minor_version=41
|
||||||
build_version=00010
|
build_version=00015
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
uri_resolution_autosub=$$RES$$,480p,720p,1080p
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.0",
|
"@sveltejs/vite-plugin-svelte": "^6.2.0",
|
||||||
"@tailwindcss/postcss": "^4.1.13",
|
"@tailwindcss/postcss": "^4.1.13",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-web",
|
"name": "playlet-web",
|
||||||
"version": "0.41.10",
|
"version": "0.41.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
Reference in new issue
Block a user