aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2023-01-20 10:41:08 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2023-01-20 10:41:08 +0000
commit94a4ece4dbb7394f51e88f7b246d2f432de76dff (patch)
tree01e2a10ccc360e1b195162a29cf2f29c8979b1f7
parent6f4e01ab94b82de3a946bb1d889f061fc8f837c9 (diff)
downloadeda.gay-94a4ece4dbb7394f51e88f7b246d2f432de76dff.tar.gz
eda.gay-94a4ece4dbb7394f51e88f7b246d2f432de76dff.zip
Added oauth2 authenticion instead
-rwxr-xr-xapp.py2
-rwxr-xr-xdatabase.py18
2 files changed, 14 insertions, 6 deletions
diff --git a/app.py b/app.py
index 011bddc..66d7f55 100755
--- a/app.py
+++ b/app.py
@@ -16,7 +16,7 @@ import os
import io
app = flask.Flask(__name__)
-CONFIG = configparser.ConfigParser()
+CONFIG = configparser.ConfigParser(interpolation = None)
CONFIG.read("edaweb.conf")
shown_images = set()
diff --git a/database.py b/database.py
index d8cfe86..ebf356d 100755
--- a/database.py
+++ b/database.py
@@ -19,7 +19,7 @@ class Database:
passwd:str = None
def __enter__(self):
- self.config = configparser.ConfigParser()
+ self.config = configparser.ConfigParser(interpolation = None)
self.config.read("edaweb.conf")
if self.safeLogin:
@@ -216,7 +216,7 @@ class Database:
with self.__connection.cursor() as cursor:
cursor.execute("INSERT INTO diaryimages (tweet_id, link) VALUES (%s, %s);", (tweet_id, imurl))
- def get_diary(self, twitteracc = "FUCKEDUPTRANNY"):
+ def get_diary(self):
threading.Thread(target = update_cache).start()
out = {}
with self.__connection.cursor() as cursor:
@@ -226,7 +226,11 @@ class Database:
out[tweeted_at] = [{
"text": tweet_text,
"images": self.get_diary_image(tweet_id),
- "link": "https://%s/%s/status/%d" % (self.config.get("nitter", "domain"), twitteracc, tweet_id)
+ "link": "https://%s/%s/status/%d" % (
+ self.config.get("nitter", "domain"),
+ self.get_my_diary_twitter(),
+ tweet_id
+ )
}]
next_tweet = self.get_child_tweets(tweet_id)
@@ -267,7 +271,11 @@ class Database:
def fetch_diary(self):
twitteracc = self.get_my_diary_twitter()
- twitter = twython.Twython(*dict(dict(self.config)["twitter"]).values())
+ twitter = twython.Twython(
+ self.config.get("twitter", "app_key"),
+ access_token = self.config.get("twitter", "oauth_2_token")
+ )
+
for tweet in twitter.search(q = "(from:%s)" % twitteracc, since_id = self.get_newest_diary_tweet_id())["statuses"]:
tweet_id = tweet["id"]
tweeted_at = datetime.datetime.strptime(tweet["created_at"], "%a %b %d %H:%M:%S %z %Y")
@@ -339,4 +347,4 @@ def request_recent_commits(since = datetime.datetime.now() - datetime.timedelta(
if __name__ == "__main__":
with Database() as db:
- print(db.get_diary())
+ print(db.fetch_diary())