modify scripts
This commit is contained in:
@ -184,6 +184,9 @@ class JavbusDBHandler(DatabaseHandler):
|
||||
|
||||
# 插入演员和电影的关联数据
|
||||
def insert_actor_movie(self, performer_id, movie_id, tags=''):
|
||||
if self.lower_sqlite_version:
|
||||
return self.insert_actor_movie_lower(performer_id, movie_id, tags)
|
||||
|
||||
try:
|
||||
self.cursor.execute("""
|
||||
INSERT INTO javbus_actors_movies (actor_id, movie_id, tags, updated_at)
|
||||
@ -202,7 +205,42 @@ class JavbusDBHandler(DatabaseHandler):
|
||||
self.conn.rollback()
|
||||
logging.error("Error inserting movie: %s", e)
|
||||
return None
|
||||
|
||||
|
||||
def insert_actor_movie_lower(self, performer_id, movie_id, tags=''):
|
||||
try:
|
||||
# 先尝试插入数据
|
||||
self.cursor.execute("""
|
||||
INSERT INTO javbus_actors_movies (actor_id, movie_id, tags, updated_at)
|
||||
VALUES (?, ?, ?, datetime('now', 'localtime'))
|
||||
""",
|
||||
(performer_id, movie_id, tags)
|
||||
)
|
||||
self.conn.commit()
|
||||
return performer_id
|
||||
|
||||
except sqlite3.IntegrityError:
|
||||
# 捕获唯一约束冲突错误
|
||||
try:
|
||||
# 如果冲突发生,执行更新操作
|
||||
self.cursor.execute("""
|
||||
UPDATE javbus_actors_movies
|
||||
SET tags=?, updated_at=datetime('now', 'localtime')
|
||||
WHERE actor_id=? AND movie_id=?
|
||||
""",
|
||||
(tags, performer_id, movie_id)
|
||||
)
|
||||
self.conn.commit()
|
||||
return performer_id
|
||||
except Exception as e:
|
||||
self.conn.rollback()
|
||||
logging.error("Error updating actor_movie: %s", e)
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
self.conn.rollback()
|
||||
logging.error("Error inserting actor_movie: %s", e)
|
||||
return None
|
||||
|
||||
def update_actor_detail_404(self, data, is_full_data=1):
|
||||
try:
|
||||
data['is_full_data'] = is_full_data
|
||||
@ -345,6 +383,9 @@ class JavbusDBHandler(DatabaseHandler):
|
||||
return self.insert_or_update_common(data, self.tbl_name_tags, uniq_key)
|
||||
|
||||
def insert_movie_tags(self, movie_id, tag_id, tags):
|
||||
if self.lower_sqlite_version:
|
||||
return self.insert_movie_tags_lower(movie_id, tag_id, tags)
|
||||
|
||||
try:
|
||||
self.cursor.execute("""
|
||||
INSERT INTO javbus_movies_tags (movie_id, tag_id, tags, updated_at)
|
||||
@ -364,6 +405,41 @@ class JavbusDBHandler(DatabaseHandler):
|
||||
logging.error("Error inserting movie: %s", e)
|
||||
return None
|
||||
|
||||
def insert_movie_tags_lower(self, movie_id, tag_id, tags):
|
||||
try:
|
||||
# 先尝试插入数据
|
||||
self.cursor.execute("""
|
||||
INSERT INTO javbus_movies_tags (movie_id, tag_id, tags, updated_at)
|
||||
VALUES (?, ?, ?, datetime('now', 'localtime'))
|
||||
""",
|
||||
(movie_id, tag_id, tags)
|
||||
)
|
||||
self.conn.commit()
|
||||
return movie_id
|
||||
|
||||
except sqlite3.IntegrityError:
|
||||
# 捕获唯一约束冲突错误
|
||||
try:
|
||||
# 如果冲突发生,执行更新操作
|
||||
self.cursor.execute("""
|
||||
UPDATE javbus_movies_tags
|
||||
SET tags=?, updated_at=datetime('now', 'localtime')
|
||||
WHERE tag_id=? AND movie_id=?
|
||||
""",
|
||||
(tags, tag_id, movie_id)
|
||||
)
|
||||
self.conn.commit()
|
||||
return movie_id
|
||||
except Exception as e:
|
||||
self.conn.rollback()
|
||||
logging.error("Error updating movie_tags: %s", e)
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
self.conn.rollback()
|
||||
logging.error("Error inserting movie_tags: %s", e)
|
||||
return None
|
||||
|
||||
def insert_or_update_movie_404(self, data, is_full_data=1):
|
||||
try:
|
||||
data['is_full_data'] = is_full_data
|
||||
|
||||
Reference in New Issue
Block a user