diff --git a/lib/dash.js b/lib/dash.js index be6408a..ce6c3a2 100644 --- a/lib/dash.js +++ b/lib/dash.js @@ -236,6 +236,21 @@ const parseSegmentFromBase = async (segmentBase, baseUrl) => { return { url: baseUrl, range: mediaRange }; }; +const transformSegmentUrls = (segments) => { + for (const segment of segments) { + const hasHtmlEscapeCode = segment.url.includes('&'); + if (hasHtmlEscapeCode) { + const url = new URL(segment.url); + const entries = new URLSearchParams(url.searchParams.toString()).entries(); + for (const [key, value] of entries) { + url.searchParams.delete(key); + url.searchParams.append(key.replaceAll('amp;', ''), value); + } + segment.url = url.toString(); + } + } +}; + const protectionSchemas = { 'urn:mpeg:dash:mp4protection:2011': 'common', 'urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95': 'playready', @@ -298,6 +313,7 @@ const parseManifest = async (text, url, fallbackLanguage) => { } else { throw new Error('Could not find a way to get segments from this MPD manifest.'); } + transformSegmentUrls(segments); const label = get('label'); const fps = get('frameRate') ?? segmentBase?.attributes.timescale;