From 632256d9ecd86f17b370b2cbe3f50acdf961d6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Tue, 28 Oct 2014 20:35:02 +0700 Subject: [PATCH 1/3] [wimp] Update video URL regex --- youtube_dl/extractor/wimp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/wimp.py b/youtube_dl/extractor/wimp.py index c27dda944..3377a543e 100644 --- a/youtube_dl/extractor/wimp.py +++ b/youtube_dl/extractor/wimp.py @@ -37,7 +37,7 @@ def _real_extract(self, url): video_id = mobj.group(1) webpage = self._download_webpage(url, video_id) video_url = self._search_regex( - r's1\.addVariable\("file",\s*"([^"]+)"\);', webpage, 'video URL') + r"'file'\s*:\s*'([^']+)'", webpage, 'video URL') if YoutubeIE.suitable(video_url): self.to_screen('Found YouTube video') return { From 9334f8f17a0e6a2b97d4e20b12a9ede52e4c0b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Tue, 28 Oct 2014 21:06:07 +0700 Subject: [PATCH 2/3] [vk] Handle deleted videos --- youtube_dl/extractor/vk.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/extractor/vk.py b/youtube_dl/extractor/vk.py index 918bd1098..837c3167e 100644 --- a/youtube_dl/extractor/vk.py +++ b/youtube_dl/extractor/vk.py @@ -142,6 +142,10 @@ def _real_extract(self, url): raise ExtractorError('This video is only available for registered users, ' 'use --username and --password options to provide account credentials.', expected=True) + if 'Unknown error' in info_page: + raise ExtractorError( + 'Video %s does not exist' % video_id, expected=True) + m_yt = re.search(r'src="(http://www.youtube.com/.*?)"', info_page) if m_yt is not None: self.to_screen('Youtube video detected') From e0c51cdadc838a67870f5c22c48bb0b9f1951afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Tue, 28 Oct 2014 21:35:25 +0700 Subject: [PATCH 3/3] [vk] Generalize errors --- youtube_dl/extractor/vk.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/vk.py b/youtube_dl/extractor/vk.py index 837c3167e..36cd7e52e 100644 --- a/youtube_dl/extractor/vk.py +++ b/youtube_dl/extractor/vk.py @@ -138,13 +138,19 @@ def _real_extract(self, url): info_url = 'http://vk.com/al_video.php?act=show&al=1&video=%s' % video_id info_page = self._download_webpage(info_url, video_id) - if re.search(r'Please log in or <', info_page): - raise ExtractorError('This video is only available for registered users, ' - 'use --username and --password options to provide account credentials.', expected=True) + ERRORS = { + r'>Видеозапись .*? была изъята из публичного доступа в связи с обращением правообладателя.<': + 'Video %s has been removed from public access due to rightholder complaint.', + r'Please log in or <': + 'Video %s is only available for registered users, ' + 'use --username and --password options to provide account credentials.', + 'Unknown error': + 'Video %s does not exist.' + } - if 'Unknown error' in info_page: - raise ExtractorError( - 'Video %s does not exist' % video_id, expected=True) + for error_re, error_msg in ERRORS.items(): + if re.search(error_re, info_page): + raise ExtractorError(error_msg % video_id, expected=True) m_yt = re.search(r'src="(http://www.youtube.com/.*?)"', info_page) if m_yt is not None: