[instagram] Handling null values (fixes #5919)
[youtube-dl] / youtube_dl / extractor / instagram.py
index b107557880345157fcf66cb7e6e1b4a92b25af2e..b92367a9d7ba6f708a8780d645336fb8cda37418 100644 (file)
@@ -100,7 +100,9 @@ class InstagramUserIE(InfoExtractor):
                 thumbnails_el = it.get('images', {})
                 thumbnail = thumbnails_el.get('thumbnail', {}).get('url')
 
-                title = it.get('caption', {}).get('text', it['id'])
+                # In some cases caption is null, which corresponds to None
+                # in python. As a result, it.get('caption', {}) gives None
+                title = (it.get('caption') or {}).get('text', it['id'])
 
                 entries.append({
                     'id': it['id'],