diff --git a/src/module/conf/config.py b/src/module/conf/config.py index 24a3d39a..90503783 100644 --- a/src/module/conf/config.py +++ b/src/module/conf/config.py @@ -42,7 +42,7 @@ class Settings(Config): if not config_dict: config_dict = self.dict() with open(CONFIG_PATH, "w", encoding="utf-8") as f: - json.dump(config_dict, f, indent=4) + json.dump(config_dict, f, indent=4, ensure_ascii=False) def init(self): load_dotenv(".env") diff --git a/src/module/database/user.py b/src/module/database/user.py index 22a97020..76dcade4 100644 --- a/src/module/database/user.py +++ b/src/module/database/user.py @@ -49,7 +49,7 @@ class AuthDB(DataConnector): ) result = self._cursor.fetchone() if not result: - raise HTTPException(status_code=404, detail="User not found") + raise HTTPException(status_code=401, detail="User not found") if not verify_password(password, result[1]): raise HTTPException(status_code=401, detail="Password error") return True diff --git a/src/module/downloader/path.py b/src/module/downloader/path.py index de4b9348..e0ed8043 100644 --- a/src/module/downloader/path.py +++ b/src/module/downloader/path.py @@ -13,8 +13,8 @@ logger = logging.getLogger(__name__) class TorrentPath: - def __init__(self, download_path: str = settings.downloader.path): - self.download_path = download_path + def __init__(self): + pass @staticmethod def check_files(info): @@ -29,10 +29,11 @@ class TorrentPath: subtitle_list.append(file_name) return media_list, subtitle_list - def _path_to_bangumi(self, save_path): + @staticmethod + def _path_to_bangumi(save_path): # Split save path and download path save_parts = save_path.split(path.sep) - download_parts = self.download_path.split(path.sep) + download_parts = settings.downloader.path.split(path.sep) # Get bangumi name and season bangumi_name = "" season = 1 @@ -50,11 +51,12 @@ class TorrentPath: def is_ep(self, file_path): return self._file_depth(file_path) <= 2 - def _gen_save_path(self, data: BangumiData): + @staticmethod + def _gen_save_path(data: BangumiData): folder = ( f"{data.official_title} ({data.year})" if data.year else data.official_title ) - save_path = path.join(self.download_path, folder, f"Season {data.season}") + save_path = path.join(settings.downloader.path, folder, f"Season {data.season}") return save_path @staticmethod diff --git a/src/module/manager/collector.py b/src/module/manager/collector.py index ec8d260b..7350108a 100644 --- a/src/module/manager/collector.py +++ b/src/module/manager/collector.py @@ -32,9 +32,10 @@ class SeasonCollector(DownloadClient): torrents = st.search_season(data) else: torrents = st.get_torrents(link, _filter="|".join(data.filter)) + torrent_files = None if proxy: torrent_files = [st.get_content(torrent.torrent_link) for torrent in torrents] - return self.add_season_torrents(data, torrents, torrent_files=torrent_files) + return self.add_season_torrents(data=data, torrents=torrents, torrent_files=torrent_files) def subscribe_season(self, data: BangumiData): with BangumiDatabase() as db: diff --git a/src/module/security/api.py b/src/module/security/api.py index 13069b72..14282171 100644 --- a/src/module/security/api.py +++ b/src/module/security/api.py @@ -6,7 +6,6 @@ from .jwt import verify_token from module.database.user import AuthDB from module.models.user import User - oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/v1/auth/login") @@ -50,8 +49,4 @@ def update_user_info(user_data: User, current_user): def auth_user(username, password): with AuthDB() as db: - if not db.auth_user(username, password): - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail="invalid username or password", - ) + db.auth_user(username, password)