|
- import sqlite3, sys
- from database import *
-
- conn = sqlite3.connect('database.db')
- cursor = conn.cursor()
-
-
-
-
- def get_last_read(uid, mid):
- cursor.execute("SELECT chap FROM readings WHERE uid = '{}' AND mid = '{}';".format(uid, mid) )
- rows = cursor.fetchall()
- if len(rows) == 0 :
- return 0
- return rows[0][0]
-
-
- def chapter_read_plus(uid, mid, number):
- username = get_dbusername(uid)
- title = get_dbtitle(mid)
- print("------ PLUS ------")
- print("User : %s" % str(username))
- print("Manga : %s" % str(mid))
- print("Last Read: %s " % get_last_read(uid, mid))
-
-
- get_last_release(mid)
- new_value = int(get_last_read(uid, mid)) + int(number)
- print("New Value : %s" % str(new_value))
- cursor.execute("UPDATE readings SET chap = '{}' WHERE mid = '{}' AND uid = '{}';".format(new_value, mid, uid) )
- conn.commit()
-
- def chapter_read_minus(uid, mid, number):
- username = get_dbusername(uid)
- title = get_dbtitle(mid)
- print("------ MINUS ------")
- print("User : %s" % str(username))
- print("Manga : %s" % str(mid))
- print("Last Read: %s " % get_last_read(uid, mid) )
-
- get_last_release(mid)
- new_value = int(get_last_read(uid, mid)) - int(number)
- print("New Value : %s" % str(new_value))
-
- cursor.execute("UPDATE readings SET chap = '{}' WHERE mid = '{}' AND uid = '{}';".format(new_value, mid, uid) )
-
- conn.commit()
-
- def chapter_read_manual(uid, mid, chap):
- username = get_dbusername(uid)
- title = get_dbtitle(mid)
- print("------ MANUAL ------")
- print("User : %s" % str(username))
- print("Manga : %s" % str(mid))
- print("Chapter : %s" % str(chap))
- print("Last Read: %s " % get_last_read(uid, mid) )
-
- if str(get_last_read(uid, mid)) == str(chap) :
- print("Vous avez deja lu ce chapitre")
- else :
- print("Vous n'avez pas vu le chapitre {} du manga {}".format(chap, title))
- cursor.execute("UPDATE readings SET chap = '{}' WHERE mid = '{}' AND uid = '{}';".format(chap, mid, uid) )
- conn.commit()
-
-
- def main():
- uid = input("UserID : ")
- mid = input("MangaID : ")
- """number = input("Nombre : ")
- chapter_read_minus(uid, mid, number)"""
- print(get_last_read(uid, mid))
-
-
-
-
- if __name__ == '__main__':
- try :
- main()
- except KeyboardInterrupt :
- print("CTRL+C, Exiting...")
- except IndexError :
- print("Bad values")
|