Repository: yt-dlp
Issue: [Audible] An extractor error has occurred. (caused by KeyError('media'))
Labels: bug,triage

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

Unable to download a sample audio clip using a url to MPD file on audible.com with this error

`An extractor error has occurred. (caused by KeyError('media'))`

When I download the content of MPD the URL directly, I get following output.

```xml
<?xml version='1.0' encoding='utf-8'?>
<MPD minBufferTime='PT20S' type='static' mediaPresentationDuration='PT3M50.156S'
     profiles='urn:mpeg:dash:profile:isoff-main:2011'
     xmlns='urn:mpeg:dash:schema:mpd:2011'
     xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
     xsi:schemaLocation='urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd'>
    <Period id='0' duration='PT3M50.156S'>
        <AdaptationSet id='0' contentType='audio' lang='und' segmentAlignment='true' bitstreamSwitching='true'>
            <Representation id='0' mimeType='audio/mp4' codecs='mp4a.40.2' bandwidth='32768' audioSamplingRate='22050'>
                <AudioChannelConfiguration schemeIdUri='urn:mpeg:dash:23003:3:audio_channel_configuration:2011'
                                           value='1'/>
                <ContentProtection xmlns:cenc='urn:mpeg:cenc:2013'
                                   cenc:default_KID='f3886098-1aaa-54db-3353-31f77e16f9f9'
                                   schemeIdUri='urn:mpeg:dash:mp4protection:2011' value='cenc'/>
                <ContentProtection xmlns:cenc='urn:mpeg:cenc:2013'
                                   schemeIdUri='urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'>
                    <cenc:pssh>
                        AAAAhnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAGYSEPOIYJgaqlTbM1Mx934W+fkSECXQB/4NCU8DM6/PnzWmA+8aB0F1ZGlibGUiN2NpZDoNCjg0aGdtQnFxVk5zelV6SDNmaGI1K1E9PSxKZEFIL2cwSlR3TXpyOCtmTmFZRDd3PT0=
                    </cenc:pssh>
                </ContentProtection>
                <ContentProtection xmlns:cenc='urn:mpeg:cenc:2013'
                                   schemeIdUri='urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95'>
                    <cenc:pssh>
                        AAAARHBzc2gBAAAAmgTweZhAQoarkuZb4IhflQAAAALziGCYGqpU2zNTMfd+Fvn5JdAH/g0JTwMzr8+fNaYD7wAAAAA=
                    </cenc:pssh>
                </ContentProtection>
                <BaseURL>
                    ../../../../../4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQzNjAzNjcsImV4cCI6MTczNjU0MDc2MDM2NywicGF0aHMiOlsiL3BlX3BlcmlfMDAwMDQ1LzkyNTA1L2NlbmMvZzEvcGVfcGVyaV8wMDAwNDVfMjJfMzIubXA0Il0sInNyIjoxMDM5LCJlciI6MTAyMzE0NX0.RXFE7W9PQ-iFID__Y0Wr3vAv--8hVQSQIMxxZ4f3x_U/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22_32.mp4
                </BaseURL>
                <SegmentList timescale='22050' duration='430080'>
                    <Initialization
                            sourceURL='../../../../../4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQzNjAzNjcsImV4cCI6MTczNjU0MDc2MDM2NywicGF0aHMiOlsiL3BlX3BlcmlfMDAwMDQ1LzkyNTA1L2NlbmMvZzEvcGVfcGVyaV8wMDAwNDVfMjJfMzIubXA0Il0sInNyIjowLCJlciI6MTAzOH0.fyIZBDZ3EeKsckM4eNO4VjNStEpJruo3h9EXWTo05S4/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22_32.mp4'
                            range='0-1038'/>
                    <SegmentURL mediaRange='1039-87720'/>
                    <SegmentURL mediaRange='87721-174277'/>
                    <SegmentURL mediaRange='174278-261104'/>
                    <SegmentURL mediaRange='261105-347606'/>
                    <SegmentURL mediaRange='347607-434212'/>
                    <SegmentURL mediaRange='434213-520838'/>
                    <SegmentURL mediaRange='520839-607477'/>
                    <SegmentURL mediaRange='607478-694032'/>
                    <SegmentURL mediaRange='694033-780658'/>
                    <SegmentURL mediaRange='780659-867329'/>
                    <SegmentURL mediaRange='867330-953848'/>
                    <SegmentURL mediaRange='953849-1023144'/>
                </SegmentList>
            </Representation>
            <Representation id='1' mimeType='audio/mp4' codecs='mp4a.40.2' bandwidth='65536' audioSamplingRate='22050'>
                <AudioChannelConfiguration schemeIdUri='urn:mpeg:dash:23003:3:audio_channel_configuration:2011'
                                           value='2'/>
                <ContentProtection xmlns:cenc='urn:mpeg:cenc:2013'
                                   cenc:default_KID='25d007fe-0d09-4f03-33af-cf9f35a603ef'
                                   schemeIdUri='urn:mpeg:dash:mp4protection:2011' value='cenc'/>
                <ContentProtection xmlns:cenc='urn:mpeg:cenc:2013'
                                   schemeIdUri='urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'>
                    <cenc:pssh>
                        AAAAhnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAGYSEPOIYJgaqlTbM1Mx934W+fkSECXQB/4NCU8DM6/PnzWmA+8aB0F1ZGlibGUiN2NpZDoNCjg0aGdtQnFxVk5zelV6SDNmaGI1K1E9PSxKZEFIL2cwSlR3TXpyOCtmTmFZRDd3PT0=
                    </cenc:pssh>
                </ContentProtection>
                <ContentProtection xmlns:cenc='urn:mpeg:cenc:2013'
                                   schemeIdUri='urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95'>
                    <cenc:pssh>
                        AAAARHBzc2gBAAAAmgTweZhAQoarkuZb4IhflQAAAALziGCYGqpU2zNTMfd+Fvn5JdAH/g0JTwMzr8+fNaYD7wAAAAA=
                    </cenc:pssh>
                </ContentProtection>
                <BaseURL>
                    ../../../../../4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQzNjAzNjcsImV4cCI6MTczNjU0MDc2MDM2NywicGF0aHMiOlsiL3BlX3BlcmlfMDAwMDQ1LzkyNTA1L2NlbmMvZzEvcGVfcGVyaV8wMDAwNDVfMjJfNjQubXA0Il0sInNyIjoxMDM5LCJlciI6MTk0Mzc2OX0.WXJi4ZRlT_0MY-uSSMx5wG8sskI37AlZXRfHJ-gHBJI/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22_64.mp4
                </BaseURL>
                <SegmentList timescale='22050' duration='430080'>
                    <Initialization
                            sourceURL='../../../../../4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQzNjAzNjcsImV4cCI6MTczNjU0MDc2MDM2NywicGF0aHMiOlsiL3BlX3BlcmlfMDAwMDQ1LzkyNTA1L2NlbmMvZzEvcGVfcGVyaV8wMDAwNDVfMjJfNjQubXA0Il0sInNyIjowLCJlciI6MTAzOH0.s1Zl9uJGivBqyH7pwCIsKOy9TVD-xzobLVKe4fKVgfo/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22_64.mp4'
                            range='0-1038'/>
                    <SegmentURL mediaRange='1039-165678'/>
                    <SegmentURL mediaRange='165679-330315'/>
                    <SegmentURL mediaRange='330316-495266'/>
                    <SegmentURL mediaRange='495267-659808'/>
                    <SegmentURL mediaRange='659809-824256'/>
                    <SegmentURL mediaRange='824257-988928'/>
                    <SegmentURL mediaRange='988929-1153655'/>
                    <SegmentURL mediaRange='1153656-1318178'/>
                    <SegmentURL mediaRange='1318179-1482855'/>
                    <SegmentURL mediaRange='1482856-1647618'/>
                    <SegmentURL mediaRange='1647619-1812058'/>
                    <SegmentURL mediaRange='1812059-1943768'/>
                </SegmentList>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>
```

I extracted the MPD url from the webpage manually, by inspecting the developer tools from an audiobook sample url like this.

`https://www.audible.com/webplayer?asin=B00NWS13PI&isSample=true`

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
yt-dlp -vU  "https://d1jobzhhm62zby.cloudfront.net/4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQwNzUxMzksImV4cCI6MTczNjU0MDQ3NTEzOSwicGF0aHMiOlsiXlxcL3BlX3BlcmlfMDAwMDQ1XFwvOTI1MDVcXC9jZW5jXFwvZzFcXC9wZV9wZXJpXzAwMDA0NV8yMlxcLDMyXFwsNjRfdjhcXC5tYXN0ZXJcXC5tcGQkIl0sInFzIjp7InNzX3NlYyI6MjAsInN0YXJ0X3NlYyI6IjAiLCJlbmRfc2VjIjoiMjMwLjI0NiIsImlkIjoiNGNiODI4NTUtZjYyMC00ZGE2LWFhOTktODhkNTM3ZThlNDc5In0sImludHNpZyI6IlVGNXVwM3NmRHBXT3U2WHBpTTBaRUVKVDBFSXhQMzJpN3FZVFFxWktyN1EifQ.kSPhsdxYb_1ViwFpY8Arufk7oQWwsnSSImXWiwQCr1o/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22,32,64_v8.master.mpd?ss_sec=20&start_sec=0&end_sec=230.246&id=4cb82855-f620-4da6-aa99-88d537e8e479"
[debug] Command-line config: ['-vU', 'https://d1jobzhhm62zby.cloudfront.net/4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQwNzUxMzksImV4cCI6MTczNjU0MDQ3NTEzOSwicGF0aHMiOlsiXlxcL3BlX3BlcmlfMDAwMDQ1XFwvOTI1MDVcXC9jZW5jXFwvZzFcXC9wZV9wZXJpXzAwMDA0NV8yMlxcLDMyXFwsNjRfdjhcXC5tYXN0ZXJcXC5tcGQkIl0sInFzIjp7InNzX3NlYyI6MjAsInN0YXJ0X3NlYyI6IjAiLCJlbmRfc2VjIjoiMjMwLjI0NiIsImlkIjoiNGNiODI4NTUtZjYyMC00ZGE2LWFhOTktODhkNTM3ZThlNDc5In0sImludHNpZyI6IlVGNXVwM3NmRHBXT3U2WHBpTTBaRUVKVDBFSXhQMzJpN3FZVFFxWktyN1EifQ.kSPhsdxYb_1ViwFpY8Arufk7oQWwsnSSImXWiwQCr1o/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22,32,64_v8.master.mpd?ss_sec=20&start_sec=0&end_sec=230.246&id=4cb82855-f620-4da6-aa99-88d537e8e479']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.12.23 from yt-dlp/yt-dlp [65cf46cdd] (pip)
[debug] Python 3.12.4 (CPython x86_64 64bit) - Linux-6.8.0-51-generic-x86_64-with-glibc2.39 (OpenSSL 3.0.13 30 Jan 2024, glibc 2.39)
[debug] exe versions: ffmpeg N-116415-g2128c17739-20240725 (setts), ffprobe N-116415-g2128c17739-20240725
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.07.04, mutagen-1.47.0, requests-2.31.0, sqlite3-3.45.1, urllib3-2.2.2, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1837 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.12.23 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.12.23 from yt-dlp/yt-dlp)
[generic] Extracting URL: https://d1jobzhhm62zby.cloudfront.net/4cb82855-f620-4da6-aa99-88d537e8e479.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzc24iOiI0Y2I4Mjg1NS1mNjIwLTRkYTYtYWE5OS04OGQ1MzdlOGU0NzkiLCJuYmYiOjE3MzY0NTQwNzUxMzksImV4cCI6MTczNjU0MDQ3NTEzOSwicGF0aHMiOlsiXlxcL3BlX3BlcmlfMDAwMDQ1XFwvOTI1MDVcXC9jZW5jXFwvZzFcXC9wZV9wZXJpXzAwMDA0NV8yMlxcLDMyXFwsNjRfdjhcXC5tYXN0ZXJcXC5tcGQkIl0sInFzIjp7InNzX3NlYyI6MjAsInN0YXJ0X3NlYyI6IjAiLCJlbmRfc2VjIjoiMjMwLjI0NiIsImlkIjoiNGNiODI4NTUtZjYyMC00ZGE2LWFhOTktODhkNTM3ZThlNDc5In0sImludHNpZyI6IlVGNXVwM3NmRHBXT3U2WHBpTTBaRUVKVDBFSXhQMzJpN3FZVFFxWktyN1EifQ.kSPhsdxYb_1ViwFpY8Arufk7oQWwsnSSImXWiwQCr1o/pe_peri_000045/92505/cenc/g1/pe_peri_000045_22,32,64_v8.master.mpd?ss_sec=20&start_sec=0&end_sec=230.246&id=4cb82855-f620-4da6-aa99-88d537e8e479
[generic] pe_peri_000045_22,32,64_v8.master.mpd?ss_sec=20&start_sec=0&end_sec=230: Downloading webpage
WARNING: [generic] Falling back on generic information extractor
[generic] pe_peri_000045_22,32,64_v8.master.mpd?ss_sec=20&start_sec=0&end_sec=230: Extracting information
ERROR: An extractor error has occurred. (caused by KeyError('media')); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "/home/k/.pyenv/versions/3.12.4/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 742, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/k/.pyenv/versions/3.12.4/lib/python3.12/site-packages/yt_dlp/extractor/generic.py", line 2520, in _real_extract
    info_dict['formats'], info_dict['subtitles'] = self._parse_mpd_formats_and_subtitles(
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/k/.pyenv/versions/3.12.4/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2683, in _parse_mpd_formats_and_subtitles
    return self._merge_mpd_periods(periods)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/k/.pyenv/versions/3.12.4/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2691, in _merge_mpd_periods
    for period in periods:
  File "/home/k/.pyenv/versions/3.12.4/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2893, in _parse_mpd_periods
    representation_ms_info = extract_multisegment_info(representation, adaption_set_ms_info)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/k/.pyenv/versions/3.12.4/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2776, in extract_multisegment_info
    ms_info['segment_urls'] = [segment.attrib['media'] for segment in segment_urls_e]
                               ~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'media'
```
```