Merge pull request #299 from EstrellaXD/3.0-dev

3.0.3
This commit is contained in:
Estrella Pan
2023-06-04 23:04:06 +08:00
committed by GitHub
5 changed files with 13 additions and 15 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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)