Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Fix data bug and media feed #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion instagram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs):
root_class=Media)

user_media_feed = bind_method(
path="/users/self/feed",
path="/users/self/media/feed",
accepts_parameters=MEDIA_ACCEPT_PARAMETERS,
root_class=Media,
paginates=True)
Expand Down
20 changes: 13 additions & 7 deletions instagram/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,33 @@ def object_from_dictionary(cls, entry):

new_media.comment_count = entry['comments']['count']
new_media.comments = []
for comment in entry['comments']['data']:
new_media.comments.append(Comment.object_from_dictionary(comment))
if "data" in entry["comments"]:
for comment in entry['comments']['data']:
new_media.comments.append(
Comment.object_from_dictionary(comment))

new_media.users_in_photo = []
if entry.get('users_in_photo'):
for user_in_photo in entry['users_in_photo']:
new_media.users_in_photo.append(UserInPhoto.object_from_dictionary(user_in_photo))
new_media.users_in_photo.append(
UserInPhoto.object_from_dictionary(user_in_photo))

new_media.created_time = timestamp_to_datetime(entry['created_time'])

if entry['location'] and 'id' in entry:
new_media.location = Location.object_from_dictionary(entry['location'])
new_media.location = Location.object_from_dictionary(
entry['location'])

new_media.caption = None
if entry['caption']:
new_media.caption = Comment.object_from_dictionary(entry['caption'])

new_media.caption = Comment.object_from_dictionary(
entry['caption'])

new_media.tags = []
if entry['tags']:
for tag in entry['tags']:
new_media.tags.append(Tag.object_from_dictionary({'name': tag}))
new_media.tags.append(
Tag.object_from_dictionary({'name': tag}))

new_media.link = entry['link']

Expand Down