Merge lp:~robru/friends/fix-flickr-images into lp:friends

Proposed by Robert Bruce Park
Status: Merged
Approved by: Ken VanDine
Approved revision: 170
Merged at revision: 170
Proposed branch: lp:~robru/friends/fix-flickr-images
Merge into: lp:friends
Diff against target: 139 lines (+35/-28)
2 files modified
friends/protocols/flickr.py (+19/-12)
friends/tests/test_flickr.py (+16/-16)
To merge this branch: bzr merge lp:~robru/friends/fix-flickr-images
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ken VanDine Approve
Review via email: mp+155371@code.launchpad.net

Commit message

Correctly generate flickr photo URLs. (LP: #1159979)

Description of the change

Alright Ken, this definitely de-cripples Flickr, definitely important to get this in for raring otherwise our flickr users are gonna hate us ;-)

Tested on live data to make sure it works for real, and also updated tests to reflect what should really be going on. Having Gwibber run for real on live data sure makes it a lot more obvious what works and what doesn't! It's like I've been flying blind all this time...

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:170
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~robru/friends/fix-flickr-images/+merge/155371/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/friends-ci/11/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/friends-raring-amd64-ci/11

Click here to trigger a rebuild:
http://s-jenkins:8080/job/friends-ci/11/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Much better!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'friends/protocols/flickr.py'
--- friends/protocols/flickr.py 2013-03-12 21:08:21 +0000
+++ friends/protocols/flickr.py 2013-03-25 23:36:19 +0000
@@ -44,8 +44,8 @@
44# http://www.flickr.com/services/api/misc.buddyicons.html44# http://www.flickr.com/services/api/misc.buddyicons.html
45FARM = 'http://farm{farm}.static.flickr.com/{server}/'45FARM = 'http://farm{farm}.static.flickr.com/{server}/'
46BUDDY_ICON_URL = FARM + 'buddyicons/{nsid}.jpg'46BUDDY_ICON_URL = FARM + 'buddyicons/{nsid}.jpg'
47IMAGE_URL = FARM + '{nsid}_{secret}_{type}.jpg'47IMAGE_URL = FARM + '{photo}_{secret}_{type}.jpg'
48IMAGE_PAGE_URL = 'http://www.flickr.com/photos/{owner}/{nsid}'48IMAGE_PAGE_URL = 'http://www.flickr.com/photos/{owner}/{photo}'
49PEOPLE_URL = 'http://www.flickr.com/people/{owner}'49PEOPLE_URL = 'http://www.flickr.com/people/{owner}'
5050
5151
@@ -121,6 +121,11 @@
121 # Pre-calculate some values to publish.121 # Pre-calculate some values to publish.
122 username = data.get('username', '')122 username = data.get('username', '')
123 ownername = data.get('ownername', '')123 ownername = data.get('ownername', '')
124 photo_id = data.get('id')
125
126 if photo_id is None:
127 # Can't do anything without this, really.
128 continue
124129
125 # Icons.130 # Icons.
126 icon_farm = data.get('iconfarm')131 icon_farm = data.get('iconfarm')
@@ -132,7 +137,7 @@
132 if None not in (icon_farm, icon_server, owner):137 if None not in (icon_farm, icon_server, owner):
133 icon_uri = Avatar.get_image(BUDDY_ICON_URL.format(138 icon_uri = Avatar.get_image(BUDDY_ICON_URL.format(
134 farm=icon_farm, server=icon_server, nsid=owner))139 farm=icon_farm, server=icon_server, nsid=owner))
135 url = PEOPLE_URL.format(owner=owner)140 url = IMAGE_PAGE_URL.format(owner=owner, photo=photo_id)
136141
137 # Calculate the ISO 8601 UTC time string.142 # Calculate the ISO 8601 UTC time string.
138 try:143 try:
@@ -144,17 +149,20 @@
144 farm = data.get('farm')149 farm = data.get('farm')
145 server = data.get('server')150 server = data.get('server')
146 secret = data.get('secret')151 secret = data.get('secret')
147 img_url = ''152 img_src, img_thumb = '', ''
148 img_src = ''
149 img_thumb = ''
150 if None not in (farm, server, secret):153 if None not in (farm, server, secret):
151 args = dict(farm=farm, server=server, nsid=owner, secret=secret)154 args = dict(
152 img_url = IMAGE_URL.format(type='b', **args)155 farm=farm,
156 server=server,
157 photo=photo_id,
158 secret=secret,
159 )
153 img_src = IMAGE_URL.format(type='m', **args)160 img_src = IMAGE_URL.format(type='m', **args)
154 img_thumb = IMAGE_URL.format(type='t', **args)161 img_thumb = IMAGE_URL.format(type='t', **args)
155162
156 self._publish(163 self._publish(
157 message_id=data.get('id', ''),164 message_id=photo_id,
165 message=data.get('title', ''),
158 stream='images',166 stream='images',
159 sender=ownername,167 sender=ownername,
160 sender_id=owner,168 sender_id=owner,
@@ -163,8 +171,7 @@
163 url=url,171 url=url,
164 from_me=from_me,172 from_me=from_me,
165 timestamp=timestamp,173 timestamp=timestamp,
166 link_caption=data.get('title', ''),174 link_url=url,
167 link_url=img_url,
168 link_picture=img_src,175 link_picture=img_src,
169 link_icon=img_thumb,176 link_icon=img_thumb,
170 latitude=data.get('latitude', 0.0),177 latitude=data.get('latitude', 0.0),
@@ -204,7 +211,7 @@
204 else:211 else:
205 destination_url = IMAGE_PAGE_URL.format(212 destination_url = IMAGE_PAGE_URL.format(
206 owner=self._account.user_name,213 owner=self._account.user_name,
207 nsid=post_id,214 photo=post_id,
208 )215 )
209 self._publish(216 self._publish(
210 from_me=True,217 from_me=True,
211218
=== modified file 'friends/tests/test_flickr.py'
--- friends/tests/test_flickr.py 2013-03-20 23:57:40 +0000
+++ friends/tests/test_flickr.py 2013-03-25 23:36:19 +0000
@@ -169,18 +169,18 @@
169 'raise my voice',169 'raise my voice',
170 True,170 True,
171 '2013-03-12T19:51:42Z',171 '2013-03-12T19:51:42Z',
172 '',172 'Chocolate chai #yegcoffee',
173 GLib.get_user_cache_dir() +173 GLib.get_user_cache_dir() +
174 '/friends/avatars/7b30ff0140dd9b80f2b1782a2802c3ce785fa0ce',174 '/friends/avatars/7b30ff0140dd9b80f2b1782a2802c3ce785fa0ce',
175 'http://www.flickr.com/people/47303164@N00',175 'http://www.flickr.com/photos/47303164@N00/8552892154',
176 0,176 0,
177 False,177 False,
178 'http://farm9.static.flickr.com/8378/47303164@N00_a_m.jpg',178 'http://farm9.static.flickr.com/8378/8552892154_a_m.jpg',
179 '',179 '',
180 'http://farm9.static.flickr.com/8378/47303164@N00_a_b.jpg',180 'http://www.flickr.com/photos/47303164@N00/8552892154',
181 '',181 '',
182 'Chocolate chai #yegcoffee',182 '',
183 'http://farm9.static.flickr.com/8378/47303164@N00_a_t.jpg',183 'http://farm9.static.flickr.com/8378/8552892154_a_t.jpg',
184 '',184 '',
185 0.0,185 0.0,
186 0.0,186 0.0,
@@ -197,18 +197,18 @@
197 'Nelson Webb',197 'Nelson Webb',
198 True,198 True,
199 '2013-03-12T13:54:10Z',199 '2013-03-12T13:54:10Z',
200 '',200 'St. Michael - The Archangel',
201 GLib.get_user_cache_dir() +201 GLib.get_user_cache_dir() +
202 '/friends/avatars/cae2939354a33fea5f008df91bb8e25920be5dc3',202 '/friends/avatars/cae2939354a33fea5f008df91bb8e25920be5dc3',
203 'http://www.flickr.com/people/27204141@N05',203 'http://www.flickr.com/photos/27204141@N05/8550829193',
204 0,204 0,
205 False,205 False,
206 'http://farm9.static.flickr.com/8246/27204141@N05_e_m.jpg',206 'http://farm9.static.flickr.com/8246/8550829193_e_m.jpg',
207 '',207 '',
208 'http://farm9.static.flickr.com/8246/27204141@N05_e_b.jpg',208 'http://www.flickr.com/photos/27204141@N05/8550829193',
209 '',209 '',
210 'St. Michael - The Archangel',210 '',
211 'http://farm9.static.flickr.com/8246/27204141@N05_e_t.jpg',211 'http://farm9.static.flickr.com/8246/8550829193_e_t.jpg',
212 '',212 '',
213 53.833156,213 53.833156,
214 -112.330784,214 -112.330784,

Subscribers

People subscribed via source and target branches