mirror of
https://github.com/l1ving/youtube-dl
synced 2024-12-21 23:52:51 +08:00
[imgur] improve error check for non-video URLs
This commit is contained in:
parent
d236b37ac9
commit
9e2d7dca87
@ -5,6 +5,7 @@ import re
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
str_or_none,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
mimetype2ext,
|
mimetype2ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
@ -35,11 +36,6 @@ class ImgurIE(InfoExtractor):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
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(
|
width = int_or_none(self._search_regex(
|
||||||
r'<param name="width" value="([0-9]+)"',
|
r'<param name="width" value="([0-9]+)"',
|
||||||
webpage, 'width', fatal=False))
|
webpage, 'width', fatal=False))
|
||||||
@ -47,10 +43,13 @@ class ImgurIE(InfoExtractor):
|
|||||||
r'<param name="height" value="([0-9]+)"',
|
r'<param name="height" value="([0-9]+)"',
|
||||||
webpage, 'height', fatal=False))
|
webpage, 'height', fatal=False))
|
||||||
|
|
||||||
formats = []
|
video_elements = str_or_none(self._search_regex(
|
||||||
video_elements = self._search_regex(
|
|
||||||
r'(?s)<div class="video-elements">(.*?)</div>',
|
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 = []
|
formats = []
|
||||||
for m in re.finditer(r'<source\s+src="(?P<src>[^"]+)"\s+type="(?P<type>[^"]+)"', video_elements):
|
for m in re.finditer(r'<source\s+src="(?P<src>[^"]+)"\s+type="(?P<type>[^"]+)"', video_elements):
|
||||||
formats.append({
|
formats.append({
|
||||||
|
Loading…
Reference in New Issue
Block a user