mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-13 16:19:48 +08:00
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user