Skip to content

Commit

Permalink
Merge pull request #299 from EstrellaXD/3.0-dev
Browse files Browse the repository at this point in the history
3.0.3
  • Loading branch information
EstrellaXD authored Jun 4, 2023
2 parents 3c760f9 + 50cd912 commit e8a7da7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/module/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def save(self, config_dict: dict | None = None):
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")
Expand Down
2 changes: 1 addition & 1 deletion src/module/database/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def auth_user(self, username, password) -> bool:
)
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
Expand Down
14 changes: 8 additions & 6 deletions src/module/downloader/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


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):
Expand All @@ -29,10 +29,11 @@ def check_files(info):
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
Expand All @@ -50,11 +51,12 @@ def _file_depth(file_path):
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
Expand Down
3 changes: 2 additions & 1 deletion src/module/manager/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def collect_season(self, data: BangumiData, link: str = None, proxy: bool = Fals
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:
Expand Down
7 changes: 1 addition & 6 deletions src/module/security/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from module.database.user import AuthDB
from module.models.user import User


oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/v1/auth/login")


Expand Down Expand Up @@ -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)

0 comments on commit e8a7da7

Please sign in to comment.