How to use the ytcc.download.DownloadException function in ytcc

To help you get started, we’ve selected a few ytcc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mkly / youtube-closed-captions / test / functional / test_real_video.py View on Github external
def test_failed(self):
        video_id = '12323123123'
        with self.assertRaises(DownloadException):
            self.download.get_captions(video_id)
github alexkohler / ytgrep / test / functional / test_real_video.py View on Github external
def test_video_does_not_exist(self):
        self.download = Download(
            {'urls': ['12323123123'], 'pattern': 'elephants', 'e': False, 'v': False})
        with self.assertRaises(DownloadException):
            self.download.get_captions()
github mkly / youtube-closed-captions / ytcc / download.py View on Github external
def get_result(self, video_id: str, language: str = 'en') -> int:
        opts = self.opts
        if language:
            opts['subtitleslangs'] = [*opts.get('subtitleslangs', []), language]

        with youtube_dl.YoutubeDL(opts) as ydl:
            try:
                return ydl.download([self.get_url_from_video_id(video_id)])
            except youtube_dl.utils.DownloadError as err:
                raise DownloadException(
                    "Unable to download captions: {0}".format(str(err)))
            except youtube_dl.utils.ExtractorError as err:
                raise DownloadException(
                    "Unable to extract captions: {0}".format(str(err)))
            except Exception as err:
                raise DownloadException(
                    "Unknown exception downloading and extracting captions: {0}".format(
                        str(err)))
github mkly / youtube-closed-captions / ytcc / download.py View on Github external
def get_result(self, video_id: str, language: str = 'en') -> int:
        opts = self.opts
        if language:
            opts['subtitleslangs'] = [*opts.get('subtitleslangs', []), language]

        with youtube_dl.YoutubeDL(opts) as ydl:
            try:
                return ydl.download([self.get_url_from_video_id(video_id)])
            except youtube_dl.utils.DownloadError as err:
                raise DownloadException(
                    "Unable to download captions: {0}".format(str(err)))
            except youtube_dl.utils.ExtractorError as err:
                raise DownloadException(
                    "Unable to extract captions: {0}".format(str(err)))
            except Exception as err:
                raise DownloadException(
                    "Unknown exception downloading and extracting captions: {0}".format(
                        str(err)))
github alexkohler / ytgrep / ytcc / download.py View on Github external
def get_result(self, video_id: str) -> int:
        self.opts['outtmpl'] = 'subtitle_' + \
            hashlib.md5(str(video_id).encode('utf-8')).hexdigest()
        with youtube_dl.YoutubeDL(self.opts) as ydl:
            try:
                return ydl.download([video_id])  # J
            except youtube_dl.utils.DownloadError as err:
                raise DownloadException(
                    "Unable to download captions: {0}".format(str(err)))
            except youtube_dl.utils.ExtractorError as err:
                raise DownloadException(
                    "Unable to extract captions: {0}".format(str(err)))
            except Exception as err:
                raise DownloadException(
                    "Unknown exception downloading and extracting captions: {0}".format(
                        str(err)))
github alexkohler / ytgrep / ytcc / download.py View on Github external
def get_result(self, video_id: str) -> int:
        self.opts['outtmpl'] = 'subtitle_' + \
            hashlib.md5(str(video_id).encode('utf-8')).hexdigest()
        with youtube_dl.YoutubeDL(self.opts) as ydl:
            try:
                return ydl.download([video_id])  # J
            except youtube_dl.utils.DownloadError as err:
                raise DownloadException(
                    "Unable to download captions: {0}".format(str(err)))
            except youtube_dl.utils.ExtractorError as err:
                raise DownloadException(
                    "Unable to extract captions: {0}".format(str(err)))
            except Exception as err:
                raise DownloadException(
                    "Unknown exception downloading and extracting captions: {0}".format(
                        str(err)))