diff options
Diffstat (limited to 'youtube_dl/extractor/imgur.py')
| -rw-r--r-- | youtube_dl/extractor/imgur.py | 32 | 
1 files changed, 22 insertions, 10 deletions
diff --git a/youtube_dl/extractor/imgur.py b/youtube_dl/extractor/imgur.py index 70c8ca64e..88423f179 100644 --- a/youtube_dl/extractor/imgur.py +++ b/youtube_dl/extractor/imgur.py @@ -13,7 +13,7 @@ from ..utils import (  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 = [{          'url': 'https://i.imgur.com/A61SaA1.gifv', @@ -21,7 +21,7 @@ class ImgurIE(InfoExtractor):              'id': 'A61SaA1',              'ext': 'mp4',              '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', @@ -29,8 +29,17 @@ class ImgurIE(InfoExtractor):              'id': 'A61SaA1',              'ext': 'mp4',              '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): @@ -100,7 +109,7 @@ class ImgurIE(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 = {          'url': 'http://imgur.com/gallery/Q95ko', @@ -113,12 +122,15 @@ class ImgurAlbumIE(InfoExtractor):      def _real_extract(self, url):          album_id = self._match_id(url) -        album_images = self._download_json( -            'http://imgur.com/gallery/%s/album_images/hit.json?all=true' % album_id, -            album_id)['data']['images'] +        album_img_data = self._download_json( +            'http://imgur.com/gallery/%s/album_images/hit.json?all=true' % album_id, album_id)['data'] -        entries = [ -            self.url_result('http://imgur.com/%s' % image['hash']) -            for image in album_images if image.get('hash')] +        if len(album_img_data) == 0: +            return self.url_result('http://imgur.com/%s' % album_id) +        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)  | 
