script/lib/iri_tweet/export_twitter_alchemy.py
changeset 83 4a759c70e40f
parent 82 210dc265c70f
child 84 b1029aa40ec3
equal deleted inserted replaced
82:210dc265c70f 83:4a759c70e40f
   271                 for tw in query_res:
   271                 for tw in query_res:
   272                     tweet_ts_dt = tw.created_at
   272                     tweet_ts_dt = tw.created_at
   273                     tweet_ts = int(time.mktime(tweet_ts_dt.timetuple()))
   273                     tweet_ts = int(time.mktime(tweet_ts_dt.timetuple()))
   274                     tweet_ts_rel = (tweet_ts-ts) * 1000
   274                     tweet_ts_rel = (tweet_ts-ts) * 1000
   275                     username = None
   275                     username = None
       
   276                     profile_url = ""
   276                     if tw.user is not None:
   277                     if tw.user is not None:
   277                         username = tw.user.name
   278                         username = tw.user.name
       
   279                         profile_url = tw.user.profile_image_url
   278                     if not username:
   280                     if not username:
   279                         username = "anon."
   281                         username = "anon."
   280                     element = etree.SubElement(elements, u"element" , {u"id":unicode(uuid.uuid4())+u"-"+unicode(tw.id), u"color":unicode(options.color), u"author":unicode(username), u"date":unicode(tweet_ts_dt.strftime("%Y/%m/%d")), u"begin": unicode(tweet_ts_rel), u"dur":u"0", u"src":u""})
   282                     
       
   283                     element = etree.SubElement(elements, u"element" , {u"id":unicode(uuid.uuid4())+u"-"+unicode(tw.id), u"color":unicode(options.color), u"author":unicode(username), u"date":unicode(tweet_ts_dt.strftime("%Y/%m/%d")), u"begin": unicode(tweet_ts_rel), u"dur":u"0", u"src":unicode(profile_url)})
   281                     etree.SubElement(element, u"title").text = unicode(username) + u": " + unicode(tw.text)
   284                     etree.SubElement(element, u"title").text = unicode(username) + u": " + unicode(tw.text)
   282                     etree.SubElement(element, u"abstract").text = unicode(tw.text)
   285                     etree.SubElement(element, u"abstract").text = unicode(tw.text)
   283             
   286             
   284                     tags_node = etree.SubElement(element, u"tags")
   287                     tags_node = etree.SubElement(element, u"tags")
   285                     
   288