{"record":{"id":"99539229eac076ed","repo":"agalwood/Motrix","slug":"unsupported-live","errorCode":"unsupported-live","errorMessage":"dynamic (live) MPD","messagePattern":"dynamic \\(live\\) MPD","errorType":"error_code","errorClass":"MediaParseError","httpStatus":null,"severity":"error","filePath":"src/core/media/dash-parser.ts","lineNumber":15,"sourceCode":"import {\n  type ByteRange,\n  type InitSegment,\n  MediaParseError,\n  type MediaPart,\n  resolveUri,\n  type SegmentPlan,\n} from './segment-plan'\n\nexport function parseDash(\n  xml: string,\n  mpdUrl: string\n): { video: SegmentPlan; audio?: SegmentPlan } {\n  if (/<MPD\\b[^>]*\\btype\\s*=\\s*\"dynamic\"/i.test(xml)) {\n    throw new MediaParseError('unsupported-live', 'dynamic (live) MPD')\n  }\n  if (/<ContentProtection\\b/i.test(xml)) {\n    throw new MediaParseError('unsupported-encryption', 'DRM-protected MPD')\n  }\n\n  const mpdBaseUrl = extractMpdBaseUrl(xml, mpdUrl)\n\n  const periodMatch = /<Period\\b([^>]*)>([\\s\\S]*?)<\\/Period>/i.exec(xml)\n  const periodAttrs = periodMatch?.[1] ?? ''\n  const periodBody = periodMatch?.[2] ?? xml\n\n  const mpdDuration = parseDuration(\n    attrVal(/<MPD\\b[^>]*>/i.exec(xml)?.[0] ?? '', 'mediaPresentationDuration')\n  )\n  const periodDuration =\n    parseDuration(attrVal(periodAttrs, 'duration')) ?? mpdDuration\n  const periodBaseUrl = resolveLevelBaseUrl(periodBody, mpdBaseUrl)\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/agalwood/Motrix/blob/1a708ee57746c434e2c67a44bbf0906a976afea4/src/core/media/dash-parser.ts#L1-L33","documentation":"MediaParseError with code 'unsupported-live', thrown by parseDash when the MPD root element carries type=\"dynamic\". The library only supports static (VOD) DASH manifests because it builds a fixed SegmentPlan; live windows require sliding playlists and segment-time updates it does not model.","triggerScenarios":"Calling parseDash(xml, mpdUrl) on a manifest whose <MPD> tag includes type=\"dynamic\" — i.e. any live or event DASH stream from a broadcaster CDN (Twitch, YouTube Live, DASH-IF reference live packs).","commonSituations":"User-supplied URL pointing at a live stream instead of VOD; CDN that serves the same path as dynamic for live events; testing against the DASH-IF live sample set instead of the VOD set.","solutions":["Point the fetcher at a static (type=\"static\") MPD or a VOD asset URL.","If you must handle live, integrate a dedicated live-DASH player (dash.js, Shaka) instead of this parser.","Detect the manifest type up front by regex-checking for type=\"dynamic\" and surface a clear user-facing message before calling parseDash.","Confirm the URL is the VOD variant — some CDNs expose ?format=vod or distinct /vod/ paths."],"exampleFix":"// before\nconst plan = parseDash(xml, mpdUrl)\n// after — pre-check and route live URLs elsewhere\nif (/type\\s*=\\s*\"dynamic\"/i.test(xml)) {\n  throw new UserFacingError('Live streams are not supported. Use a VOD URL.')\n}\nconst plan = parseDash(xml, mpdUrl)","handlingStrategy":"validation","validationCode":"function isStaticMpd(xml: string): boolean {\n  return !/<MPD\\b[^>]*\\btype\\s*=\\s*\"dynamic\"/i.test(xml)\n}\nif (!isStaticMpd(xml)) {\n  throw new Error('Live DASH (type=dynamic) is not supported; provide a static MPD URL.')\n}","typeGuard":"function isStaticMpd(xml: string): boolean {\n  return !/<MPD\\b[^>]*\\btype\\s*=\\s*\"dynamic\"/i.test(xml)\n}","tryCatchPattern":"try {\n  const plan = parseDash(xml, mpdUrl)\n} catch (e) {\n  if (e instanceof MediaParseError && e.code === 'unsupported-live') {\n    // inform user to provide a VOD URL\n  } else throw e\n}","preventionTips":["Detect manifest type before calling parseDash and route live URLs to a dedicated live player.","Maintain an allowlist of known VOD CDN hosts and validate against it.","Surface a clear user-facing message rather than letting the parse error propagate."],"tags":["dash","media","streaming","live"],"backgroundTag":null,"analyzedSha":"1a708ee57746c434e2c67a44bbf0906a976afea4","analyzedAt":"2026-08-12T16:18:09.346Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}