diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb9bc85..5c6a1321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - A few issues related to Playlet backend feeds and caching - An error when Invidious doesn't return valid video metadata - A bug where playlists with small number of videos has duplicates +- A bug where DASH manifest was not generated correctly for proxied Invidious videos ## [0.37.0] - 2025-05-16 diff --git a/playlet-lib/src/components/Services/Dash/DashManifest.bs b/playlet-lib/src/components/Services/Dash/DashManifest.bs index f1bbe984..0f7cb17c 100644 --- a/playlet-lib/src/components/Services/Dash/DashManifest.bs +++ b/playlet-lib/src/components/Services/Dash/DashManifest.bs @@ -12,7 +12,6 @@ class DashManifest m.invidiousInstance = invidiousInstance m.utils = new Http.Utils() - m.urlRegex = /https?:\/\/\S+(\/\S+)/i ' https://github.com/LuanRT/YouTube.js/blob/6082b4a52ee07a622735e6e9128a0531a5ae3bfb/src/utils/StreamingInfo.ts#L332-L349 m.colorInfo = { @@ -38,8 +37,11 @@ class DashManifest adaptiveFormats.Append(metadata.adaptiveFormats) if local + parsedInvidiousUrl = UrlUtils.ParseUrl(m.invidiousInstance) for i = 0 to adaptiveFormats.Count() - 1 - adaptiveFormats[i].url = m.urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1") + parsedUrl = UrlUtils.ParseUrl(adaptiveFormats[i].url) + parsedInvidiousUrl.path = UrlUtils.AppendQueryParams(parsedUrl.path, { host: parsedUrl.host }) + adaptiveFormats[i].url = UrlUtils.BuildUrlFromParts(parsedInvidiousUrl) end for end if diff --git a/playlet-lib/src/source/utils/UrlUtils.bs b/playlet-lib/src/source/utils/UrlUtils.bs index 85fb4d6c..f5633997 100644 --- a/playlet-lib/src/source/utils/UrlUtils.bs +++ b/playlet-lib/src/source/utils/UrlUtils.bs @@ -246,4 +246,28 @@ namespace UrlUtils } end function + function BuildUrlFromParts(parts as object) as string + url = "" + if not StringUtils.IsNullOrEmpty(parts.protocol) + url += parts.protocol + "://" + end if + + if not StringUtils.IsNullOrEmpty(parts.host) + url += parts.host + end if + + if (not StringUtils.IsNullOrEmpty(parts.port)) and ((parts.protocol = "http" and parts.port <> "80") or (parts.protocol = "https" and parts.port <> "443") or (parts.protocol <> "http" and parts.protocol <> "https")) + url += ":" + parts.port + end if + + if not StringUtils.IsNullOrEmpty(parts.path) + if not parts.path.StartsWith("/") + url += "/" + end if + url += parts.path + end if + + return url + end function + end namespace