Fixed filler dependencies
This commit is contained in:
parent
c688162300
commit
c6c994926d
3 changed files with 21 additions and 23 deletions
|
@ -4,6 +4,9 @@ SQLITE = 0
|
|||
MYSQL = 1
|
||||
MARIADB = MYSQL
|
||||
|
||||
MIN = 0
|
||||
MAX = 1
|
||||
|
||||
class dbObject:
|
||||
|
||||
# --------------------------------------------- Initialization -------------------------------------------------
|
||||
|
@ -56,9 +59,17 @@ class dbObject:
|
|||
except:
|
||||
return False
|
||||
|
||||
def getFLDate(self, val = 0):
|
||||
if val == 0:
|
||||
def getFLDate(self, val = MIN):
|
||||
if val == MIN:
|
||||
mode = "MIN"
|
||||
else:
|
||||
mode = "MAX"
|
||||
return getDate(str(list(self.executeQuery("SELECT %s(SUBSTR(timestamp,0,11)) FROM tweets" % mode))[0][0]))
|
||||
|
||||
def getLatestTweet(db):
|
||||
db.executeQuery("SELECT max(tweet_id) FROM tweets")
|
||||
try:
|
||||
return int(db.getNext()[0])
|
||||
except:
|
||||
return 0
|
||||
|
||||
|
|
24
filler.py
24
filler.py
|
@ -1,26 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import tools
|
||||
import dbtools, tools
|
||||
|
||||
import html.parser, os
|
||||
|
||||
def getSavepoint(db):
|
||||
db.executeQuery("SELECT max(tweet_id) FROM tweets")
|
||||
try:
|
||||
return int(db.getNext()[0])
|
||||
except:
|
||||
print("No tweets stored yet.")
|
||||
return 0
|
||||
|
||||
def unescapeText(text):
|
||||
return html.parser.HTMLParser().unescape(text).replace("'","''")
|
||||
|
||||
def fill(dbpath=tools.dbpath(), user=tools.user(), two=tools.twObject()):
|
||||
def fill(db=dbtools.dbObject(), user=tools.user(), two=tools.twObject()):
|
||||
query = "from:" + user
|
||||
|
||||
db = tools.dbHelper(dbpath)
|
||||
|
||||
savepoint = getSavepoint(db)
|
||||
savepoint = db.getLatestTweet()
|
||||
last = savepoint
|
||||
|
||||
timeline = two.search(query, savepoint)
|
||||
|
@ -29,7 +13,7 @@ def fill(dbpath=tools.dbpath(), user=tools.user(), two=tools.twObject()):
|
|||
|
||||
for status in timeline:
|
||||
timestamp = status.created_at.strftime('%Y-%m-%d %H:%M:%S') + " +0000"
|
||||
text = unescapeText(status.text)
|
||||
text = tools.unescapeText(status.text)
|
||||
|
||||
db.executeQuery("INSERT INTO tweets('tweet_id','timestamp','text') VALUES(" + str(status.id) + ",'" + timestamp + "','" + text + "')")
|
||||
db.commit()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import configparser, csv, datetime, itertools, os, sqlite3, sys, tweepy
|
||||
import configparser, csv, datetime, html.parser, itertools, os, sqlite3, sys, tweepy
|
||||
|
||||
class SetupException(Exception):
|
||||
def __str__(self):
|
||||
|
@ -158,3 +158,6 @@ def printCSV(inlist):
|
|||
writer = csv.writer(sys.stdout)
|
||||
writer.writerows(inlist)
|
||||
|
||||
def unescapeText(text):
|
||||
return html.parser.HTMLParser().unescape(text).replace("'","''")
|
||||
|
||||
|
|
Loading…
Reference in a new issue