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

Commit de29177

Browse files
committed
Merge branch 'lcarvalho-master'
2 parents dd796e7 + bf877e8 commit de29177

4 files changed

Lines changed: 109 additions & 1 deletion

File tree

fixtures/media_shortcode.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"meta": {
3+
"code": 200
4+
},
5+
"data": {
6+
"attribution": null,
7+
"tags": [
8+
"alegria"
9+
],
10+
"type": "image",
11+
"location": null,
12+
"comments": {
13+
"count": 79623,
14+
"data": []
15+
},
16+
"filter": "Normal",
17+
"created_time": "1401623658",
18+
"link": "http://instagram.com/p/os1NQjxtvF/",
19+
"likes": {
20+
"count": 370660,
21+
"data": [
22+
{
23+
"username": "wakamario0904",
24+
"profile_picture": "http://images.ak.instagram.com/profiles/profile_395645793_75sq_1400392412.jpg",
25+
"id": "395645793",
26+
"full_name": "$☆<-W@ka M@rio->☆$"
27+
},
28+
{
29+
"username": "musaed_ms3",
30+
"profile_picture": "http://images.ak.instagram.com/profiles/profile_1353197338_75sq_1401757650.jpg",
31+
"id": "1353197338",
32+
"full_name": "Musaed"
33+
},
34+
{
35+
"username": "kerllancritiina_",
36+
"profile_picture": "http://images.ak.instagram.com/profiles/profile_405413316_75sq_1401764697.jpg",
37+
"id": "405413316",
38+
"full_name": "Kerllan Santos"
39+
},
40+
{
41+
"username": "marccelaaa",
42+
"profile_picture": "http://images.ak.instagram.com/profiles/profile_327540205_75sq_1401046535.jpg",
43+
"id": "327540205",
44+
"full_name": "Marcela Funes"
45+
}
46+
]
47+
},
48+
"images": {
49+
"low_resolution": {
50+
"url": "http://scontent-a.cdninstagram.com/hphotos-xpf1/t51.2885-15/10432037_1487631304805008_1552236767_a.jpg",
51+
"width": 306,
52+
"height": 306
53+
},
54+
"thumbnail": {
55+
"url": "http://scontent-a.cdninstagram.com/hphotos-xpf1/t51.2885-15/10432037_1487631304805008_1552236767_s.jpg",
56+
"width": 150,
57+
"height": 150
58+
},
59+
"standard_resolution": {
60+
"url": "http://scontent-a.cdninstagram.com/hphotos-xpf1/t51.2885-15/10432037_1487631304805008_1552236767_n.jpg",
61+
"width": 640,
62+
"height": 640
63+
}
64+
},
65+
"users_in_photo": [],
66+
"caption": {
67+
"created_time": "1401623658",
68+
"text": "Bom diaaaaa !! #alegria #Alegria",
69+
"from": {
70+
"username": "neymarjr",
71+
"profile_picture": "http://images.ak.instagram.com/profiles/profile_26669533_75sq_1396546465.jpg",
72+
"id": "26669533",
73+
"full_name": "Nj"
74+
},
75+
"id": "733194849033313209"
76+
},
77+
"user_has_liked": false,
78+
"id": "733194846952938437_26669533",
79+
"user": {
80+
"username": "neymarjr",
81+
"website": "",
82+
"profile_picture": "http://images.ak.instagram.com/profiles/profile_26669533_75sq_1396546465.jpg",
83+
"full_name": "Nj",
84+
"bio": "",
85+
"id": "26669533"
86+
}
87+
}
88+
}
89+

instagram/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import oauth2
22
from bind import bind_method
3-
from models import Media, User, Location, Tag, Comment, Relationship
3+
from models import MediaShortcode, Media, User, Location, Tag, Comment, Relationship
44

55
MEDIA_ACCEPT_PARAMETERS = ["count", "max_id"]
66
SEARCH_ACCEPT_PARAMETERS = ["q", "count"]
@@ -38,6 +38,13 @@ def __init__(self, *args, **kwargs):
3838
accepts_parameters=SEARCH_ACCEPT_PARAMETERS + ['lat', 'lng', 'min_timestamp', 'max_timestamp', 'distance'],
3939
root_class=Media)
4040

41+
media_shortcode = bind_method(
42+
path="/media/shortcode/{shortcode}",
43+
accepts_parameters=['shortcode'],
44+
response_type="entry",
45+
root_class=MediaShortcode)
46+
47+
4148
media_likes = bind_method(
4249
path="/media/{media_id}/likes",
4350
accepts_parameters=['media_id'],

instagram/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ def object_from_dictionary(cls, entry):
109109
return new_media
110110

111111

112+
class MediaShortcode(Media):
113+
114+
def __init__(self, shortcode=None, **kwargs):
115+
self.shortcode = shortcode
116+
for key, value in kwargs.iteritems():
117+
setattr(self, key, value)
118+
119+
112120
class Tag(ApiModel):
113121
def __init__(self, name, **kwargs):
114122
self.name = name

tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def test_media_search(self):
9999
self.client_only_api.media_search(lat=37.7,lng=-122.22)
100100
self.api.media_search(lat=37.7,lng=-122.22)
101101

102+
def test_media_shortcode(self):
103+
self.client_only_api.media_shortcode('os1NQjxtvF')
104+
self.api.media_shortcode('os1NQjxtvF')
105+
102106
def test_media_likes(self):
103107
self.client_only_api.media_likes(media_id=4)
104108

0 commit comments

Comments
 (0)