Capture additional fields to investigate DRM errors
This commit is contained in:
1 parent
555665488d
commit
9eac1aac04
14 files changed
+251
-47
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import "pkg:/components/Services/Innertube/GetDrmLicenseEndpoint.types.bs"
|
||||
import "pkg:/components/Telemetry/VideoLoadHandoff.bs"
|
||||
|
||||
const DRM_LICENSE_REQUESTS_PATH = "tmp:/drm_license_requests.json"
|
||||
const DRM_LICENSE_RESPONSE_SAMPLE_CAP = 10
|
||||
|
||||
namespace DrmLicenseRequests
|
||||
|
||||
function RecordSent(videoLoadId as string) as void
|
||||
requests = DrmLicenseRequests.Load(videoLoadId)
|
||||
requests["sent"] += 1
|
||||
VideoLoadHandoff.Write(DRM_LICENSE_REQUESTS_PATH, videoLoadId, requests)
|
||||
end function
|
||||
|
||||
function RecordResponse(videoLoadId as string, response as Innertube.DrmLicenseResponse) as void
|
||||
requests = DrmLicenseRequests.Load(videoLoadId)
|
||||
responses = requests["responses"]
|
||||
if responses.Count() >= DRM_LICENSE_RESPONSE_SAMPLE_CAP
|
||||
return
|
||||
end if
|
||||
if response.payload <> invalid
|
||||
responses.Push({ "payload": response.payload })
|
||||
else
|
||||
responses.Push({ "error": response.error })
|
||||
end if
|
||||
VideoLoadHandoff.Write(DRM_LICENSE_REQUESTS_PATH, videoLoadId, requests)
|
||||
end function
|
||||
|
||||
function Load(videoLoadId as string) as object
|
||||
requests = VideoLoadHandoff.Read(DRM_LICENSE_REQUESTS_PATH, videoLoadId)
|
||||
if not IsAssociativeArray(requests)
|
||||
return { "sent": 0, "responses": [] }
|
||||
end if
|
||||
return requests
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,3 +1,5 @@
|
||||
import "pkg:/components/Services/Innertube/GetDrmLicenseEndpoint.types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function CreateGetDrmLicenceRequest(options as object) as HttpClient.Request
|
||||
@@ -39,7 +41,7 @@ namespace Innertube
|
||||
return request
|
||||
end function
|
||||
|
||||
function ParseGetDrmLicenseResponse(payload as object) as dynamic
|
||||
function ParseGetDrmLicenseResponse(payload as object) as Innertube.DrmLicenseResponse
|
||||
if not IsAssociativeArray(payload)
|
||||
return {
|
||||
"error": "Invalid JSON response"
|
||||
@@ -50,6 +52,7 @@ namespace Innertube
|
||||
if status <> "LICENSE_STATUS_OK"
|
||||
return {
|
||||
"error": "DRM license request failed with status: " + status
|
||||
"payload": payload
|
||||
}
|
||||
end if
|
||||
|
||||
@@ -57,12 +60,24 @@ namespace Innertube
|
||||
if StringUtils.IsNullOrEmpty(license)
|
||||
return {
|
||||
"error": "DRM license is missing in the response"
|
||||
"payload": payload
|
||||
}
|
||||
end if
|
||||
|
||||
buffer = createObject("roByteArray")
|
||||
buffer.FromBase64String(license.Replace("-", "+").Replace("_", "/"))
|
||||
return buffer
|
||||
if buffer.Count() = 0
|
||||
return {
|
||||
"error": "DRM license decodes to no bytes"
|
||||
"payload": payload
|
||||
}
|
||||
end if
|
||||
|
||||
payload.Delete("license")
|
||||
return {
|
||||
"license": buffer
|
||||
"payload": payload
|
||||
}
|
||||
end function
|
||||
|
||||
function GenerateDrmSessionId() as string
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Innertube
|
||||
|
||||
interface DrmLicenseResponse
|
||||
optional license as roByteArray
|
||||
' The response, without the license once it decoded.
|
||||
optional payload as object
|
||||
optional error as string
|
||||
end interface
|
||||
|
||||
end namespace
|
||||
@@ -810,7 +810,7 @@ namespace InnertubeService
|
||||
return Innertube.ListAccounts(accessToken, cancellation)
|
||||
end function
|
||||
|
||||
function GetDrmLicense(options as object) as dynamic
|
||||
function GetDrmLicense(options as object) as Innertube.DrmLicenseResponse
|
||||
request = Innertube.CreateGetDrmLicenceRequest(options)
|
||||
|
||||
response = request.Await()
|
||||
|
||||
Reference in new issue
Block a user