| @@ -1,13 +1,17 @@ | |||||
| # coding: utf-8 | # coding: utf-8 | ||||
| from mangadex import * | from mangadex import * | ||||
| import sqlite3 | |||||
| import sqlite3, sys | |||||
| conn = sqlite3.connect('database.db') | conn = sqlite3.connect('database.db') | ||||
| cursor = conn.cursor() | cursor = conn.cursor() | ||||
| url = "https://mangadex.org/title/31477" | url = "https://mangadex.org/title/31477" | ||||
| def check_if_exit(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), | ||||
| @@ -21,3 +25,16 @@ 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(): | |||||
| if len(sys.argv) == 2 : | |||||
| print("Mode Script") | |||||
| url = sys.argv[1] | |||||
| print("URL : %s" % url) | |||||
| else : | |||||
| print("Mode utilisateur") | |||||
| url = input("Veuillez entrer l'URL du manga : ") | |||||
| print("URL : %s" % url) | |||||
| if __name__ == '__main__': | |||||
| main() | |||||
| @@ -60,4 +60,6 @@ def main(): | |||||
| print("Dernier chap : %s " % chap) | print("Dernier chap : %s " % chap) | ||||
| link = get_url(get_id(url)) | link = get_url(get_id(url)) | ||||
| print("Url mangadex : %s" % link) | print("Url mangadex : %s" % link) | ||||
| main() | |||||
| if __name__ == '__main__': | |||||
| main() | |||||
| @@ -5,26 +5,28 @@ import sqlite3 | |||||
| conn = sqlite3.connect('database.db') | conn = sqlite3.connect('database.db') | ||||
| cursor = conn.cursor() | cursor = conn.cursor() | ||||
| def main(): | |||||
| print("Pas de fonction Main") | |||||
| def update_manga(id): | def update_manga(id): | ||||
| url = get_url(id) | url = get_url(id) | ||||
| # On récupère l'URL | |||||
| cursor.execute("SELECT chap FROM manga WHERE id = '%s'" % id) | cursor.execute("SELECT chap FROM manga WHERE id = '%s'" % id) | ||||
| rows = cursor.fetchall() | rows = cursor.fetchall() | ||||
| # Last_chapt est le dernier chapitre sauvegardé | |||||
| last_chapt = str(rows[0][0]) | last_chapt = str(rows[0][0]) | ||||
| 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 enregistre est %s" % get_last_chap(url)) | ||||
| if int(last_chapt) == get_last_chap(url) : | |||||
| if int(last_chapt) == int(get_last_chap(url)) : | |||||
| print("Nous sommes a jour") | print("Nous sommes a jour") | ||||
| else : | else : | ||||
| print("Pas a jour ! :c ") | |||||
| 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() | ||||
| update_manga(31477) | |||||
| if __name__ == '__main__': | |||||
| main() | |||||