Skip to content

Commit

Permalink
Pagination fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Feb 27, 2017
1 parent cbcf67f commit 661eb0f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
- Fixes for app api:
* ``feed_timeline()``
* ``broadcast_like_count()``
* ``feed_location()``
* ``username_feed()``
* pagination fixes for ``feed_location()``, ``username_feed()``, ``saved_feed()``, ``location_related()``, ``tag_related()``, ``media_likers()``, ``feed_popular()``
* compat patch: ``media()``
- Update app client version to 10.9.0

## 1.0.9
- New endpoints for app client
Expand Down
35 changes: 26 additions & 9 deletions instagram_private_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,16 @@ def feed_timeline(self, **kwargs):
for m in res.get('feed_items', [])]
return res

def feed_popular(self):
def feed_popular(self, **kwargs):
"""Get popular feed"""
endpoint = 'feed/popular/?' + urlencode({
'people_teaser_supported': '1', 'rank_token': self.rank_token, 'ranked_content': 'true'})
query = {
'people_teaser_supported': '1',
'rank_token': self.rank_token,
'ranked_content': 'true'
}
if kwargs:
query.update(kwargs)
endpoint = 'feed/popular/?' + urlencode(query)
res = self._call_api(endpoint)
if self.auto_patch:
[ClientCompatPatch.media(m, drop_incompat_keys=self.drop_incompat_keys)
Expand Down Expand Up @@ -976,14 +982,17 @@ def delete_comment(self, media_id, comment_id):
res = self._call_api(endpoint, params=params)
return res

def media_likers(self, media_id):
def media_likers(self, media_id, **kwargs):
"""
Get users who have liked a post
:param media_id:
:return:
"""
res = self._call_api('media/%(media_id)s/likers/' % {'media_id': media_id})
endpoint = 'media/%(media_id)s/likers/' % {'media_id': media_id}
if kwargs:
endpoint += '?' + urlencode(kwargs)
res = self._call_api(endpoint)
if self.auto_patch:
[ClientCompatPatch.list_user(u, drop_incompat_keys=self.drop_incompat_keys)
for u in res.get('users', [])]
Expand Down Expand Up @@ -1434,14 +1443,16 @@ def bulk_translate(self, comment_ids):
res = self._call_api(endpoint)
return res

def feed_tag(self, tag):
def feed_tag(self, tag, **kwargs):
"""
Get tag feed
:param tag:
:return:
"""
endpoint = 'feed/tag/%(tag)s/' % {'tag': tag}
if kwargs:
endpoint += '?' + urlencode(kwargs)
res = self._call_api(endpoint)
if self.auto_patch:
if res.get('items'):
Expand All @@ -1463,7 +1474,7 @@ def tag_info(self, tag):
res = self._call_api(endpoint)
return res

def tag_related(self, tag):
def tag_related(self, tag, **kwargs):
"""
Get related tags
Expand All @@ -1474,6 +1485,8 @@ def tag_related(self, tag):
params = {
'visited': json.dumps([{'id': tag, 'type': 'hashtag'}], separators=(',', ':')),
'related_types': json.dumps(['hashtag'], separators=(',', ':'))}
if kwargs:
params.update(kwargs)
endpoint += '?' + urlencode(params)
res = self._call_api(endpoint)
return res
Expand Down Expand Up @@ -1575,7 +1588,7 @@ def location_info(self, location_id):
endpoint = 'locations/%(location_id)s/info/' % {'location_id': location_id}
return self._call_api(endpoint)

def location_related(self, location_id):
def location_related(self, location_id, **kwargs):
"""
Get related locations
Expand All @@ -1586,6 +1599,8 @@ def location_related(self, location_id):
params = {
'visited': json.dumps([{'id': location_id, 'type': 'location'}], separators=(',', ':')),
'related_types': json.dumps(['location'], separators=(',', ':'))}
if kwargs:
params.update(kwargs)
endpoint += '?' + urlencode(params)
return self._call_api(endpoint)

Expand Down Expand Up @@ -1863,13 +1878,15 @@ def unsave_photo(self, media_id):
params.update(self.authenticated_params)
return self._call_api(endpoint, params=params)

def saved_feed(self):
def saved_feed(self, **kwargs):
"""
Get saved photo feed
:return:
"""
endpoint = 'feed/saved/'
if kwargs:
endpoint += '?' + urlencode(kwargs)
res = self._call_api(endpoint)
if self.auto_patch:
[ClientCompatPatch.media(m['media'], drop_incompat_keys=self.drop_incompat_keys)
Expand Down

0 comments on commit 661eb0f

Please sign in to comment.