summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/imgur.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/extractor/imgur.py')
-rw-r--r--yt_dlp/extractor/imgur.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/yt_dlp/extractor/imgur.py b/yt_dlp/extractor/imgur.py
index f32c116..f0c3419 100644
--- a/yt_dlp/extractor/imgur.py
+++ b/yt_dlp/extractor/imgur.py
@@ -228,21 +228,18 @@ class ImgurGalleryBaseIE(ImgurBaseIE):
if traverse_obj(data, 'is_album'):
- def yield_media_ids():
- for m_id in traverse_obj(data, (
- 'media', lambda _, v: v.get('type') == 'video' or v['metadata']['is_animated'],
- 'id', {lambda x: str_or_none(x) or None})):
- yield m_id
+ items = traverse_obj(data, (
+ 'media', lambda _, v: v.get('type') == 'video' or v['metadata']['is_animated'],
+ 'id', {lambda x: str_or_none(x) or None}))
# if a gallery with exactly one video, apply album metadata to video
- media_id = (
- self._GALLERY
- and traverse_obj(data, ('image_count', {lambda c: c == 1}))
- and next(yield_media_ids(), None))
+ media_id = None
+ if self._GALLERY and len(items) == 1:
+ media_id = items[0]
if not media_id:
result = self.playlist_result(
- map(self._imgur_result, yield_media_ids()), gallery_id)
+ map(self._imgur_result, items), gallery_id)
result.update(info)
return result
gallery_id = media_id
@@ -372,13 +369,13 @@ class ImgurAlbumIE(ImgurGalleryBaseIE):
'url': 'https://imgur.com/a/iX265HX',
'info_dict': {
'id': 'iX265HX',
- 'title': 'enen-no-shouboutai'
+ 'title': 'enen-no-shouboutai',
},
'playlist_count': 2,
}, {
'url': 'https://imgur.com/a/8pih2Ed',
'info_dict': {
- 'id': '8pih2Ed'
+ 'id': '8pih2Ed',
},
'playlist_mincount': 1,
}]