aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorJohn Boehr <jbboehr@gmail.com>2015-02-18 19:47:54 -0800
committerJohn Boehr <jbboehr@gmail.com>2015-02-18 19:47:54 -0800
commit9e2d7dca87a15cf455fa6c4843a0241ba0b7ad77 (patch)
tree734243d27b5e94499b1f0c5f381db03a269136b5 /youtube_dl
parentd236b37ac94cd36657c881e18b8d9187483afa80 (diff)
[imgur] improve error check for non-video URLs
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/imgur.py15
1 files 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'<source src="([^"]+)" type="([^"]+)"', webpage)
- if not sources:
- raise ExtractorError(
- 'No sources found for video %s' % video_id, expected=True)
-
width = int_or_none(self._search_regex(
r'<param name="width" value="([0-9]+)"',
webpage, 'width', fatal=False))
@@ -47,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({