From cfa32589d4dba15bb063cbb611ceab66c4343fe7 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 11 Sep 2019 15:26:28 +1000 Subject: [PATCH] handle case where we haven't scraped any posts yet i guess --- scrape.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scrape.py b/scrape.py index cf386fa..e8151cb 100644 --- a/scrape.py +++ b/scrape.py @@ -13,7 +13,8 @@ def scrape_posts(account): c = db.cursor() last_post = 0 c.execute("SELECT COUNT(*) FROM `posts` WHERE `fedi_id` = %s", (handle,)) - if c.fetchone()[0] > 0: + count = c.fetchone() + if count is not None and count > 0: # we've downloaded this user's posts before # find out the most recently downloaded post of theirs c.execute("SELECT `post_id` FROM `posts` WHERE `fedi_id` = %s ORDER BY `id` DESC LIMIT 1", (handle,))