From 625a551f84f7a59a1abb4de1d1f50ea51b4e75f3 Mon Sep 17 00:00:00 2001 From: Breno Lipi Date: Thu, 11 Mar 2021 00:16:56 -0300 Subject: [PATCH] captiongenerator.com extractor --- youtube_dl/extractor/captiongenerator.py | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 youtube_dl/extractor/captiongenerator.py diff --git a/youtube_dl/extractor/captiongenerator.py b/youtube_dl/extractor/captiongenerator.py new file mode 100644 index 000000000..0d6ba0600 --- /dev/null +++ b/youtube_dl/extractor/captiongenerator.py @@ -0,0 +1,40 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class CaptionGeneratorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?captiongenerator\.com/(?P[0-9]+)' + _TEST = { + 'url': 'https://d34ov3vwfhhb30.cloudfront.net/Hitler+Reacts+-+No+Subtitles.mp4', + 'info_dict': { + 'id': '128', + 'ext': 'mp4', + 'title': 'Team building...', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + + video_url = self._html_search_regex(r'(https?://[a-z0-9]+\.cloudfront\.net/.+?\.mp4)', webpage, 'videoUrl') + print(video_url) + + vtt_page = self._download_webpage('https://www.captiongenerator.com/videos/%s.vtt' % video_id, video_id) + + vtt_captions = open("128.vtt", "w") + vtt_captions.write(vtt_page) + vtt_captions.close() + + title = self._html_search_regex(r'(.*)', webpage, 'videoTitle') + + return { + 'id': video_id, + 'title': title, + 'url': video_url, + 'description': self._og_search_description(webpage), + 'http_headers': {"Referer": "https://www.captiongenerator.com/"} + }