- 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, fatal=False)
-
- if album_images:
- data = album_images.get('data')
- if data and isinstance(data, dict):
- images = data.get('images')
- if images and isinstance(images, list):
- entries = [
- self.url_result('http://imgur.com/%s' % image['hash'])
- for image in images if image.get('hash')]
- return self.playlist_result(entries, album_id)
-
- # Fallback to single video
- return self.url_result('http://imgur.com/%s' % album_id, ImgurIE.ie_key())
+ gallery_id = self._match_id(url)
+
+ data = self._download_json(
+ 'https://imgur.com/gallery/%s.json' % gallery_id,
+ gallery_id)['data']['image']
+
+ if data.get('is_album'):
+ entries = [
+ self.url_result('http://imgur.com/%s' % image['hash'], ImgurIE.ie_key(), image['hash'])
+ for image in data['album_images']['images'] if image.get('hash')]
+ return self.playlist_result(entries, gallery_id, data.get('title'), data.get('description'))
+
+ return self.url_result('http://imgur.com/%s' % gallery_id, ImgurIE.ie_key(), gallery_id)
+
+
+class ImgurAlbumIE(ImgurGalleryIE):
+ IE_NAME = 'imgur:album'
+ _VALID_URL = r'https?://(?:i\.)?imgur\.com/a/(?P<id>[a-zA-Z0-9]+)'
+
+ _TESTS = [{
+ 'url': 'http://imgur.com/a/j6Orj',
+ 'info_dict': {
+ 'id': 'j6Orj',
+ 'title': 'A Literary Analysis of "Star Wars: The Force Awakens"',
+ },
+ 'playlist_count': 12,
+ }]