modify scripts
This commit is contained in:
@ -634,7 +634,7 @@ class JavbusDBHandler(DatabaseHandler):
|
||||
return result
|
||||
|
||||
# 处理影片的 无码 字段
|
||||
def reset_movies_uncensored(self):
|
||||
def reset_movies_uncensored(self, check_and_do = 0):
|
||||
try:
|
||||
logging.info("创建临时表以便于保存待更新记录")
|
||||
self.cursor.execute("""
|
||||
@ -669,24 +669,26 @@ class JavbusDBHandler(DatabaseHandler):
|
||||
total_movies = self.cursor.execute("SELECT COUNT(*) FROM javbus_movies").fetchone()[0]
|
||||
logging.info(f"共收集到 {total_count} 部需要更新的影片, 共有 {total_movies} 部影片")
|
||||
|
||||
# 1. 将所有记录的uncensored默认设为0
|
||||
logging.info("开始将所有影片的uncensored设为默认值0...")
|
||||
self.cursor.execute("UPDATE javbus_movies SET uncensored = 0")
|
||||
logging.info(f"已将 {self.cursor.rowcount} 条记录的uncensored设为0")
|
||||
if check_and_do:
|
||||
# 1. 将所有记录的uncensored默认设为0
|
||||
logging.info("开始将所有影片的uncensored设为默认值0...")
|
||||
self.cursor.execute("UPDATE javbus_movies SET uncensored = 0")
|
||||
logging.info(f"已将 {self.cursor.rowcount} 条记录的uncensored设为0")
|
||||
|
||||
# 2. 将临时表中匹配的记录设为1
|
||||
logging.info("开始将匹配的影片的uncensored设为1...")
|
||||
self.cursor.execute("""
|
||||
UPDATE javbus_movies
|
||||
SET uncensored = 1
|
||||
WHERE id IN (SELECT movie_id FROM temp_movies_to_update)
|
||||
""")
|
||||
logging.info(f"已将 {self.cursor.rowcount} 条记录的uncensored设为1")
|
||||
# 2. 将临时表中匹配的记录设为1
|
||||
logging.info("开始将匹配的影片的uncensored设为1...")
|
||||
self.cursor.execute("""
|
||||
UPDATE javbus_movies
|
||||
SET uncensored = 1
|
||||
WHERE id IN (SELECT movie_id FROM temp_movies_to_update)
|
||||
""")
|
||||
logging.info(f"已将 {self.cursor.rowcount} 条记录的uncensored设为1")
|
||||
|
||||
# 3. 清理临时表,也可以不清理,以便于抽检
|
||||
self.conn.commit()
|
||||
else:
|
||||
logging.info("check完毕,本次忽略更新。。。")
|
||||
|
||||
self.conn.commit()
|
||||
logging.info("所有更新已提交")
|
||||
logging.info("任务执行完成!")
|
||||
|
||||
except sqlite3.Error as e:
|
||||
self.conn.rollback()
|
||||
|
||||
Reference in New Issue
Block a user