Skip to content

Commit

Permalink
[tvplay] Add support for subtitles (Closes #10194)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Aug 5, 2016
1 parent 08c6559 commit f0d31c6
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions youtube_dl/extractor/tvplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import re

from .common import InfoExtractor
from ..compat import compat_str
from ..compat import (
compat_str,
compat_urlparse,
)
from ..utils import (
parse_iso8601,
qualities,
Expand Down Expand Up @@ -226,7 +229,8 @@ def _real_extract(self, url):
'ext': ext,
}
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:
continue
fmt.update({
Expand All @@ -242,6 +246,17 @@ def _real_extract(self, url):
formats.append(fmt)
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 {
'id': video_id,
'title': title,
Expand All @@ -251,4 +266,5 @@ def _real_extract(self, url):
'view_count': int_or_none(video.get('views', {}).get('total')),
'age_limit': int_or_none(video.get('age_limit', 0)),
'formats': formats,
'subtitles': subtitles,
}

0 comments on commit f0d31c6

Please sign in to comment.