question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dash plugin: MPDParsingError: root tag did not match the expected tag: MPD

See original GitHub issue

Checklist

Streamlink version

Latest build from the master branch

Description

The following steps worked until yesterday:

  1. Connect to a channel livestream of Teleboy (teleboy.ch) or Zattoo (zattoo.com) with my web browser.
  2. Get the .mpd URL link of the livestream.
  3. Launch the command "streamlink “mpd-url-link best”.
  4. The livestream opens up in VLC.

Since today, the command fails.

Here is an example of the .mpd file content which streamlink fails to play: https://pastebin.com/jXD1NY1F

Debug log

streamlink "https://zh2-0-dash-live.zahs.tv/HD_orf1/m.mpd?z32=MF2WI2LPL5RW6ZDFMNZT2YLBMMTGG43JMQ6TCNSBII4DSMJSIZBTEMJVIQ2EKLJUGEZDORJSGVCDKOBTIE4ECOKEEZWWC6DSMF2GKPJVGAYDAJTNNFXHEYLUMU6TEMJQEZYHEZLGMVZHEZLEL5WGC3THOVQWOZJ5MZZCM43JM46TSX3FG4YDGMJXG5RGIMRVGNSTCMLBGI4GEMZRG5SDQN3DGRSGGYJXGETHK43FOJPWSZB5ORSWYZLCN54TUORYGM4DSMRXEZ3D2MA" best --loglevel debug
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.9.6
[cli][debug] Streamlink: 2.4.0
[cli][debug] Requests(2.26.0), Socks(1.7.1), Websocket(1.2.1)
[cli][debug] Arguments:
[cli][debug]  url=https://zh2-0-dash-live.zahs.tv/HD_orf1/m.mpd?z32=MF2WI2LPL5RW6ZDFMNZT2YLBMMTGG43JMQ6TCNSBII4DSMJSIZBTEMJVIQ2EKLJUGEZDORJSGVCDKOBTIE4ECOKEEZWWC6DSMF2GKPJVGAYDAJTNNFXHEYLUMU6TEMJQEZYHEZLGMVZHEZLEL5WGC3THOVQWOZJ5MZZCM43JM46TSX3FG4YDGMJXG5RGIMRVGNSTCMLBGI4GEMZRG5SDQN3DGRSGGYJXGETHK43FOJPWSZB5ORSWYZLCN54TUORYGM4DSMRXEZ3D2MA
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --rtmp-rtmpdump=rtmpdump.exe
[cli][debug]  --rtmpdump=C:\Program Files (x86)\Streamlink\rtmpdump\rtmpdump.exe
[cli][debug]  --ffmpeg-ffmpeg=C:\Program Files (x86)\Streamlink\ffmpeg\ffmpeg.exe
[cli][info] Found matching plugin dash for URL https://zh2-0-dash-live.zahs.tv/HD_orf1/m.mpd?z32=MF2WI2LPL5RW6ZDFMNZT2YLBMMTGG43JMQ6TCNSBII4DSMJSIZBTEMJVIQ2EKLJUGEZDORJSGVCDKOBTIE4ECOKEEZWWC6DSMF2GKPJVGAYDAJTNNFXHEYLUMU6TEMJQEZYHEZLGMVZHEZLEL5WGC3THOVQWOZJ5MZZCM43JM46TSX3FG4YDGMJXG5RGIMRVGNSTCMLBGI4GEMZRG5SDQN3DGRSGGYJXGETHK43FOJPWSZB5ORSWYZLCN54TUORYGM4DSMRXEZ3D2MA
[plugins.dash][debug] Parsing MPD URL: https://zh2-0-dash-live.zahs.tv/HD_orf1/m.mpd?z32=MF2WI2LPL5RW6ZDFMNZT2YLBMMTGG43JMQ6TCNSBII4DSMJSIZBTEMJVIQ2EKLJUGEZDORJSGVCDKOBTIE4ECOKEEZWWC6DSMF2GKPJVGAYDAJTNNFXHEYLUMU6TEMJQEZYHEZLGMVZHEZLEL5WGC3THOVQWOZJ5MZZCM43JM46TSX3FG4YDGMJXG5RGIMRVGNSTCMLBGI4GEMZRG5SDQN3DGRSGGYJXGETHK43FOJPWSZB5ORSWYZLCN54TUORYGM4DSMRXEZ3D2MA
Traceback (most recent call last):
  File "runpy.py", line 197, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "C:\Program Files (x86)\Streamlink\bin\streamlink.exe\__main__.py", line 18, in <module>
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 1082, in main
    handle_url()
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 576, in handle_url
    streams = fetch_streams(plugin)
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 470, in fetch_streams
    return plugin.streams(stream_types=args.stream_types,
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugin\plugin.py", line 335, in streams
    ostreams = self._get_streams()
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugins\dash.py", line 34, in _get_streams
    return DASHStream.parse_manifest(self.session, url)
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\stream\dash.py", line 185, in parse_manifest
    mpd = MPD(session.http.xml(res, ignore_ns=True), base_url=urlunparse(urlp), url=url)
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\stream\dash_manifest.py", line 224, in __init__
    super().__init__(node, root=self, *args, **kwargs)
  File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\stream\dash_manifest.py", line 146, in __init__
    raise MPDParsingError("root tag did not match the expected tag: {}".format(self.__tag__))
streamlink.stream.dash_manifest.MPDParsingError: root tag did not match the expected tag: MPD

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
bastimeyercommented, Oct 6, 2021

Looks like the issue is the regex for stripping off the default namespace attribute. It’s expecting a leading space or tab character, which is not the case in your input manifest, where it’s using a new-line character instead. The regex did not get changed though in the recent code refactorings, which means the issue was already present in earlier versions of Streamlink. https://github.com/streamlink/streamlink/blob/e38caa19a12363c60be1d73629543b810b6b9c99/src/streamlink/utils/parse.py#L79

That should fix it:

diff --git a/src/streamlink/utils/parse.py b/src/streamlink/utils/parse.py
index 8165a2c3..2a4de948 100644
--- a/src/streamlink/utils/parse.py
+++ b/src/streamlink/utils/parse.py
@@ -76,7 +76,7 @@ def parse_xml(
     if isinstance(data, str):
         data = bytes(data, "utf8")
     if ignore_ns:
-        data = re.sub(br"[\t ]xmlns=\"(.+?)\"", b"", data)
+        data = re.sub(br"\s+xmlns=\"(.+?)\"", b"", data)
     if invalid_char_entities:
         data = re.sub(br"&(?!(?:#(?:[0-9]+|[Xx][0-9A-Fa-f]+)|[A-Za-z0-9]+);)", b"&amp;", data)

Can you confirm this? It’s parsing the manifest correctly for me.

$ streamlink -l debug 'dash://file://./foo'
[cli][debug] OS:         Linux-5.14.8-1-git-x86_64-with-glibc2.33
[cli][debug] Python:     3.9.7
[cli][debug] Streamlink: 2.4.0+37.ge38caa1.dirty
[cli][debug] Requests(2.26.0), Socks(1.7.1), Websocket(0.58.0)
[cli][debug] Arguments:
[cli][debug]  url=dash://file://./foo
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv
[cli][info] Found matching plugin dash for URL dash://file://./foo
[plugins.dash][debug] Parsing MPD URL: file://./foo
[utils.l10n][debug] Language code: en_US
[stream.dash][debug] Available languages for DASH audio streams: mis, de (using: de)
Available streams: 224p (worst), 288p_alt, 288p, 432p, 720p_alt, 720p (best)
0reactions
Europe57commented, Oct 9, 2021

Thanks, I updated Python, it works. Sorry for the late reply, but I’m not fast in Linux

Read more comments on GitHub >

github_iconTop Results From Across the Web

segmentBase with stream=True - gists · GitHub
from streamlink import StreamError, PluginError ... if self.closed or not retries: ... raise MPDParsingError("root tag did not match the expected tag: ...
Read more >
how to resolve "did not match expected tag" exception
When I test these two ChannelInboundHandler whose names are ProtobufVarint32FrameDecoder and ProtobufDecoder ,there occurs one exception ...
Read more >
utils.parse_xml: allow a tab for ignore_ns · 6d6776cf8b - streamlink ...
MPDParsingError : root tag did not match the expected tag: MPD ``` --- `DeprecationWarning: Please use assertEqual instead.` --- Flake8 import errors
Read more >
Protocol message end-group tag did not match expected tag
InvalidProtocolBufferException : Protocol message end-group tag did not match expected tag. at io.netty.handler.codec.MessageToMessageDecoder.
Read more >
dash plugin: MPDParsingError: root tag did not match the expected ...
Connect to a channel livestream of Teleboy (teleboy.ch) or Zattoo (zattoo.com) with my web browser. Get the .mpd URL link of the livestream....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found