Repository: yt-dlp/yt-dlp

Issue:
[ok.ru] Download subtitle
### 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)
- [ ] 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

_No response_

### Example URLs

https://ok.ru/video/4249587550747

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

Download subtitle from ok.ru

### 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: ['https://ok.ru/video/4249587550747', '--no-download', '--list-subs', '-vU']
[debug] User config "/home/nir/.config/yt-dlp/config": ['--no-overwrites', '--restrict-filenames', '--merge-output-format', 'mkv', '--paths', '~/Downloads/youtube_dl', '--output', '%(title)s_%(id)s_%(autonumber)d.%(ext)s']
[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 [8b644025b] (source)
[debug] Lazy loading extractors is disabled
[debug] Plugins: ['SamplePluginIE', 'SamplePluginPP']
[debug] Git HEAD: 935bac1e
[debug] Python 3.8.10 (CPython x86_64 64bit) - Linux-5.15.0-56-generic-x86_64-with-glibc2.29 (OpenSSL 1.1.1f  31 Mar 2020, glibc 2.31)
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7
[debug] Optional libraries: certifi-2019.11.28, secretstorage-2.3.1, sqlite3-2.6.0
[debug] Proxy map: {}
[debug] Loaded 1731 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)
[Odnoklassniki] Extracting URL: https://ok.ru/video/4249587550747
[Odnoklassniki] 4249587550747: Downloading desktop webpage
[Odnoklassniki] 4249587550747: Downloading m3u8 information
[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
4249587550747 has no subtitles
```



Discussion:
try with yt-dlp -o '%(title).20s' "https://vd265.mycdn.me/?expires=1670582591232&srcIp=76.8.147.101&srcAg=CHROME&ms=185.226.52.15&type=2&ix=0&sig=PtWWzXxbqFE&ct=13&urls=45.136.21.53&clientType=0&id=2782319872539"
This works:
```diff
diff --git a/yt_dlp/extractor/odnoklassniki.py b/yt_dlp/extractor/odnoklassniki.py
index 4f325f087..679535635 100644
--- a/yt_dlp/extractor/odnoklassniki.py
+++ b/yt_dlp/extractor/odnoklassniki.py
@@ -11,6 +11,7 @@
     int_or_none,
     qualities,
     smuggle_url,
+    traverse_obj,
     unescapeHTML,
     unified_strdate,
     unsmuggle_url,
@@ -294,6 +295,18 @@ def _extract_desktop(self, url):
 
         like_count = int_or_none(metadata.get('likeCount'))
 
+        subtitles = {}
+        for sub in traverse_obj(metadata, ('movie', 'subtitleTracks', ...), expected_type=dict):
+            sub_url = sub.get('url')
+            if not sub_url:
+                continue
+            if sub_url.startswith('//'):
+                sub_url = f'https:{sub_url}'
+            subtitles.setdefault(sub.get('language') or 'en', []).append({
+                'url': sub_url,
+                'ext': 'vtt',
+            })
+
         info = {
             'id': video_id,
             'title': title,
@@ -305,6 +318,7 @@ def _extract_desktop(self, url):
             'like_count': like_count,
             'age_limit': age_limit,
             'start_time': start_time,
+            'subtitles': subtitles,
         }
 
         # pladform
```

Resolving patch:
diff --git a/yt_dlp/extractor/odnoklassniki.py b/yt_dlp/extractor/odnoklassniki.py
--- a/yt_dlp/extractor/odnoklassniki.py
+++ b/yt_dlp/extractor/odnoklassniki.py
@@ -11,6 +11,7 @@
     int_or_none,
     qualities,
     smuggle_url,
+    traverse_obj,
     unescapeHTML,
     unified_strdate,
     unsmuggle_url,
@@ -153,6 +154,26 @@ class OdnoklassnikiIE(InfoExtractor):
             'title': 'Быковское крещение',
             'duration': 3038.181,
         },
+        'skip': 'HTTP Error 400',
+    }, {
+        'note': 'subtitles',
+        'url': 'https://ok.ru/video/4249587550747',
+        'info_dict': {
+            'id': '4249587550747',
+            'ext': 'mp4',
+            'title': 'Small Country An African Childhood (2020) (1080p) +subtitle',
+            'uploader': 'Sunflower Movies',
+            'uploader_id': '595802161179',
+            'upload_date': '20220816',
+            'duration': 6728,
+            'age_limit': 0,
+            'thumbnail': r're:^https?://i\.mycdn\.me/videoPreview\?.+',
+            'like_count': int,
+            'subtitles': dict,
+        },
+        'params': {
+            'skip_download': True,
+        },
     }, {
         'url': 'http://ok.ru/web-api/video/moviePlayer/20079905452',
         'only_matching': True,
@@ -202,6 +223,7 @@ class OdnoklassnikiIE(InfoExtractor):
             'like_count': 0,
             'duration': 10444,
         },
+        'skip': 'Site no longer embeds',
     }]
 
     @classmethod
@@ -294,6 +316,16 @@ def _extract_desktop(self, url):
 
         like_count = int_or_none(metadata.get('likeCount'))
 
+        subtitles = {}
+        for sub in traverse_obj(metadata, ('movie', 'subtitleTracks', ...), expected_type=dict):
+            sub_url = sub.get('url')
+            if not sub_url:
+                continue
+            subtitles.setdefault(sub.get('language') or 'en', []).append({
+                'url': sub_url,
+                'ext': 'vtt',
+            })
+
         info = {
             'id': video_id,
             'title': title,
@@ -305,6 +337,7 @@ def _extract_desktop(self, url):
             'like_count': like_count,
             'age_limit': age_limit,
             'start_time': start_time,
+            'subtitles': subtitles,
         }
 
         # pladform


Test patch: