]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[instagram] Handling null values (fixes #5919)
authorYen Chi Hsuan <yan12125@gmail.com>
Sun, 7 Jun 2015 17:17:21 +0000 (01:17 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sun, 7 Jun 2015 17:17:21 +0000 (01:17 +0800)
I didn't add the test case here because it takes too much time. (7
minutes on my machine)

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'],