From 1a13940c8dada638f8298b6c1406f38d4a3bf270 Mon Sep 17 00:00:00 2001 From: John Boehr Date: Wed, 18 Feb 2015 18:12:48 -0800 Subject: [PATCH 1/3] [imgur] support regular URL --- youtube_dl/extractor/imgur.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/imgur.py b/youtube_dl/extractor/imgur.py index 16488e0c4..8449c45f4 100644 --- a/youtube_dl/extractor/imgur.py +++ b/youtube_dl/extractor/imgur.py @@ -7,11 +7,11 @@ from ..utils import ( int_or_none, js_to_json, mimetype2ext, + ExtractorError, ) - class ImgurIE(InfoExtractor): - _VALID_URL = r'https?://i\.imgur\.com/(?P[a-zA-Z0-9]+)\.(?:mp4|gifv)' + _VALID_URL = r'https?://(?:i\.)?imgur\.com/(?P[a-zA-Z0-9]+)(?:\.)?(?:mp4|gifv)?' _TESTS = [{ 'url': 'https://i.imgur.com/A61SaA1.gifv', @@ -21,12 +21,25 @@ class ImgurIE(InfoExtractor): 'title': 'MRW gifv is up and running without any bugs', 'description': 'The Internet\'s visual storytelling community. Explore, share, and discuss the best visual stories the Internet has to offer.', }, + }, { + 'url': 'https://imgur.com/A61SaA1', + 'info_dict': { + 'id': 'A61SaA1', + 'ext': 'mp4', + 'title': 'MRW gifv is up and running without any bugs', + 'description': 'The Internet\'s visual storytelling community. Explore, share, and discuss the best visual stories the Internet has to offer.', + }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) + sources = re.findall(r' Date: Wed, 18 Feb 2015 19:28:19 -0800 Subject: [PATCH 2/3] [imgur] improve regex #4998 --- youtube_dl/extractor/imgur.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/imgur.py b/youtube_dl/extractor/imgur.py index 8449c45f4..38c961773 100644 --- a/youtube_dl/extractor/imgur.py +++ b/youtube_dl/extractor/imgur.py @@ -11,7 +11,7 @@ from ..utils import ( ) class ImgurIE(InfoExtractor): - _VALID_URL = r'https?://(?:i\.)?imgur\.com/(?P[a-zA-Z0-9]+)(?:\.)?(?:mp4|gifv)?' + _VALID_URL = r'https?://(?:i\.)?imgur\.com/(?P[a-zA-Z0-9]+)(?:\.mp4|\.gifv)?' _TESTS = [{ 'url': 'https://i.imgur.com/A61SaA1.gifv', From 9e2d7dca87a15cf455fa6c4843a0241ba0b7ad77 Mon Sep 17 00:00:00 2001 From: John Boehr Date: Wed, 18 Feb 2015 19:47:54 -0800 Subject: [PATCH 3/3] [imgur] improve error check for non-video URLs --- youtube_dl/extractor/imgur.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/imgur.py b/youtube_dl/extractor/imgur.py index 38c961773..7937a5c81 100644 --- a/youtube_dl/extractor/imgur.py +++ b/youtube_dl/extractor/imgur.py @@ -5,6 +5,7 @@ import re from .common import InfoExtractor from ..utils import ( int_or_none, + str_or_none, js_to_json, mimetype2ext, ExtractorError, @@ -35,11 +36,6 @@ class ImgurIE(InfoExtractor): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - sources = re.findall(r'(.*?)', - webpage, 'video elements') + webpage, 'video elements', fatal=False)) + if not video_elements: + raise ExtractorError( + 'No sources found for video %s' % video_id, expected=True) + formats = [] for m in re.finditer(r'[^"]+)"\s+type="(?P[^"]+)"', video_elements): formats.append({