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

Commit d73c815

Browse files
author
Tomoyuki Kakuda
authored
Merge pull request #1 from devinstevenson/pr-from-original
Deprecations update
2 parents c1118d4 + 693e4f8 commit d73c815

3 files changed

Lines changed: 22 additions & 46 deletions

File tree

instagram/client.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .bind import bind_method
33
from .models import MediaShortcode, Media, User, Location, Tag, Comment, Relationship
44

5-
MEDIA_ACCEPT_PARAMETERS = ["count", "max_id"]
5+
MEDIA_ACCEPT_PARAMETERS = ["count"]
66
SEARCH_ACCEPT_PARAMETERS = ["q", "count"]
77

88
SUPPORTED_FORMATS = ['json']
@@ -17,7 +17,7 @@ class InstagramAPI(oauth2.OAuth2API):
1717
access_token_url = "https://api.instagram.com/oauth/access_token"
1818
protocol = "https"
1919
api_name = "Instagram"
20-
x_ratelimit_remaining = None
20+
x_ratelimit_remaining = None
2121
x_ratelimit = None
2222

2323
def __init__(self, *args, **kwargs):
@@ -28,11 +28,6 @@ def __init__(self, *args, **kwargs):
2828
raise Exception("Unsupported format")
2929
super(InstagramAPI, self).__init__(**kwargs)
3030

31-
media_popular = bind_method(
32-
path="/media/popular",
33-
accepts_parameters=MEDIA_ACCEPT_PARAMETERS,
34-
root_class=Media)
35-
3631
media_search = bind_method(
3732
path="/media/search",
3833
accepts_parameters=SEARCH_ACCEPT_PARAMETERS + ['lat', 'lng', 'min_timestamp', 'max_timestamp', 'distance'],
@@ -94,20 +89,21 @@ def __init__(self, *args, **kwargs):
9489
root_class=Media)
9590

9691
user_media_feed = bind_method(
97-
path="/users/self/feed",
98-
accepts_parameters=MEDIA_ACCEPT_PARAMETERS,
92+
path="/users/self/media/recent",
93+
accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ["min_id", "max_id"],
9994
root_class=Media,
10095
paginates=True)
10196

10297
user_liked_media = bind_method(
10398
path="/users/self/media/liked",
104-
accepts_parameters=MEDIA_ACCEPT_PARAMETERS,
99+
accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ["max_like_id"],
105100
root_class=Media,
106101
paginates=True)
107102

108103
user_recent_media = bind_method(
109104
path="/users/{user_id}/media/recent",
110-
accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ['user_id', 'min_id', 'max_timestamp', 'min_timestamp'],
105+
accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ['user_id', 'min_id',
106+
'max_id'],
111107
root_class=Media,
112108
paginates=True)
113109

@@ -117,14 +113,12 @@ def __init__(self, *args, **kwargs):
117113
root_class=User)
118114

119115
user_follows = bind_method(
120-
path="/users/{user_id}/follows",
121-
accepts_parameters=["user_id"],
116+
path="/users/self/follows",
122117
paginates=True,
123118
root_class=User)
124119

125120
user_followed_by = bind_method(
126-
path="/users/{user_id}/followed-by",
127-
accepts_parameters=["user_id"],
121+
path="/users/self/followed-by",
128122
paginates=True,
129123
root_class=User)
130124

@@ -142,7 +136,7 @@ def __init__(self, *args, **kwargs):
142136

143137
location_search = bind_method(
144138
path="/locations/search",
145-
accepts_parameters=SEARCH_ACCEPT_PARAMETERS + ['lat', 'lng', 'foursquare_id', 'foursquare_v2_id'],
139+
accepts_parameters=SEARCH_ACCEPT_PARAMETERS + ['lat', 'lng'],
146140
root_class=Location)
147141

148142
location = bind_method(
@@ -151,12 +145,6 @@ def __init__(self, *args, **kwargs):
151145
root_class=Location,
152146
response_type="entry")
153147

154-
geography_recent_media = bind_method(
155-
path="/geographies/{geography_id}/media/recent",
156-
accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ["geography_id"],
157-
root_class=Media,
158-
paginates=True)
159-
160148
tag_recent_media = bind_method(
161149
path="/tags/{tag_name}/media/recent",
162150
accepts_parameters=['count', 'max_tag_id', 'tag_name'],
@@ -216,9 +204,6 @@ def _make_subscription_action(method, include=None, exclude=None):
216204
"aspect",
217205
"object_id", # Optional if subscribing to all users
218206
"callback_url",
219-
"lat", # Geography
220-
"lng", # Geography
221-
"radius", # Geography
222207
"verify_token"]
223208

224209
if include:

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
from setuptools import setup, find_packages
33

44
setup(name="python-instagram-ext",
5-
version="1.3.4",
5+
version="1.3.5",
66
description="Life extended Instagram API client",
77
license="MIT",
8-
install_requires=["simplejson","httplib2","six"],
8+
install_requires=["simplejson", "httplib2", "six"],
99
author="Seraphicer",
1010
author_email="tomoyuki.kakuda@gmail.com",
1111
url="http://github.com/Seraphicer/python-instagram",
12-
packages = find_packages(),
13-
keywords= "instagram",
14-
zip_safe = True)
12+
packages=find_packages(),
13+
keywords="instagram",
14+
zip_safe=True)

tests.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, *args, **kwargs):
2424

2525
def request(self, url, method="GET", body=None, headers={}):
2626
fail_state = {
27-
'status':'400'
27+
'status': '400'
2828
}, "{}"
2929

3030
parsed = urlparse(url)
@@ -37,9 +37,9 @@ def request(self, url, method="GET", body=None, headers={}):
3737
'content-location':'http://example.com/redirect/login'
3838
}, None
3939

40-
if not 'access_token' in options and not 'client_id' in options:
40+
if 'access_token' not in options and 'client_id' not in options:
4141
fn_name += '_unauthorized'
42-
if 'self' in url and not 'access_token' in options:
42+
if 'self' in url and 'access_token' not in options:
4343
fn_name += '_no_auth_user'
4444

4545
fl = open('fixtures/%s.json' % fn_name)
@@ -83,7 +83,7 @@ def test_xauth_exchange(self):
8383
username = raw_input("Enter username for XAuth (blank to skip): ").strip()
8484
if not username:
8585
return
86-
password = getpass.getpass("Enter password for XAuth (blank to skip): ").strip()
86+
password = getpass.getpass("Enter password for XAuth (blank to skip): ").strip()
8787
access_token = self.unauthenticated_api.exchange_xauth_login_for_access_token(username, password)
8888
assert access_token
8989

@@ -94,12 +94,9 @@ def setUp(self):
9494
self.client_only_api = TestInstagramAPI(client_id=client_id)
9595
self.api = TestInstagramAPI(access_token=access_token)
9696

97-
def test_media_popular(self):
98-
self.api.media_popular(count=10)
99-
10097
def test_media_search(self):
101-
self.client_only_api.media_search(lat=37.7,lng=-122.22)
102-
self.api.media_search(lat=37.7,lng=-122.22)
98+
self.client_only_api.media_search(lat=37.7, lng=-122.22)
99+
self.api.media_search(lat=37.7, lng=-122.22)
103100

104101
def test_media_shortcode(self):
105102
self.client_only_api.media_shortcode('os1NQjxtvF')
@@ -144,7 +141,7 @@ def test_user_liked_media(self):
144141
def test_user_recent_media(self):
145142
media, url = self.api.user_recent_media(count=10)
146143

147-
self.assertTrue( all( [hasattr(obj, 'type') for obj in media] ) )
144+
self.assertTrue(all([hasattr(obj, 'type') for obj in media]))
148145

149146
image = media[0]
150147
self.assertEqual(
@@ -178,10 +175,6 @@ def test_user_recent_media(self):
178175
video.get_thumbnail_url(),
179176
"http://distilleryimage2.ak.instagram.com/11f75f1cd9cc11e2a0fd22000aa8039a_5.jpg")
180177

181-
182-
183-
184-
185178
def test_user_search(self):
186179
self.api.user_search('mikeyk', 10)
187180

@@ -243,8 +236,6 @@ def test_change_relationship(self):
243236
self.api.follow_user(user_id='10')
244237
self.api.unfollow_user(user_id='10')
245238

246-
def test_geography_recent_media(self):
247-
self.api.geography_recent_media(geography_id=1)
248239

249240
if __name__ == '__main__':
250241
if not TEST_AUTH:

0 commit comments

Comments
 (0)