From 7385a65e3d370fadbc9c6f10b013a74701636cba Mon Sep 17 00:00:00 2001 From: Cinabre Date: Thu, 17 Dec 2020 01:40:35 +0100 Subject: [PATCH] Correction d'un bug --- create_manga.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/create_manga.py b/create_manga.py index 1dcdef0..2ed0750 100644 --- a/create_manga.py +++ b/create_manga.py @@ -20,9 +20,9 @@ def create_manga(url): print("Author : " + str(data["author"])) print("Link : " + url) print("Last chap : " + str(data["chap"])) - print("Image : " + str(data["img"]) + print("Image : " + str(data["img"])) - cursor.execute(""" INSERT INTO manga(id, title, author, url, chap, img) VALUES(:id, :title, :author, :url, :chap, :img)""", data) + cursor.execute("""INSERT INTO manga(id, title, author, url, chap, img) VALUES(:id, :title, :author, :url, :chap, :img)""", data) conn.commit() def main(): @@ -41,7 +41,13 @@ def main(): print("Mode utilisateur") url = input("Veuillez entrer l'URL du manga : ") print("URL : %s" % url) - create_manga(url) + try : + create_manga(url) + except sqlite3.IntegrityError : + print("Erreur dans l'ajout ! Deja present(?)") + except urllib.error.HTTPError : + print("Erreur HTTP.. deuxieme tentative") + create_manga(url)