| @@ -9,9 +9,9 @@ url = "https://mangadex.org/title/31477" | |||||
| def check_if_exit(url): | def check_if_exit(url): | ||||
| id = get_id(url) | id = get_id(url) | ||||
| def create_manga(url): | |||||
| def create_manga(url): | |||||
| data = {"id" : get_id(url), | data = {"id" : get_id(url), | ||||
| "title" : get_title(url), | "title" : get_title(url), | ||||
| "author" : get_author(url), | "author" : get_author(url), | ||||
| @@ -25,16 +25,20 @@ def create_manga(url): | |||||
| print("Last chap" + str(data["chap"])) | print("Last chap" + str(data["chap"])) | ||||
| cursor.execute(""" INSERT INTO manga(id, title, author, url, chap) VALUES(:id, :title, :author, :url, :chap)""", data) | cursor.execute(""" INSERT INTO manga(id, title, author, url, chap) VALUES(:id, :title, :author, :url, :chap)""", data) | ||||
| conn.commit() | conn.commit() | ||||
| def main(): | def main(): | ||||
| if len(sys.argv) == 2 : | if len(sys.argv) == 2 : | ||||
| print("Mode Script") | print("Mode Script") | ||||
| url = sys.argv[1] | url = sys.argv[1] | ||||
| print("URL : %s" % url) | print("URL : %s" % url) | ||||
| else : | else : | ||||
| print("Mode utilisateur") | print("Mode utilisateur") | ||||
| url = input("Veuillez entrer l'URL du manga : ") | url = input("Veuillez entrer l'URL du manga : ") | ||||
| print("URL : %s" % url) | print("URL : %s" % url) | ||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| main() | main() | ||||
| @@ -6,7 +6,8 @@ conn = sqlite3.connect('database.db') | |||||
| cursor = conn.cursor() | cursor = conn.cursor() | ||||
| def main(): | def main(): | ||||
| print("Pas de fonction Main") | |||||
| #print("Pas de fonction Main") | |||||
| update_manga(31477) | |||||
| def update_manga(id): | def update_manga(id): | ||||
| url = get_url(id) | url = get_url(id) | ||||
| @@ -17,14 +18,16 @@ def update_manga(id): | |||||
| rows = cursor.fetchall() | rows = cursor.fetchall() | ||||
| # Last_chapt est le dernier chapitre sauvegardé | # Last_chapt est le dernier chapitre sauvegardé | ||||
| last_chapt = str(rows[0][0]) | last_chapt = str(rows[0][0]) | ||||
| new_chapt = get_last_chap(url) | |||||
| print("Mise a jour de %s" % get_title(url)) | print("Mise a jour de %s" % get_title(url)) | ||||
| print("Le dernier chapitre est %s" % last_chapt) | print("Le dernier chapitre est %s" % last_chapt) | ||||
| print("Le dernier chapitre enregistre est %s" % get_last_chap(url)) | |||||
| print("Le dernier chapitre sur mangadex est %s" % new_chapt) | |||||
| if int(last_chapt) == int(get_last_chap(url)) : | |||||
| if int(last_chapt) == int(new_chapt) : | |||||
| print("Nous sommes a jour") | print("Nous sommes a jour") | ||||
| else : | else : | ||||
| print("Pas a jour ! Le dernier chapitre est %s " ) | |||||
| print("Pas a jour ! Le dernier chapitre est %s " % ) | |||||
| cursor.execute("UPDATE manga SET chap = '{}' WHERE id = '{}'".format(get_last_chap(url), get_id(url))) | cursor.execute("UPDATE manga SET chap = '{}' WHERE id = '{}'".format(get_last_chap(url), get_id(url))) | ||||
| conn.commit() | conn.commit() | ||||