aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-02-19 05:16:11 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-02-19 05:16:11 +0100
commitb74d50557757df97c1b2d7a776aa496e623a116c (patch)
treebfaf269e7a3fd6ec8c19f8f74248043ded90cbc4
parente880c66bd800e4769ffdff41fb9dc88cf3206c12 (diff)
parent9e2d7dca87a15cf455fa6c4843a0241ba0b7ad77 (diff)
downloadyoutube-dl-b74d50557757df97c1b2d7a776aa496e623a116c.tar.xz
Merge remote-tracking branch 'jbboehr/imgur-gifv-improvements'
-rw-r--r--youtube_dl/extractor/imgur.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/youtube_dl/extractor/imgur.py b/youtube_dl/extractor/imgur.py
index 16488e0c4..7937a5c81 100644
--- a/youtube_dl/extractor/imgur.py
+++ b/youtube_dl/extractor/imgur.py
@@ -5,13 +5,14 @@ import re
from .common import InfoExtractor
from ..utils import (
int_or_none,
+ str_or_none,
js_to_json,
mimetype2ext,
+ ExtractorError,
)
-
class ImgurIE(InfoExtractor):
- _VALID_URL = r'https?://i\.imgur\.com/(?P<id>[a-zA-Z0-9]+)\.(?:mp4|gifv)'
+ _VALID_URL = r'https?://(?:i\.)?imgur\.com/(?P<id>[a-zA-Z0-9]+)(?:\.mp4|\.gifv)?'
_TESTS = [{
'url': 'https://i.imgur.com/A61SaA1.gifv',
@@ -21,6 +22,14 @@ 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):
@@ -34,10 +43,13 @@ class ImgurIE(InfoExtractor):
r'<param name="height" value="([0-9]+)"',
webpage, 'height', fatal=False))
- formats = []
- video_elements = self._search_regex(
+ video_elements = str_or_none(self._search_regex(
r'(?s)<div class="video-elements">(.*?)</div>',
- 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'<source\s+src="(?P<src>[^"]+)"\s+type="(?P<type>[^"]+)"', video_elements):
formats.append({