From 5a449a1b1d88166d78ee26458ba5e2c6f63fbe82 Mon Sep 17 00:00:00 2001 From: 3risian <59593325+3risian@users.noreply.github.com> Date: Tue, 7 Jan 2020 19:01:05 +1100 Subject: [PATCH] [PeerTube] Add subtitles --- youtube_dl/extractor/peertube.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/youtube_dl/extractor/peertube.py b/youtube_dl/extractor/peertube.py index c16db51fd..179fdef00 100644 --- a/youtube_dl/extractor/peertube.py +++ b/youtube_dl/extractor/peertube.py @@ -496,6 +496,9 @@ class PeerTubeIE(InfoExtractor): video_description = self._download_json( 'https://%s/api/v1/videos/%s/description' % (host, video_id), video_id) + video_captions = self._download_json( + 'https://%s/api/v1/videos/%s/captions' % (host, video_id), video_id) + title = video['name'] formats = [] @@ -517,6 +520,13 @@ class PeerTubeIE(InfoExtractor): formats.append(f) self._sort_formats(formats) + subtitles = {} + for entry in video_captions['data']: + caption_url = 'https://%s%s' % (host, entry['captionPath']) + subtitles[entry['language']['id']] = [{ + 'url': caption_url + }] + def account_data(field): return try_get(video, lambda x: x['account'][field], compat_str) @@ -550,4 +560,5 @@ class PeerTubeIE(InfoExtractor): 'tags': try_get(video, lambda x: x['tags'], list), 'categories': categories, 'formats': formats, + 'subtitles': subtitles }