From 9cdfe04f8b3f0da3dd46ad0610fd7c1f0300fec2 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Thu, 30 Jul 2009 00:17:24 -0500 Subject: [PATCH] Fixed status source parsing. Status.source -> source name Status.source_url -> url --- tweepy/parsers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tweepy/parsers.py b/tweepy/parsers.py index 71ec6df..e54b3c6 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -21,6 +21,14 @@ def _parse_search_datetime(str): return datetime.strptime(str, '%a, %d %b %Y %H:%M:%S +0000') +def _parse_html_value(html): + + return html[html.find('>')+1:html.rfind('<')] + +def _parse_a_href(atag): + + return atag[atag.find('"')+1:atag.find('>')-1] + def _parse_user(obj, api): user = api.classes['user']() @@ -54,6 +62,9 @@ def _parse_status(obj, api): setattr(status, k, _parse_user(v, api)) elif k == 'created_at': setattr(status, k, _parse_datetime(v)) + elif k == 'source': + setattr(status, k, _parse_html_value(v)) + setattr(status, 'source_url', _parse_a_href(v)) else: setattr(status, k, v) return status -- 2.25.1