diff options
author | Sergey M․ <dstftw@gmail.com> | 2017-11-15 22:14:54 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2017-11-15 22:14:54 +0700 |
commit | 9cbd4dda10ad248a5268ec1e0e563cf97024a8b9 (patch) | |
tree | 611ccc66319b46ad1db973783e0d746aa4895b2a /youtube_dl/extractor | |
parent | 08e45b39e76419f63aa43d5008257789d8a30bf8 (diff) |
[instagram] Fix description, timestamp and counters extraction (closes #14755)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/instagram.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/youtube_dl/extractor/instagram.py b/youtube_dl/extractor/instagram.py index 20db31f86..a77f619d2 100644 --- a/youtube_dl/extractor/instagram.py +++ b/youtube_dl/extractor/instagram.py @@ -130,13 +130,21 @@ class InstagramIE(InfoExtractor): video_url = media.get('video_url') height = int_or_none(media.get('dimensions', {}).get('height')) width = int_or_none(media.get('dimensions', {}).get('width')) - description = media.get('caption') + description = try_get( + media, lambda x: x['edge_media_to_caption']['edges'][0]['node']['text'], + compat_str) or media.get('caption') thumbnail = media.get('display_src') - timestamp = int_or_none(media.get('date')) + timestamp = int_or_none(media.get('taken_at_timestamp') or media.get('date')) uploader = media.get('owner', {}).get('full_name') uploader_id = media.get('owner', {}).get('username') - like_count = int_or_none(media.get('likes', {}).get('count')) - comment_count = int_or_none(media.get('comments', {}).get('count')) + + def get_count(key, kind): + return int_or_none(try_get( + media, (lambda x: x['edge_media_%s' % key]['count'], + lambda x: x['%ss' % kind]['count']))) + like_count = get_count('preview_like', 'like') + comment_count = get_count('to_comment', 'comment') + comments = [{ 'author': comment.get('user', {}).get('username'), 'author_id': comment.get('user', {}).get('id'), |