Repository: yt-dlp/yt-dlp

Issue:
[drtv] audio formats listed with m3u8 extension
### 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 that yt-dlp is broken on a **supported** 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)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Denmark

### Provide a description that is worded well enough to be understood

The latest fix for drtv have introduced a new issue. Audio formats are listed with m3u8 extension instead of m4a.

This causes audio only downloads to be saved with m3u8 extension, and when downloading video+audio it merges to mkv instead of mp4.

### 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
[debug] Command-line config: ['-v', '--proxy', 'http://192.168.0.13:8888', '-F', 'https://www.dr.dk/drtv/episode/sportsmagasinet_415499']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version master@2023.11.15.232812 from yt-dlp/yt-dlp-master-builds [15cb3528c] (zip)
[debug] Python 3.9.18 (CPython amd64 64bit) - FreeBSD-13.2-RELEASE-p1-amd64-64bit-ELF (OpenSSL 1.1.1t-freebsd  7 Feb 2023, libc 7)
[debug] exe versions: ffmpeg 6.0 (setts), ffprobe 6.0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, requests-2.31.0, sqlite3-3.43.1, urllib3-2.1.0, websockets-10.4
[debug] Proxy map: {'all': 'http://192.168.0.13:8888'}
[debug] Request Handlers: urllib, requests
[debug] Extractor Plugins: TTUser (TikTokUserIE)
[debug] Plugin directories: ['/home/weird/.local/lib/python3.9/site-packages/yt_dlp_plugins']
[debug] Loaded 1901 extractors
[drtv] Downloading anonymous token
[drtv] Extracting URL: https://www.dr.dk/drtv/episode/sportsmagasinet_415499
[drtv] sportsmagasinet_415499: Downloading webpage
[drtv] 00602304440: Downloading stream data
[drtv] 00602304440: Downloading m3u8 information
[drtv] 00602304440: Downloading m3u8 information
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[info] Available formats for 00602304440:
ID                                             EXT  RESOLUTION FPS │   FILESIZE   TBR PROTO │ VCODEC        VBR ACODEC     MORE INFO
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
video_hls-SpokenSubtitles-audio_low-English    m3u8 audio only     │                  m3u8  │ audio only        unknown    [en] English
video_hls-SpokenSubtitles-audio_medium-English m3u8 audio only     │                  m3u8  │ audio only        unknown    [en] English
video_hls-AUDIO-English                        m3u8 audio only     │                  m3u8  │ audio only        unknown    [en] English
video_hls-AUDIO-English_2                      m3u8 audio only     │                  m3u8  │ audio only        unknown    [en] English_2
video_hls-SpokenSubtitles-628                  mp4  640x360     25 │ ~123.57MiB  628k m3u8  │ avc1.42C01E  628k video only
video_hls-SpokenSubtitles-1224                 mp4  852x480     25 │ ~240.72MiB 1224k m3u8  │ avc1.64001F 1224k video only
video_hls-SpokenSubtitles-2184                 mp4  960x540     25 │ ~429.52MiB 2184k m3u8  │ avc1.640028 2184k video only
video_hls-SpokenSubtitles-3674                 mp4  1280x720    25 │ ~722.68MiB 3675k m3u8  │ avc1.640029 3675k video only
video_hls-SpokenSubtitles-5658                 mp4  1280x720    25 │ ~  1.09GiB 5658k m3u8  │ avc1.640029 5658k video only
video_hls-691                                  mp4  640x360     25 │ ~135.90MiB  691k m3u8  │ avc1.42C01E  691k video only
video_hls-1285                                 mp4  852x480     25 │ ~252.81MiB 1286k m3u8  │ avc1.64001F 1286k video only
video_hls-2186                                 mp4  960x540     50 │ ~429.92MiB 2186k m3u8  │ avc1.640028 2186k video only
video_hls-3677                                 mp4  1280x720    50 │ ~723.15MiB 3677k m3u8  │ avc1.640029 3677k video only
video_hls-5665                                 mp4  1280x720    50 │ ~  1.09GiB 5666k m3u8  │ avc1.640029 5666k video only

[debug] Command-line config: ['-v', '--proxy', 'http://192.168.0.13:8888', 'https://www.dr.dk/drtv/episode/sportsmagasinet_415499']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version master@2023.11.15.232812 from yt-dlp/yt-dlp-master-builds [15cb3528c] (zip)
[debug] Python 3.9.18 (CPython amd64 64bit) - FreeBSD-13.2-RELEASE-p1-amd64-64bit-ELF (OpenSSL 1.1.1t-freebsd  7 Feb 2023, libc 7)
[debug] exe versions: ffmpeg 6.0 (setts), ffprobe 6.0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, requests-2.31.0, sqlite3-3.43.1, urllib3-2.1.0, websockets-10.4
[debug] Proxy map: {'all': 'http://192.168.0.13:8888'}
[debug] Request Handlers: urllib, requests
[debug] Extractor Plugins: TTUser (TikTokUserIE)
[debug] Plugin directories: ['/home/weird/.local/lib/python3.9/site-packages/yt_dlp_plugins']
[debug] Loaded 1901 extractors
[drtv] Downloading anonymous token
[drtv] Extracting URL: https://www.dr.dk/drtv/episode/sportsmagasinet_415499
[drtv] sportsmagasinet_415499: Downloading webpage
[drtv] 00602304440: Downloading stream data
[drtv] 00602304440: Downloading m3u8 information
[drtv] 00602304440: Downloading m3u8 information
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 00602304440: Downloading 1 format(s): video_hls-5665+video_hls-AUDIO-English_2
[debug] Invoking hlsnative downloader on "https://drod21i.akamaized.net/dk/clear/none/86/6535862191240928fc467786/00602304440/stream_fmp4/Sportsmagasinet_DRTV2022Jan_HDp50_16x9_VideoMain_video_5500.m3u8"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 162
[download] Destination: Sportsmagasinet [00602304440].fvideo_hls-5665.mp4
[download] 100% of    1.03GiB in 00:01:00 at 17.40MiB/s
[debug] Invoking hlsnative downloader on "https://drod21i.akamaized.net/dk/clear/none/86/6535862191240928fc467786/00602304440/stream_fmp4/Sportsmagasinet_DRTV2022Jan_HDp50_16x9_VideoMain_audio_128kbps.m3u8"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 162
[download] Destination: Sportsmagasinet [00602304440].fvideo_hls-AUDIO-English_2.m3u8
[download] 100% of   24.90MiB in 00:00:19 at 1.28MiB/s
[debug] ffmpeg command line: ffprobe -show_streams 'file:Sportsmagasinet [00602304440].fvideo_hls-AUDIO-English_2.m3u8'
[Merger] Merging formats into "Sportsmagasinet [00602304440].mkv"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Sportsmagasinet [00602304440].fvideo_hls-5665.mp4' -i 'file:Sportsmagasinet [00602304440].fvideo_hls-AUDIO-English_2.m3u8' -c copy -map 0:v:0 -map 1:a:0 -bsf:a:0 aac_adtstoasc -movflags +faststart 'file:Sportsmagasinet [00602304440].temp.mkv'
Deleting original file Sportsmagasinet [00602304440].fvideo_hls-5665.mp4 (pass -k to keep)
Deleting original file Sportsmagasinet [00602304440].fvideo_hls-AUDIO-English_2.m3u8 (pass -k to keep)
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/drtv.py b/yt_dlp/extractor/drtv.py
--- a/yt_dlp/extractor/drtv.py
+++ b/yt_dlp/extractor/drtv.py
@@ -209,7 +209,7 @@ def _real_extract(self, url):
             elif access_service == 'StandardVideo':
                 preference = 1
             fmts, subs = self._extract_m3u8_formats_and_subtitles(
-                stream.get('url'), video_id, preference=preference, m3u8_id=format_id, fatal=False)
+                stream.get('url'), video_id, ext='mp4', preference=preference, m3u8_id=format_id, fatal=False)
             formats.extend(fmts)
 
             api_subtitles = traverse_obj(stream, ('subtitles', lambda _, v: url_or_none(v['link']), {dict}))


Test patch: