mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-29 15:45:18 +08:00
fix: fix #300
This commit is contained in:
@@ -4,7 +4,6 @@ import logging
|
||||
|
||||
|
||||
from module.conf import DATA_PATH
|
||||
from module.ab_decorator import locked
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -17,7 +16,6 @@ class DataConnector:
|
||||
self._conn = sqlite3.connect(DATA_PATH)
|
||||
self._cursor = self._conn.cursor()
|
||||
|
||||
@locked
|
||||
def _update_table(self, table_name: str, db_data: dict):
|
||||
columns = ", ".join(
|
||||
[
|
||||
@@ -41,7 +39,6 @@ class DataConnector:
|
||||
self._conn.commit()
|
||||
logger.debug(f"Create / Update table {table_name}.")
|
||||
|
||||
@locked
|
||||
def _insert(self, table_name: str, db_data: dict):
|
||||
columns = ", ".join(db_data.keys())
|
||||
values = ", ".join([f":{key}" for key in db_data.keys()])
|
||||
@@ -50,7 +47,6 @@ class DataConnector:
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
@locked
|
||||
def _insert_list(self, table_name: str, data_list: list[dict]):
|
||||
columns = ", ".join(data_list[0].keys())
|
||||
values = ", ".join([f":{key}" for key in data_list[0].keys()])
|
||||
@@ -59,7 +55,6 @@ class DataConnector:
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
@locked
|
||||
def _select(self, keys: list[str], table_name: str, condition: str = None) -> dict:
|
||||
if condition is None:
|
||||
self._cursor.execute(f"SELECT {', '.join(keys)} FROM {table_name}")
|
||||
@@ -69,7 +64,6 @@ class DataConnector:
|
||||
)
|
||||
return dict(zip(keys, self._cursor.fetchone()))
|
||||
|
||||
@locked
|
||||
def _update(self, table_name: str, db_data: dict):
|
||||
_id = db_data.get("id")
|
||||
if _id is None:
|
||||
@@ -81,7 +75,6 @@ class DataConnector:
|
||||
self._conn.commit()
|
||||
return self._cursor.rowcount == 1
|
||||
|
||||
@locked
|
||||
def _update_list(self, table_name: str, data_list: list[dict]):
|
||||
if len(data_list) == 0:
|
||||
return
|
||||
@@ -93,7 +86,6 @@ class DataConnector:
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
@locked
|
||||
def _update_section(self, table_name: str, location: dict, update_dict: dict):
|
||||
set_sql = ", ".join([f"{key} = :{key}" for key in update_dict.keys()])
|
||||
sql_loc = f"{location['key']} = {location['value']}"
|
||||
@@ -102,12 +94,12 @@ class DataConnector:
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
@locked
|
||||
|
||||
def _delete_all(self, table_name: str):
|
||||
self._cursor.execute(f"DELETE FROM {table_name}")
|
||||
self._conn.commit()
|
||||
|
||||
@locked
|
||||
|
||||
def _search_data(self, table_name: str, keys: list[str] | None, condition: str) -> dict:
|
||||
if keys is None:
|
||||
self._cursor.execute(f"SELECT * FROM {table_name} WHERE {condition}")
|
||||
@@ -117,7 +109,7 @@ class DataConnector:
|
||||
)
|
||||
return dict(zip(keys, self._cursor.fetchone()))
|
||||
|
||||
@locked
|
||||
|
||||
def _search_datas(self, table_name: str, keys: list[str] | None, condition: str = None) -> list[dict]:
|
||||
if keys is None:
|
||||
select_sql = "*"
|
||||
|
||||
@@ -132,7 +132,12 @@ class QbDownloader:
|
||||
return self._client.torrents_info(hashes=_hash)[0].save_path
|
||||
|
||||
def set_category(self, _hash, category):
|
||||
self._client.torrents_set_category(category, hashes=_hash)
|
||||
try:
|
||||
self._client.torrents_set_category(category, hashes=_hash)
|
||||
except Conflict409Error:
|
||||
logger.warning(f"[Downloader] Category {category} does not exist")
|
||||
self.add_category(category)
|
||||
self._client.torrents_set_category(category, hashes=_hash)
|
||||
|
||||
def check_connection(self):
|
||||
return self._client.app_version()
|
||||
|
||||
@@ -106,7 +106,7 @@ class Renamer(DownloadClient):
|
||||
_hash=_hash, old_path=media_path, new_path=new_path
|
||||
)
|
||||
if not renamed:
|
||||
logger.warning(f"[Renamrr] {media_path} rename failed")
|
||||
logger.warning(f"[Renamer] {media_path} rename failed")
|
||||
# Delete bad torrent.
|
||||
if settings.bangumi_manage.remove_bad_torrent:
|
||||
self.delete_torrent(_hash)
|
||||
|
||||
Reference in New Issue
Block a user