Merge lp:~stefanor/ibid/twitter-breakage into lp:ibid

Proposed by Stefano Rivera on 2012-11-20
Status: Merged
Approved by: Stefano Rivera on 2012-11-20
Approved revision: 1055
Merged at revision: 1054
Proposed branch: lp:~stefanor/ibid/twitter-breakage
Merge into: lp:ibid
Diff against target: 38 lines (+12/-10)
1 file modified
ibid/plugins/social.py (+12/-10)
To merge this branch: bzr merge lp:~stefanor/ibid/twitter-breakage
Reviewer Review Type Date Requested Status
Jonathan Hitchcock 2012-11-20 Approve on 2012-11-20
Review via email: mp+135227@code.launchpad.net

Commit message

Make "latest tweet from PERSON" work again

Description of the change

Fixes: latest tweet from *twit*

To post a comment you must log in.
lp:~stefanor/ibid/twitter-breakage updated on 2012-11-20
1055. By Stefano Rivera on 2012-11-20

Log twitter error messages

Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/social.py'
2--- ibid/plugins/social.py 2012-06-01 14:35:40 +0000
3+++ ibid/plugins/social.py 2012-11-20 20:08:20 +0000
4@@ -74,22 +74,24 @@
5 def remote_latest(self, service, user):
6 if service['api'] == 'twitter':
7 # Twitter ommits retweets in the JSON and XML results:
8- statuses = generic_webservice('%sstatuses/user_timeline/%s.atom'
9- % (service['endpoint'], user.encode('utf-8')),
10- {'count': 1})
11+ statuses = generic_webservice('%sstatuses/user_timeline.rss'
12+ % service['endpoint'], {
13+ 'screen_name': user,
14+ 'count': 1
15+ })
16 tree = ElementTree.fromstring(statuses)
17- latest = tree.find('{http://www.w3.org/2005/Atom}entry')
18+ latest = tree.find('.//item')
19 if latest is None:
20+ if tree.find('.//error'):
21+ log.info('Twitter user_latest returned: %s',
22+ tree.findtext('.//error'))
23 raise self.NoTweetsException(user)
24 return {
25- 'text': latest.findtext('{http://www.w3.org/2005/Atom}content')
26+ 'text': latest.findtext('description')
27 .split(': ', 1)[1],
28 'ago': ago(datetime.utcnow() - parse_timestamp(
29- latest.findtext('{http://www.w3.org/2005/Atom}published'))),
30- 'url': [x for x
31- in latest.getiterator('{http://www.w3.org/2005/Atom}link')
32- if x.get('type') == 'text/html'
33- ][0].get('href'),
34+ latest.findtext('pubDate'))),
35+ 'url': latest.findtext('guid'),
36 }
37 elif service['api'] == 'laconica':
38 statuses = json_webservice('%sstatuses/user_timeline/%s.json'

Subscribers

People subscribed via source and target branches

to all changes: