Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit 518ca9c

Browse files
committed
[fix] Instagram sometimes return type:videos with images object...
1 parent c944f95 commit 518ca9c

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed
8.66 KB
Binary file not shown.

instagram/models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from .helper import timestamp_to_datetime
22
import six
33

4-
54
class ApiModel(object):
65

76
@classmethod
@@ -78,13 +77,19 @@ def object_from_dictionary(cls, entry):
7877
new_media.user = User.object_from_dictionary(entry['user'])
7978

8079
new_media.images = {}
81-
for version, version_info in six.iteritems(entry['images']):
80+
for version, version_info in six.iteritems(entry.get('images')):
8281
new_media.images[version] = Image.object_from_dictionary(version_info)
8382

8483
if new_media.type == 'video':
8584
new_media.videos = {}
86-
for version, version_info in six.iteritems(entry['videos']):
87-
new_media.videos[version] = Video.object_from_dictionary(version_info)
85+
if entry.get('videos', False):
86+
for version, version_info in six.iteritems(entry['videos']):
87+
new_media.videos[version] = Video.object_from_dictionary(version_info)
88+
89+
## Sometimes images return with type: 'videos'
90+
elif entry.get('images', False):
91+
for version, version_info in six.iteritems(entry['images']):
92+
new_media.images[version] = Image.object_from_dictionary(version_info)
8893

8994
if 'user_has_liked' in entry:
9095
new_media.user_has_liked = entry['user_has_liked']

python_instagram_ext.egg-info/PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.0
22
Name: python-instagram-ext
3-
Version: 1.3.8
3+
Version: 1.3.9
44
Summary: Life extended Instagram API client
55
Home-page: https://github.com/Seraphicer/python-instagram-ext.git
66
Author: Seraphicer

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import setup, find_packages
33

44
setup(name="python-instagram-ext",
5-
version="1.3.8",
5+
version="1.3.9",
66
description="Life extended Instagram API client",
77
license="MIT",
88
install_requires=["simplejson", "httplib2", "six"],

0 commit comments

Comments
 (0)