mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
initial work on bot posting
This commit is contained in:
parent
7015431687
commit
44c7e24a53
1 changed files with 19 additions and 2 deletions
21
service.py
21
service.py
|
@ -84,6 +84,9 @@ def scrape_posts(account):
|
||||||
c.close()
|
c.close()
|
||||||
print("Finished {}".format(handle))
|
print("Finished {}".format(handle))
|
||||||
|
|
||||||
|
def make_post(bot):
|
||||||
|
pass
|
||||||
|
|
||||||
print("Establishing DB connection")
|
print("Establishing DB connection")
|
||||||
db = MySQLdb.connect(
|
db = MySQLdb.connect(
|
||||||
host = cfg['db_host'],
|
host = cfg['db_host'],
|
||||||
|
@ -93,12 +96,26 @@ db = MySQLdb.connect(
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Downloading posts")
|
print("Downloading posts")
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()")
|
cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()")
|
||||||
accounts = cursor.fetchall()
|
accounts = cursor.fetchall()
|
||||||
cursor.close()
|
|
||||||
with Pool(8) as p:
|
with Pool(8) as p:
|
||||||
p.map(scrape_posts, accounts)
|
p.map(scrape_posts, accounts)
|
||||||
|
|
||||||
|
print("Generating posts")
|
||||||
|
cursor.execute("""
|
||||||
|
SELECT
|
||||||
|
bots.handle, credentials.client_id, credentials.client_secret, credentials.secret
|
||||||
|
FROM
|
||||||
|
bots,
|
||||||
|
credentials
|
||||||
|
WHERE
|
||||||
|
bots.credentials_id = credentials.id
|
||||||
|
AND bots.enabled = TRUE;
|
||||||
|
""")
|
||||||
|
bots = cursor.fetchall()
|
||||||
|
|
||||||
|
with Pool(8) as p:
|
||||||
|
p.map(make_post, bots)
|
||||||
|
|
||||||
#TODO: other cron tasks should be done here, like updating profile pictures
|
#TODO: other cron tasks should be done here, like updating profile pictures
|
||||||
|
|
Loading…
Reference in a new issue