script/lib/iri_tweet/export_twitter_alchemy.py
changeset 23 2b17b26ca153
parent 22 3823611919ef
child 27 c3ea041c6cde
equal deleted inserted replaced
22:3823611919ef 23:2b17b26ca153
   142                     te = ts + duration
   142                     te = ts + duration
   143                     end_date = start_date + datetime.timedelta(seconds=duration)
   143                     end_date = start_date + datetime.timedelta(seconds=duration)
   144         
   144         
   145             
   145             
   146                 query_res = session.query(Tweet).join(EntityHashtag).join(Hashtag).filter(~Tweet.id.in_(select([tweet_exclude_table.c.id]))).filter(Hashtag.text.contains(options.hashtag)).filter(Tweet.created_at >=  start_date).filter(Tweet.created_at <=  end_date).all()
   146                 query_res = session.query(Tweet).join(EntityHashtag).join(Hashtag).filter(~Tweet.id.in_(select([tweet_exclude_table.c.id]))).filter(Hashtag.text.contains(options.hashtag)).filter(Tweet.created_at >=  start_date).filter(Tweet.created_at <=  end_date).all()
   147                  
   147                                  
   148                 #hashtag = u"%#"+unicode(options.hashtag)+u"%"
       
   149                 
       
   150                 #cursor.execute("select tt.id, tt.text, tt.created_at_ts, tu.name, tu.screen_name from tweet_tweet as tt join tweet_user as tu on tt.user = tu.rowid where text like ? and tt.created_at_ts >= ? and tt.created_at_ts <= ? and tt.id not in (select id from tweet_exclude) order by tt.created_at_ts asc;", (hashtag,ts,te));
       
   151                 
       
   152                 root = None
   148                 root = None
   153                 ensemble_parent = None
   149                 ensemble_parent = None
   154                 
   150                 
   155                 if content_file and os.path.exists(content_file):
   151                 if content_file and os.path.exists(content_file):
   156             
   152             
   216                             '==' : u'REF'}[m.group(1)]
   212                             '==' : u'REF'}[m.group(1)]
   217                         etree.SubElement(polemics_element, u'polemic').text = pol_link
   213                         etree.SubElement(polemics_element, u'polemic').text = pol_link
   218                     if polemic_added:
   214                     if polemic_added:
   219                         meta_element.append(polemics_element)
   215                         meta_element.append(polemics_element)
   220                     
   216                     
   221                     etree.SubElement(meta_element, u"twitter").text = etree.CDATA(unicode(tw.original_json))
   217                     etree.SubElement(meta_element, u"source", attrib={"url":u"http://dev.twitter.com", "mimetype":u"application/json"}).text = etree.CDATA(unicode(tw.original_json))
   222                     
   218                     
   223                 
   219                 
   224                 if content_file and os.path.exists(content_file):
   220                 if content_file and os.path.exists(content_file):
   225                     dest_file_name = content_file 
   221                     dest_file_name = content_file 
   226                 else:
   222                 else: