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
1=== modified file 'friends/protocols/flickr.py'
2--- friends/protocols/flickr.py 2013-03-12 21:08:21 +0000
3+++ friends/protocols/flickr.py 2013-03-25 23:36:19 +0000
4@@ -44,8 +44,8 @@
5 # http://www.flickr.com/services/api/misc.buddyicons.html
6 FARM = 'http://farm{farm}.static.flickr.com/{server}/'
7 BUDDY_ICON_URL = FARM + 'buddyicons/{nsid}.jpg'
8-IMAGE_URL = FARM + '{nsid}_{secret}_{type}.jpg'
9-IMAGE_PAGE_URL = 'http://www.flickr.com/photos/{owner}/{nsid}'
10+IMAGE_URL = FARM + '{photo}_{secret}_{type}.jpg'
11+IMAGE_PAGE_URL = 'http://www.flickr.com/photos/{owner}/{photo}'
12 PEOPLE_URL = 'http://www.flickr.com/people/{owner}'
13
14
15@@ -121,6 +121,11 @@
16 # Pre-calculate some values to publish.
17 username = data.get('username', '')
18 ownername = data.get('ownername', '')
19+ photo_id = data.get('id')
20+
21+ if photo_id is None:
22+ # Can't do anything without this, really.
23+ continue
24
25 # Icons.
26 icon_farm = data.get('iconfarm')
27@@ -132,7 +137,7 @@
28 if None not in (icon_farm, icon_server, owner):
29 icon_uri = Avatar.get_image(BUDDY_ICON_URL.format(
30 farm=icon_farm, server=icon_server, nsid=owner))
31- url = PEOPLE_URL.format(owner=owner)
32+ url = IMAGE_PAGE_URL.format(owner=owner, photo=photo_id)
33
34 # Calculate the ISO 8601 UTC time string.
35 try:
36@@ -144,17 +149,20 @@
37 farm = data.get('farm')
38 server = data.get('server')
39 secret = data.get('secret')
40- img_url = ''
41- img_src = ''
42- img_thumb = ''
43+ img_src, img_thumb = '', ''
44 if None not in (farm, server, secret):
45- args = dict(farm=farm, server=server, nsid=owner, secret=secret)
46- img_url = IMAGE_URL.format(type='b', **args)
47+ args = dict(
48+ farm=farm,
49+ server=server,
50+ photo=photo_id,
51+ secret=secret,
52+ )
53 img_src = IMAGE_URL.format(type='m', **args)
54 img_thumb = IMAGE_URL.format(type='t', **args)
55
56 self._publish(
57- message_id=data.get('id', ''),
58+ message_id=photo_id,
59+ message=data.get('title', ''),
60 stream='images',
61 sender=ownername,
62 sender_id=owner,
63@@ -163,8 +171,7 @@
64 url=url,
65 from_me=from_me,
66 timestamp=timestamp,
67- link_caption=data.get('title', ''),
68- link_url=img_url,
69+ link_url=url,
70 link_picture=img_src,
71 link_icon=img_thumb,
72 latitude=data.get('latitude', 0.0),
73@@ -204,7 +211,7 @@
74 else:
75 destination_url = IMAGE_PAGE_URL.format(
76 owner=self._account.user_name,
77- nsid=post_id,
78+ photo=post_id,
79 )
80 self._publish(
81 from_me=True,
82
83=== modified file 'friends/tests/test_flickr.py'
84--- friends/tests/test_flickr.py 2013-03-20 23:57:40 +0000
85+++ friends/tests/test_flickr.py 2013-03-25 23:36:19 +0000
86@@ -169,18 +169,18 @@
87 'raise my voice',
88 True,
89 '2013-03-12T19:51:42Z',
90- '',
91+ 'Chocolate chai #yegcoffee',
92 GLib.get_user_cache_dir() +
93 '/friends/avatars/7b30ff0140dd9b80f2b1782a2802c3ce785fa0ce',
94- 'http://www.flickr.com/people/47303164@N00',
95+ 'http://www.flickr.com/photos/47303164@N00/8552892154',
96 0,
97 False,
98- 'http://farm9.static.flickr.com/8378/47303164@N00_a_m.jpg',
99- '',
100- 'http://farm9.static.flickr.com/8378/47303164@N00_a_b.jpg',
101- '',
102- 'Chocolate chai #yegcoffee',
103- 'http://farm9.static.flickr.com/8378/47303164@N00_a_t.jpg',
104+ 'http://farm9.static.flickr.com/8378/8552892154_a_m.jpg',
105+ '',
106+ 'http://www.flickr.com/photos/47303164@N00/8552892154',
107+ '',
108+ '',
109+ 'http://farm9.static.flickr.com/8378/8552892154_a_t.jpg',
110 '',
111 0.0,
112 0.0,
113@@ -197,18 +197,18 @@
114 'Nelson Webb',
115 True,
116 '2013-03-12T13:54:10Z',
117- '',
118+ 'St. Michael - The Archangel',
119 GLib.get_user_cache_dir() +
120 '/friends/avatars/cae2939354a33fea5f008df91bb8e25920be5dc3',
121- 'http://www.flickr.com/people/27204141@N05',
122+ 'http://www.flickr.com/photos/27204141@N05/8550829193',
123 0,
124 False,
125- 'http://farm9.static.flickr.com/8246/27204141@N05_e_m.jpg',
126- '',
127- 'http://farm9.static.flickr.com/8246/27204141@N05_e_b.jpg',
128- '',
129- 'St. Michael - The Archangel',
130- 'http://farm9.static.flickr.com/8246/27204141@N05_e_t.jpg',
131+ 'http://farm9.static.flickr.com/8246/8550829193_e_m.jpg',
132+ '',
133+ 'http://www.flickr.com/photos/27204141@N05/8550829193',
134+ '',
135+ '',
136+ 'http://farm9.static.flickr.com/8246/8550829193_e_t.jpg',
137 '',
138 53.833156,
139 -112.330784,

Subscribers

People subscribed via source and target branches