watch_list_name.py 722 B

1234567891011121314151617181920212223
  1. from .tool.func import *
  2. def watch_list_name_2(conn, name):
  3. curs = conn.cursor()
  4. ip = ip_check()
  5. if ip_or_user(ip) != 0:
  6. return redirect('/login')
  7. curs.execute(db_change("select count(title) from scan where user = ?"), [ip])
  8. count = curs.fetchall()
  9. if count and count[0][0] > 9:
  10. return redirect('/watch_list')
  11. curs.execute(db_change("select title from scan where user = ? and title = ?"), [ip, name])
  12. if curs.fetchall():
  13. curs.execute(db_change("delete from scan where user = ? and title = ?"), [ip, name])
  14. else:
  15. curs.execute(db_change("insert into scan (user, title) values (?, ?)"), [ip, name])
  16. conn.commit()
  17. return redirect('/watch_list')