1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 08:38:59 +00:00

started work on service.py, the cron thing that actually downloads the posts

This commit is contained in:
Lynne Megido 2019-09-03 14:29:45 +10:00
parent 0294f8e004
commit dd3679d8db

View file

@ -0,0 +1,33 @@
#!/usr/bin/env python3
from mastodon import Mastodon
import MySQLdb
import requests
from multiprocessing import Pool
import json
cfg = json.load(open('config.json'))
def scrape_posts(handle, outbox):
# check for min_id
last_post = 0
r = requests.get(outbox)
j = r.json()
pleroma = 'next' not in j
if pleroma:
j = j['first']
else:
uri = "{}&min_id={}".format(outbox, last_post)
r = requests.get(uri)
j = r.json()
print("Establishing DB connection")
db = MySQLdb.connect(
host = cfg['db_host'],
user=cfg['db_user'],
passwd=cfg['db_pass'],
db=cfg['db_name']
)
c = db.cursor()
print("Downloading posts")