Repository: yt-dlp/yt-dlp

Issue:
ntv.ru: add support for file formats better than 360p
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I remove or skip any mandatory\* field

### Checklist

- [X] I'm requesting a site-specific feature
- [X] I've verified that I'm running yt-dlp version **2022.11.11** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've searched 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

Netherlands

### Example URLs

https://www.ntv.ru/peredacha/Kvartirnik/m63761/o712744/video/

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

Website's player provides different video qualities (144p, 360p, 720p, 1080p) but yt-dlp detects and downloads only one (360p). Please provide a way to download higher quality videos.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', '--list-formats', 'https://www.ntv.ru/peredacha/Kvartirnik/m63761/o712744/video/']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.11.11 [8b64402] (pip)
[debug] Python 3.10.9 (CPython x86_64 64bit) - Linux-5.15.80-gentoo-x86_64-AMD_Ryzen_9_5900X_12-Core_Processor-with-glibc2.36 (OpenSSL 1.1.1s  1 Nov 2022, glibc 2.36)
[debug] exe versions: ffmpeg 4.4.3 (setts), ffprobe 4.4.3, rtmpdump 2.4
[debug] Optional libraries: Crypto-3.15.0, brotli-1.0.9, certifi-3021.03.16, sqlite3-2.6.0
[debug] Proxy map: {}
[debug] Loaded 1723 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.11.11, Current version: 2022.11.11
yt-dlp is up to date (2022.11.11)
[debug] [ntv.ru] Extracting URL: https://www.ntv.ru/peredacha/Kvartirnik/m63761/o712744/video/
[ntv.ru] video: Downloading webpage
[ntv.ru] 2171782: Downloading video XML
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[info] Available formats for 2171782:
ID EXT RESOLUTION │   FILESIZE PROTO │ VCODEC  ACODEC
──────────────────────────────────────────────────────
0  mp4 unknown    │  917.38MiB https │ unknown unknown
```



Discussion:
```diff
diff --git a/yt_dlp/extractor/ntvru.py b/yt_dlp/extractor/ntvru.py
index 8d5877daa..00e35f9b3 100644
--- a/yt_dlp/extractor/ntvru.py
+++ b/yt_dlp/extractor/ntvru.py
@@ -115,6 +115,14 @@ def _real_extract(self, url):
                 'url': file_,
                 'filesize': int_or_none(xpath_text(video, './%ssize' % format_id)),
             })
+        hls_manifest = xpath_text(video, './playback/hls')
+        if hls_manifest:
+            formats.extend(self._extract_m3u8_formats(
+                hls_manifest, video_id, m3u8_id='hls', fatal=False))
+        dash_manifest = xpath_text(video, './playback/dash')
+        if dash_manifest:
+            formats.extend(self._extract_mpd_formats(
+                dash_manifest, video_id, mpd_id='dash', fatal=False))
 
         return {
             'id': xpath_text(video, './id'),
```
Cool! I can confirm patch is working (version 2022.11.11 contains extra `self._sort_formats(formats)` line before `return`, so I suppose this patch is for some other version, maybe current master):

```
$ yt-dlp --list-formats https://www.ntv.ru/peredacha/Kvartirnik/m63761/o712744/video/                                      
[ntv.ru] video: Downloading webpage
[ntv.ru] 2171782: Downloading video XML
[ntv.ru] 2171782: Downloading m3u8 information
[ntv.ru] 2171782: Downloading MPD manifest
[info] Available formats for 2171782:
ID                     EXT   RESOLUTION │   FILESIZE   TBR PROTO │ VCODEC        VBR ACODEC      ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
dash-thumbnails_160x90 mhtml unknown    │                  mhtml │ images                                DASH storyboards (jpeg)
hls-audio-RUSSIAN      m3u8  audio only │                  m3u8  │ audio only        unknown             [en] RUSSIAN
hls-audio-RUSSIAN_LOW  m3u8  audio only │                  m3u8  │ audio only        unknown             [en] RUSSIAN_LOW
dash-0                 m4a   audio only │ ~ 80.29MiB   67k https │ audio only        mp4a.40.5   67k 48k [en] DASH audio, m4a_dash
dash-1                 m4a   audio only │ ~157.21MiB  132k https │ audio only        mp4a.40.2  132k 48k [en] DASH audio, m4a_dash
5                      mp4   unknown    │  917.38MiB       https │ unknown           unknown
dash-2                 mp4   256x144    │ ~168.26MiB  141k https │ avc1.42c01e  141k video only          DASH video, mp4_dash
hls-251                mp4   256x144    │ ~300.03MiB  251k m3u8  │ avc1.42c01e  251k video only
dash-3                 mp4   640x360    │ ~812.30MiB  680k https │ avc1.4d481e  680k video only          DASH video, mp4_dash
hls-713                mp4   640x360    │ ~852.57MiB  714k m3u8  │ avc1.4d481e  714k video only
hls-2017               mp4   1280x720   │ ~  2.35GiB 2017k m3u8  │ avc1.4d481f 2017k video only
dash-4                 mp4   1280x720   │ ~  2.65GiB 2272k https │ avc1.4d481f 2272k video only          DASH video, mp4_dash
hls-3262               mp4   1920x1080  │ ~  3.81GiB 3263k m3u8  │ avc1.640828 3263k video only
dash-5                 mp4   1920x1080  │ ~  4.31GiB 3693k https │ avc1.640828 3693k video only          DASH video, mp4_dash
```

Not sure is this important, but while downloading I get a bit weird info:

```
yt-dlp https://www.ntv.ru/peredacha/Kvartirnik/m63761/o712744/video/ 
[ntv.ru] video: Downloading webpage
[ntv.ru] 2171782: Downloading video XML
[ntv.ru] 2171782: Downloading m3u8 information
[ntv.ru] 2171782: Downloading MPD manifest
[info] 2171782: Downloading 1 format(s): dash-5+dash-1
[download] Destination: «Новогодний квартирник НТВ у Маргулиса»： «Гараж желаний» [2171782].fdash-5.mp4
[download] 100% of    3.57GiB in 00:06:16 at 9.70MiB/s
[download] Destination: «Новогодний квартирник НТВ у Маргулиса»： «Гараж желаний» [2171782].fdash-1.m4a
[download] 100% of  151.32MiB in 00:00:17 at 8.59MiB/s
[Merger] Merging formats into "«Новогодний квартирник НТВ у Маргулиса»： «Гараж желаний» [2171782].mp4"
Deleting original file «Новогодний квартирник НТВ у Маргулиса»： «Гараж желаний» [2171782].fdash-1.m4a (pass -k to keep)
Deleting original file «Новогодний квартирник НТВ у Маргулиса»： «Гараж желаний» [2171782].fdash-5.mp4 (pass -k to keep)
```

Here you see chosen format "dash-5" plus "dash-1", but "dash-5" itself is 4.31GiB while download size is shown as 3.57GiB. Final size of downloaded file is 3993571546 bytes.
`self._sort_formats` was removed from the extractor in the current version (2023.01.02)

the tilde (`~`) indicates that the filesize is approximate, it is calculated from the duration and bitrate. actual filesize may differ

Resolving patch:
diff --git a/yt_dlp/extractor/ntvru.py b/yt_dlp/extractor/ntvru.py
--- a/yt_dlp/extractor/ntvru.py
+++ b/yt_dlp/extractor/ntvru.py
@@ -21,6 +21,7 @@ class NTVRuIE(InfoExtractor):
             'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 136,
+            'view_count': int,
         },
     }, {
         'url': 'http://www.ntv.ru/video/novosti/750370/',
@@ -32,6 +33,7 @@ class NTVRuIE(InfoExtractor):
             'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 172,
+            'view_count': int,
         },
     }, {
         'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416',
@@ -43,6 +45,7 @@ class NTVRuIE(InfoExtractor):
             'description': '«Сегодня». 21 марта 2014 года. 16:00',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 1496,
+            'view_count': int,
         },
     }, {
         'url': 'https://www.ntv.ru/kino/Koma_film/m70281/o336036/video/',
@@ -54,6 +57,7 @@ class NTVRuIE(InfoExtractor):
             'description': 'Остросюжетный фильм «Кома»',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 5592,
+            'view_count': int,
         },
     }, {
         'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/',
@@ -65,6 +69,7 @@ class NTVRuIE(InfoExtractor):
             'description': '«Дело врачей»: «Деревце жизни»',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 2590,
+            'view_count': int,
         },
     }, {
         # Schemeless file URL
@@ -115,6 +120,14 @@ def _real_extract(self, url):
                 'url': file_,
                 'filesize': int_or_none(xpath_text(video, './%ssize' % format_id)),
             })
+        hls_manifest = xpath_text(video, './playback/hls')
+        if hls_manifest:
+            formats.extend(self._extract_m3u8_formats(
+                hls_manifest, video_id, m3u8_id='hls', fatal=False))
+        dash_manifest = xpath_text(video, './playback/dash')
+        if dash_manifest:
+            formats.extend(self._extract_mpd_formats(
+                dash_manifest, video_id, mpd_id='dash', fatal=False))
 
         return {
             'id': xpath_text(video, './id'),


Test patch: