#NEWLINE# def timeline_result( self , tweets ) : #NEWLINE# #INDENT# for tweet in tweets : #NEWLINE# #INDENT# exists = self . models . content_remote . get ( to_username = self . user . username , type = 'twitter' , post_id = str ( tweet [ 'id' ] ) ) [ 0 ] #NEWLINE# if exists : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_tweet = self . models . content_remote ( ) #NEWLINE# #UNINDENT# new_tweet . to_username = self . user . username #NEWLINE# new_tweet . username = tweet [ 'user' ] [ 'screen_name' ] #NEWLINE# new_tweet . from_user = ( 'http://twitter.com/' + tweet [ 'user' ] [ 'screen_name' ] ) #NEWLINE# new_tweet . avatar = tweet [ 'user' ] [ 'profile_image_url' ] #NEWLINE# parsed_date = re . compile ( '\\+.....' ) . sub ( '' , tweet [ 'created_at' ] ) #NEWLINE# parsed_date = datetime . datetime . strptime ( parsed_date , '%a %b %d %H:%M:%S %Y' ) #NEWLINE# if ( parsed_date < ( datetime . datetime . utcnow ( ) - datetime . timedelta ( days = self . constants [ 'feed_max_days_old' ] ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# new_tweet . date_created = parsed_date #NEWLINE# new_tweet . date_updated = None #NEWLINE# new_tweet . comments_count = 0 #NEWLINE# new_tweet . comments_updated = None #NEWLINE# new_tweet . type = 'twitter' #NEWLINE# new_tweet . title = '' #NEWLINE# new_tweet . post_id = str ( tweet [ 'id' ] ) #NEWLINE# new_tweet . link = ( ( ( 'http://twitter.com/' + tweet [ 'user' ] [ 'screen_name' ] ) + '/status/' ) + str ( tweet [ 'id' ] ) ) #NEWLINE# if tweet . has_key ( 'retweeted_status' ) : #NEWLINE# #INDENT# text = tornado . escape . linkify ( tweet [ 'retweeted_status' ] [ 'text' ] ) #NEWLINE# text += ( ( '<br><span class="hw-retweeted-by">' + ( self . locale . translate ( 'retweeted by <a href="%(link)s">%(tweeter)s</a>' ) % { #NEWLINE# #INDENT# 'link' : ( 'http://twitter.com/' + tweet [ 'user' ] [ 'screen_name' ] ) , #NEWLINE# 'tweeter' : tweet [ 'user' ] [ 'screen_name' ] , #NEWLINE# #UNINDENT# } ) ) + '</span>' ) #NEWLINE# new_tweet . username = tweet [ 'retweeted_status' ] [ 'user' ] [ 'screen_name' ] #NEWLINE# new_tweet . from_user = ( 'http://twitter.com/' + tweet [ 'retweeted_status' ] [ 'user' ] [ 'screen_name' ] ) #NEWLINE# new_tweet . avatar = tweet [ 'retweeted_status' ] [ 'user' ] [ 'profile_image_url' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# text = tornado . escape . linkify ( tweet [ 'text' ] ) #NEWLINE# #UNINDENT# text = re . compile ( '#(\\w+)' , ( re . M | re . U ) ) . sub ( '<a href="https://twitter.com/#!/search/%23\\1" rel="tag">#\\1</a>' , text ) #NEWLINE# text = re . compile ( '@(\\w+)' , ( re . M | re . U ) ) . sub ( '<a href="https://twitter.com/#!/\\1">@\\1</a>' , text ) #NEWLINE# new_tweet . view = content_remote . sanitize ( tornado . escape . xhtml_unescape ( text ) ) #NEWLINE# new_tweet . save ( ) #NEWLINE# #UNINDENT# count = self . models . content_remote . get ( to_username = self . user . username , type = 'twitter' , deleted = False ) . count ( ) #NEWLINE# self . write ( json . dumps ( { #NEWLINE# #INDENT# 'count' : count , #NEWLINE# #UNINDENT# } ) )