diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2021-03-06 15:56:32 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2021-03-06 15:56:32 +0000 |
commit | 7f549879d0a29313c75e96a623c1b4606dce5a06 (patch) | |
tree | 06e9aa591a664265ddda0ad8dd35c43eaba6e661 /services.py | |
parent | 7cc501c5efde9da7c5e4dbfd854cdeb80a8e0ce9 (diff) | |
download | eda.gay-7f549879d0a29313c75e96a623c1b4606dce5a06.tar.gz eda.gay-7f549879d0a29313c75e96a623c1b4606dce5a06.zip |
added caching tweets, added git commits
Diffstat (limited to 'services.py')
-rw-r--r-- | services.py | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/services.py b/services.py index 2cfe394..4f014d8 100644 --- a/services.py +++ b/services.py @@ -1,6 +1,5 @@ from dataclasses import dataclass from io import StringIO -from lxml import html import multiprocessing import pihole as ph import qbittorrent @@ -112,30 +111,4 @@ def get_pihole_stats(): "domains": pihole.domain_count, "last_updated": str(datetime.datetime.fromtimestamp(pihole.gravity_last_updated["absolute"])) } - -# @timeout -def get_recent_tweets(numToGet): - tweets = [] - domain = "http://" + app.CONFIG.get("nitter", "domain") - with app.database.Database() as db: - for title, url in db.get_header_links(): - if title == "twitter": - break - tree = html.fromstring(requests.get(url).content) - for i, tweetUrlElement in enumerate(tree.xpath('//*[@class="tweet-link"]'), 0): - if i > 0: - tweets.append(( - domain + tweetUrlElement.get("href"), - tweetUrlElement.getparent().find_class("tweet-content media-body")[0].text - )) - if len(tweets) >= numToGet: - break - return tweets + [(url, "view all tweets...")] - - - -if __name__ == "__main__": - for tweet in get_recent_tweets(): - print(tweet.get_url()) - print(tweet.get_text()) - print()
\ No newline at end of file + |