0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-23 02:25:11 +00:00

[tvplay] Add support for subtitles (Closes #10194)

This commit is contained in:
Sergey M․ 2016-08-05 22:17:32 +07:00
parent 08c655906c
commit f0d31c624e
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -4,7 +4,10 @@
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import compat_str from ..compat import (
compat_str,
compat_urlparse,
)
from ..utils import ( from ..utils import (
parse_iso8601, parse_iso8601,
qualities, qualities,
@ -226,7 +229,8 @@ def _real_extract(self, url):
'ext': ext, 'ext': ext,
} }
if video_url.startswith('rtmp'): if video_url.startswith('rtmp'):
m = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url) m = re.search(
r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url)
if not m: if not m:
continue continue
fmt.update({ fmt.update({
@ -242,6 +246,17 @@ def _real_extract(self, url):
formats.append(fmt) formats.append(fmt)
self._sort_formats(formats) self._sort_formats(formats)
# TODO: webvtt in m3u8
subtitles = {}
sami_path = video.get('sami_path')
if sami_path:
lang = self._search_regex(
r'_([a-z]{2})\.xml', sami_path, 'lang',
default=compat_urlparse.urlparse(url).netloc.rsplit('.', 1)[-1])
subtitles[lang] = [{
'url': sami_path,
}]
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
@ -251,4 +266,5 @@ def _real_extract(self, url):
'view_count': int_or_none(video.get('views', {}).get('total')), 'view_count': int_or_none(video.get('views', {}).get('total')),
'age_limit': int_or_none(video.get('age_limit', 0)), 'age_limit': int_or_none(video.get('age_limit', 0)),
'formats': formats, 'formats': formats,
'subtitles': subtitles,
} }