Piped backend: absolute HLS URI rewrite, roLongInt-safe epoch conversion, /manifest endpoint
This commit is contained in:
1 parent
a30bf73d0f
commit
be8c79c3d1
4 files changed
+342
-148
No files matched your search
@@ -41,6 +41,12 @@ namespace Http
|
||||
|
||||
hlsManifest = hlsResponse.Text()
|
||||
|
||||
' Some backends (Piped) return master manifests with relative
|
||||
' variant URIs; since we serve the manifest from 127.0.0.1, the
|
||||
' player would resolve them against the local server and 404.
|
||||
' Make them absolute against the original manifest URL.
|
||||
hlsManifest = m.MakeRelativeUrisAbsolute(hlsManifest, url)
|
||||
|
||||
hlsManifest = m.PrependManifestHeader(hlsManifest, v, url)
|
||||
|
||||
qualityFilter = m.CreateQualityFilter(quality)
|
||||
@@ -253,6 +259,54 @@ ${storyboard.templateUrl.replace("$M", `${i}`)}
|
||||
return hlsManifest
|
||||
end function
|
||||
|
||||
function MakeRelativeUrisAbsolute(manifest as string, baseUrl as string) as string
|
||||
if manifest = invalid or manifest = "" or baseUrl = invalid or baseUrl = ""
|
||||
return manifest
|
||||
end if
|
||||
|
||||
parsedUrl = UrlUtils.ParseUrl(baseUrl)
|
||||
if parsedUrl = invalid or parsedUrl.host = invalid
|
||||
return manifest
|
||||
end if
|
||||
|
||||
protocol = parsedUrl.protocol
|
||||
if protocol = invalid or protocol = ""
|
||||
protocol = "https"
|
||||
end if
|
||||
origin = protocol + "://" + parsedUrl.host
|
||||
if parsedUrl.port <> invalid and parsedUrl.port <> "" and parsedUrl.port <> "80" and parsedUrl.port <> "443"
|
||||
origin = origin + ":" + parsedUrl.port
|
||||
end if
|
||||
|
||||
' normalize line endings (CR-only manifests would be one line)
|
||||
manifest = manifest.Replace(chr(13) + chr(10), chr(10))
|
||||
manifest = manifest.Replace(chr(13), chr(10))
|
||||
|
||||
lines = manifest.Split(chr(10))
|
||||
for i = 0 to lines.Count() - 1
|
||||
line = lines[i]
|
||||
trimmed = line.Trim()
|
||||
|
||||
if Left(trimmed, 1) = "/"
|
||||
' bare relative URI line (variant/media playlist)
|
||||
lines[i] = origin + trimmed
|
||||
else if Left(trimmed, 1) = "#" and InStr(UCase(trimmed), "URI=" + chr(34) + "/") > 0
|
||||
' attribute form: #EXT-X-MEDIA:...URI="/..." etc.
|
||||
' split on double quotes; rewrite any segment that starts
|
||||
' with a bare slash. no index math needed.
|
||||
parts = trimmed.Split(chr(34))
|
||||
for p = 0 to parts.Count() - 1
|
||||
if Left(parts[p], 1) = "/"
|
||||
parts[p] = origin + parts[p]
|
||||
end if
|
||||
end for
|
||||
lines[i] = parts.Join(chr(34))
|
||||
end if
|
||||
end for
|
||||
|
||||
return lines.Join(chr(10))
|
||||
end function
|
||||
|
||||
function GetPlayerMetadata() as object
|
||||
player = m.videoQueue.player
|
||||
|
||||
|
||||
Reference in new issue
Block a user