{"record":{"id":"3748e419eae66e49","repo":"subhra74/xdm","slug":"encrypted-manifest","errorCode":null,"errorMessage":"Encrypted manifest","messagePattern":"Encrypted manifest","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/XDM/XDM.Core/MediaParser/Dash/MpdParser.cs","lineNumber":37,"sourceCode":"            new Regex(@\"\\$(RepresentationID|Time|Time%0(?<time_digits>[\\d]+)(?<time_dx>[dx])?|Number|Number%0(?<num_digits>[\\d]+)(?<num_dx>[dx])?|Bandwidth)\\$\");\r\n        //@\"\\$(RepresentationID|Time|Time(%0([\\d]+)([dx])?)?|Number|Number(%0([\\d]+)([dx])?)?|Bandwidth)\\$\");\r\n        public static IList<IList<KeyValuePair<Representation?, Representation?>>> Parse(\r\n            string[] manifestLines,\r\n            string playlistUrl)\r\n        {\r\n            using var memstream = new MemoryStream(Encoding.UTF8.GetBytes(string.Join(\"\\n\", manifestLines)));\r\n            var xmldoc = new XmlDocument();\r\n            xmldoc.Load(new XmlTextReader(memstream)\r\n            {\r\n                Namespaces = false\r\n            });\r\n\r\n            if (xmldoc.DocumentElement?.Name != \"MPD\")\r\n                throw new Exception(\"Missing MPD start tag: \" + xmldoc.DocumentElement.Name);\r\n            if (xmldoc.DocumentElement.Attributes[\"type\"]?.Value == \"dynamic\")\r\n                throw new Exception(\"Manifest type dynamic is not supported\");\r\n            if (xmldoc.DocumentElement.SelectSingleNode(\"descendant::ContentProtection\") != null)\r\n                throw new Exception(\"Encrypted manifest\");\r\n\r\n            var mediaList = new List<IList<KeyValuePair<Representation?, Representation?>>>();\r\n\r\n            var mediaPresentationDuration =\r\n                DashUtil.ParseXsDuration(xmldoc.DocumentElement.Attributes[\"mediaPresentationDuration\"]?.Value ?? \"0\");\r\n            var baseUrl = new Uri(playlistUrl);\r\n            var baseUrlNodeRoot = xmldoc.DocumentElement.SelectSingleNode(\"child::BaseURL\");\r\n            if (baseUrlNodeRoot != null)\r\n            {\r\n                baseUrl = UrlResolver.Resolve(baseUrl, baseUrlNodeRoot.InnerText);\r\n            }\r\n\r\n            var periods = xmldoc.DocumentElement.SelectNodes(\"child::Period\");\r\n            if (periods == null || periods.Count < 1) throw new Exception(\"No period found!\");\r\n            if (periods.Count > 1)\r\n            {\r\n                var periodDurations = CalculatePeriodDurationsIfMissing(periods, mediaPresentationDuration);\r\n                for (var i = 0; i < periods.Count; i++)\r","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/subhra74/xdm/blob/1ca5a25aae007826c859c81bea494e7c102e1242/app/XDM/XDM.Core/MediaParser/Dash/MpdParser.cs#L19-L55","documentation":"Parse performs a SelectNodes/SelectSingleNode search for any ContentProtection element in the manifest. ContentProtection signals DRM (Widevine/PlayReady etc.) encryption, so its presence means the media cannot be downloaded as plaintext. The parser throws immediately to refuse DRM-protected content.","triggerScenarios":"Parsing an MPD manifest that contains <ContentProtection> elements under AdaptationSet/Representation — i.e. any DRM-protected (encrypted) DASH stream.","commonSituations":"Streaming platforms using Widevine/PlayReady DRM (Netflix-like services, paid VOD); manifests from services where the free tier is unencrypted but the premium tier is DRM-locked; test URLs from DRM SDK demos.","solutions":["Use a non-DRM source for the content; this library cannot and should not decrypt DRM streams.","Check for an unencrypted rendition of the same content (some services expose clear-key/free variants).","Catch this exception and surface a clear 'content is DRM protected' message instead of a generic failure.","If you own the content, remove ContentProtection from the test manifest or serve a clear variant for development."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var body = await http.GetStringAsync(manifestUrl);\nif (body.Contains(\"ContentProtection\"))\n    throw new Exception(\"Manifest is DRM-protected (ContentProtection present)\");","typeGuard":null,"tryCatchPattern":"try { return MpdParser.Parse(url, null); }\ncatch (Exception ex) when (ex.Message == \"Encrypted manifest\")\n{ throw new DrmProtectedException(\"Cannot download DRM-protected content\", ex); }","preventionTips":["Pre-check manifests for ContentProtection and refuse early","Surface a specific 'DRM protected' message instead of generic failure","Do not attempt to bypass DRM; find a clear source"],"tags":["dash","drm","encryption","manifest-parsing"],"backgroundTag":"incompatible-source-type","analyzedSha":"1ca5a25aae007826c859c81bea494e7c102e1242","analyzedAt":"2026-09-13T20:37:40.968Z","contentChangedAt":"2026-09-13T20:37:40.968Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}