Merge branch 'main' of lain.church:bartholin/flask-server

This commit is contained in:
kaia 2024-10-13 17:22:38 +02:00
commit 293b976c95
2 changed files with 6 additions and 2 deletions

View File

@ -78,7 +78,7 @@ def get_watched_movies():
def new_movie(movie):
db = get_db()
movie["id"] = db.execute("INSERT INTO movies (title, year, poster, plot, number) VALUES (?,?,?,?,?) RETURNING id",
movie["id"] = db.execute("INSERT INTO movies (title, year, poster, plot, number, watched) VALUES (?,?,?,?,?, 0) RETURNING id",
(movie["title"], movie["year"], movie["poster"], movie["plot"], new_nb())).fetchone()["id"]
db.commit()
return movie
@ -87,7 +87,7 @@ def new_blank_movie():
db = get_db()
id = db.execute("INSERT INTO movies DEFAULT VALUES RETURNING id").fetchone()["id"]
nb = new_nb()
db.execute("UPDATE movies SET number = ? WHERE id = ?", (nb, id))
db.execute("UPDATE movies SET number = ?, watched = 0 WHERE id = ?", (nb, id))
db.commit()
return {"id": id, "nb": nb}

View File

@ -41,6 +41,10 @@ def imdbid(imdbid):
img = get(poster)
if img.status_code == 200:
movie["poster"] = posters.save(poster, img.content)
else:
movie["poster"] = None
else:
movie["poster"] = None
return movie
else:
return None