diff --git a/chanbans/__main__.py b/chanbans/__main__.py index b720b6d..82b21c6 100644 --- a/chanbans/__main__.py +++ b/chanbans/__main__.py @@ -135,23 +135,27 @@ async def main(): if 'thumb' in post: thumb_path = Path(THUMBS_DIR, f"{post['thumb']}s.jpg") download_jobs += [get_thumb(thumb_path, post)] + else: + thumb_path = "" # Try to create post in database try: with db: curs = db.execute( - "insert into bans (action, board, length, post, thumb_path, reason) values(?, ?, ?, ?, ?)", + "insert into bans (action, board, length, post, thumb_path, reason) values(?, ?, ?, ?, ?, ?)", ( cols["action"], cols["board"], cols["length"], json.dumps(cols["post"]), - cols["thumb_path"], + str(thumb_path), cols["reason"], ), ) - except: - pass + except Exception as ex: + msg = str(ex) + if 'UNIQUE' not in msg: + print("error:", ex) # Finish off thumbnail jobs await asyncio.gather(*download_jobs)