mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 04:10:23 +00:00
Improve extraction (Closes #7918)
remove outer parentheses in if Conflicts: youtube_dl/extractor/imgur.py checked code with flake8 not returning list in case of single images. using the fact that id with length 5 are albums and more are single videos. Also for single videos ie ImgurIE both urls - http://imgur.com/gallery/oWeAMW2 and http://imgur.com/oWeAMW2 are equally fine. Change regex to allow thuis. For albums urls - http://imgur.com/gallery/Q95ko and http://imgur.com/Q95ko are ok. Change regex to allow this also. update description in ImgurIE Tests. Also move single video test 'https://imgur.com/gallery/YcAQlkx' from ImgurAlbumIE to ImgurIE.
This commit is contained in:
parent
31d9ea4a3e
commit
dbee18b552
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class ImgurIE(InfoExtractor):
|
class ImgurIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:i\.)?imgur\.com/(?!gallery)(?P<id>[a-zA-Z0-9]+)'
|
_VALID_URL = r'https?://(?:i\.)?imgur\.com/(gallery/)?(?P<id>[a-zA-Z0-9]{6,})'
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://i.imgur.com/A61SaA1.gifv',
|
'url': 'https://i.imgur.com/A61SaA1.gifv',
|
||||||
@ -21,7 +21,7 @@ class ImgurIE(InfoExtractor):
|
|||||||
'id': 'A61SaA1',
|
'id': 'A61SaA1',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 're:Imgur GIF$|MRW gifv is up and running without any bugs$',
|
'title': 're:Imgur GIF$|MRW gifv is up and running without any bugs$',
|
||||||
'description': 're:The origin of the Internet\'s most viral images$|The Internet\'s visual storytelling community\. Explore, share, and discuss the best visual stories the Internet has to offer\.$',
|
'description': 'Imgur: The most awesome images on the Internet.',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://imgur.com/A61SaA1',
|
'url': 'https://imgur.com/A61SaA1',
|
||||||
@ -29,8 +29,17 @@ class ImgurIE(InfoExtractor):
|
|||||||
'id': 'A61SaA1',
|
'id': 'A61SaA1',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 're:Imgur GIF$|MRW gifv is up and running without any bugs$',
|
'title': 're:Imgur GIF$|MRW gifv is up and running without any bugs$',
|
||||||
'description': 're:The origin of the Internet\'s most viral images$|The Internet\'s visual storytelling community\. Explore, share, and discuss the best visual stories the Internet has to offer\.$',
|
'description': 'Imgur: The most awesome images on the Internet.',
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://imgur.com/gallery/YcAQlkx',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'YcAQlkx',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Classic Steve Carell gif...cracks me up everytime....damn the repost downvotes....',
|
||||||
|
'description': 'Imgur: The most awesome images on the Internet.'
|
||||||
|
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
@ -100,7 +109,7 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
|
|
||||||
class ImgurAlbumIE(InfoExtractor):
|
class ImgurAlbumIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:i\.)?imgur\.com/gallery/(?P<id>[a-zA-Z0-9]+)'
|
_VALID_URL = r'https?://(?:i\.)?imgur\.com/(gallery/)?(?P<id>[a-zA-Z0-9]{5})(?![a-zA-Z0-9])'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://imgur.com/gallery/Q95ko',
|
'url': 'http://imgur.com/gallery/Q95ko',
|
||||||
@ -113,12 +122,15 @@ class ImgurAlbumIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
album_id = self._match_id(url)
|
album_id = self._match_id(url)
|
||||||
|
|
||||||
album_images = self._download_json(
|
album_img_data = self._download_json(
|
||||||
'http://imgur.com/gallery/%s/album_images/hit.json?all=true' % album_id,
|
'http://imgur.com/gallery/%s/album_images/hit.json?all=true' % album_id, album_id)['data']
|
||||||
album_id)['data']['images']
|
|
||||||
|
|
||||||
entries = [
|
if len(album_img_data) == 0:
|
||||||
self.url_result('http://imgur.com/%s' % image['hash'])
|
return self.url_result('http://imgur.com/%s' % album_id)
|
||||||
for image in album_images if image.get('hash')]
|
else:
|
||||||
|
album_images = album_img_data['images']
|
||||||
|
entries = [
|
||||||
|
self.url_result('http://imgur.com/%s' % image['hash'])
|
||||||
|
for image in album_images if image.get('hash')]
|
||||||
|
|
||||||
return self.playlist_result(entries, album_id)
|
return self.playlist_result(entries, album_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user