Skip to content

Commit

Permalink
[extractor/odnoklassniki] Extract subtitles (#5920)
Browse files Browse the repository at this point in the history
Closes #5744
Authored by: bashonly
  • Loading branch information
bashonly committed Jan 2, 2023
1 parent e756f45 commit b23b503
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions yt_dlp/extractor/odnoklassniki.py
Expand Up @@ -11,6 +11,7 @@
int_or_none,
qualities,
smuggle_url,
traverse_obj,
unescapeHTML,
unified_strdate,
unsmuggle_url,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -202,6 +223,7 @@ class OdnoklassnikiIE(InfoExtractor):
'like_count': 0,
'duration': 10444,
},
'skip': 'Site no longer embeds',
}]

@classmethod
Expand Down Expand Up @@ -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,
Expand All @@ -305,6 +337,7 @@ def _extract_desktop(self, url):
'like_count': like_count,
'age_limit': age_limit,
'start_time': start_time,
'subtitles': subtitles,
}

# pladform
Expand Down

0 comments on commit b23b503

Please sign in to comment.