Un serveur permettant de récupérer à quelle manga on s'est arrêté d'une licence. Un script se chargera de récupérer automatiquement les derniers mangas à jour à l'aide du site MangaDex
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

update_manga.py 1.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # coding: utf-8
  2. from mangadex import *
  3. import sqlite3
  4. conn = sqlite3.connect('database.db')
  5. cursor = conn.cursor()
  6. def main():
  7. #print("Pas de fonction Main")
  8. fetch_all_id()
  9. def fetch_all_id():
  10. print("Recuperation des IDs")
  11. cursor.execute("SELECT id FROM manga;")
  12. rows = cursor.fetchall()
  13. print("----- MISE A JOUR DES CHAPITRES -----")
  14. for i in range(len(rows)):
  15. print(rows[i][0])
  16. update_manga(rows[i][0])
  17. print("----- FIN -----")
  18. def update_manga(id):
  19. url = get_url(id)
  20. # On récupère l'URL
  21. cursor.execute("SELECT chap FROM manga WHERE id = '%s'" % id)
  22. rows = cursor.fetchall()
  23. # Last_chapt est le dernier chapitre sauvegardé
  24. last_chapt = str(rows[0][0])
  25. new_chapt = get_last_chap(url)
  26. print("Mise a jour de %s" % get_title(url))
  27. print("Le dernier chapitre est %s" % last_chapt)
  28. print("Le dernier chapitre sur mangadex est %s" % new_chapt)
  29. if int(last_chapt) == int(new_chapt) :
  30. print("Nous sommes a jour")
  31. else :
  32. print("Pas a jour ! Le dernier chapitre est %s " % new_chapt)
  33. cursor.execute("UPDATE manga SET chap = '{}' WHERE id = '{}'".format(get_last_chap(url), get_id(url)))
  34. conn.commit()
  35. if __name__ == '__main__':
  36. main()