update movie database schema

This commit is contained in:
iou1name 2021-02-06 00:37:18 -05:00
parent 64953ae402
commit a632948414

View File

@ -23,14 +23,10 @@ def setup(bot):
cur.execute("SELECT * FROM movie").fetchone()
except OperationalError:
cur.execute("CREATE TABLE movie("
"movie_title TEXT NOT NULL PRIMARY KEY,"
"added_by TEXT DEFAULT 'UNKNOWN',"
"title TEXT PRIMARY KEY,"
"added_by TEXT,"
"added_date INTEGER DEFAULT (STRFTIME('%s', 'now')),"
"times_watched INTEGER DEFAULT 0,"
"first_watched TEXT DEFAULT 'NA',"
"shitpost INTEGER DEFAULT 0,"
"theater_release_date TEXT,"
"bluray_release_date TEXT"
"watched INTEGER DEFAULT 0"
")")
con.commit()
con.close()
@ -140,8 +136,8 @@ def pickMovie(bot, trigger):
Picks a random movie title out of the database.
"""
bot.memory['movie_lock'].acquire()
cur = bot.db.execute("SELECT movie_title FROM movie WHERE " + \
"times_watched < 1 AND shitpost = 0 ORDER BY RANDOM() LIMIT 1;")
cur = bot.db.execute("SELECT title FROM movie WHERE "
"watched = 0 ORDER BY RANDOM() LIMIT 1;")
movie = cur.fetchone()
bot.memory['movie_lock'].release()
@ -168,7 +164,7 @@ def addMovie(bot, trigger):
movie = ' '.join(trigger.args[1:])
bot.memory['movie_lock'].acquire()
try:
bot.db.execute("INSERT INTO movie (movie_title, added_by) VALUES(?,?)",
bot.db.execute("INSERT INTO movie (title, added_by) VALUES(?,?)",
(movie, trigger.nick))
confirm = f"Added movie: {movie}"
except IntegrityError: