From 580151faf0b748c0464355fe1a3274521886eeca Mon Sep 17 00:00:00 2001 From: woorst Date: Fri, 6 Oct 2017 19:28:19 -0500 Subject: [PATCH] handle single image imgur galleries --- rtv/mime_parsers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rtv/mime_parsers.py b/rtv/mime_parsers.py index e70515d..031c437 100644 --- a/rtv/mime_parsers.py +++ b/rtv/mime_parsers.py @@ -206,11 +206,14 @@ class ImgurApiMIMEParser(BaseMIMEParser): _logger.warning('Imgur API failure, resp %s', r.json()) return cls.fallback(url, domain) - if 'images' in data: + if 'images' in data and len(data['images']) > 1: # TODO: handle imgur albums with mixed content, i.e. jpeg and gifv link = ' '.join([d['link'] for d in data['images'] if not d['animated']]) mime = 'image/x-imgur-album' else: + data = data['images'][0] if 'images' in data else data + # this handles single image galleries + link = data['mp4'] if data['animated'] else data['link'] mime = 'video/mp4' if data['animated'] else data['type']