added updatecount

but it doesn't work and need to be dubbuged further..
develop
rick 5 months ago
parent f307ba1351
commit ad62325f4c

@ -9,7 +9,7 @@ def main(argv):
##
try:
opts, args = getopt.getopt(argv, 'ail')
opts, args = getopt.getopt(argv, 'ailu')
except getopt.GetoptError:
help()
sys.exit(2)
@ -30,12 +30,15 @@ def main(argv):
show_db()
elif opt == '-a':
add_db(get_input())
elif opt == '-u':
update_count()
def help():
print(""" usage:
-i init db
-l show db
-a add entry to db
-f file (parse text from a file)
-u update +1 episode of current watching anime
""")
def int_db():
@ -78,7 +81,7 @@ def get_input():
curep = int(curep)
maxep = int(maxep)
rating = int(rating)
print(state)
if state != 'planning' and state != 'running' and state != 'finished' and state != 'dropped':
sys.exit('Please use one of the following Paramters for State: planning, running, finished, dropped')
elif rating > 10:
@ -88,7 +91,36 @@ def get_input():
#print(db_input)
return db_input
def update_count():
#List all watching Episodes
found = 0
running_anime = conn.execute("SELECT id,name FROM anime WHERE state = 'running'")
for anime in running_anime:
print(anime)
selected_anime = input('Please select the number of the anime you want to update: ')
for running_id in running_anime:
print(running_id)
print('test ' + running_id)
if selected_anime == running_id:
found +=1
else:
print('debug else')
if found <= 0:
sys.exit('You really need to select an valid ID from above')
else:
#get current episode
cursor = conn.execute(("SELECT curep FROM anime WHERE id = ?"), selected_anime)
epsiode = cursor.fetchone()[0]
episode +=1
#add plus1 episode
conn.execute("UPDATE anime set curep = ?"), episode
print('Anime:' + running_anime.name + 'now has' + episode + 'Episodes')
#Start of Programm
#always try to open db
conn = sqlite3.connect('../database/test.db')
main(sys.argv[1:])
conn = sqlite3.connect('/home/rick/git/anidb/database/test.db')
main(sys.argv[1:])

Loading…
Cancel
Save