mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
Merge remote-tracking branch 'jbboehr/imgur-gifv-improvements'
This commit is contained in:
commit
b74d505577
1 changed files with 17 additions and 5 deletions
|
@ -5,13 +5,14 @@
|
||||||
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ImgurIE(InfoExtractor):
|
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 = [{
|
_TESTS = [{
|
||||||
'url': 'https://i.imgur.com/A61SaA1.gifv',
|
'url': 'https://i.imgur.com/A61SaA1.gifv',
|
||||||
|
@ -21,6 +22,14 @@ class ImgurIE(InfoExtractor):
|
||||||
'title': 'MRW gifv is up and running without any bugs',
|
'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.',
|
'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):
|
def _real_extract(self, url):
|
||||||
|
@ -34,10 +43,13 @@ def _real_extract(self, url):
|
||||||
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 a new issue