mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-07-17 12:11:14 +08:00
refactor: change downloader action,
This commit is contained in:
@@ -129,10 +129,11 @@ class BangumiDatabase:
|
||||
i += 1
|
||||
return torrent_list
|
||||
|
||||
def match_torrent(self, torrent_name: str) -> Optional[Bangumi]:
|
||||
def match_torrent(self, torrent_name: str, rss_link: str) -> Optional[Bangumi]:
|
||||
statement = select(Bangumi).where(
|
||||
and_(
|
||||
func.instr(torrent_name, Bangumi.title_raw) > 0,
|
||||
func.instr(Bangumi.rss_link, rss_link),
|
||||
# use `false()` to avoid E712 checking
|
||||
# see: https://docs.astral.sh/ruff/rules/true-false-comparison/
|
||||
Bangumi.deleted == false(),
|
||||
|
||||
@@ -17,7 +17,7 @@ class QbDownloader:
|
||||
data={"username": self.username, "password": self.password},
|
||||
timeout=5,
|
||||
)
|
||||
return resp.text
|
||||
return resp.text == "Ok."
|
||||
|
||||
async def logout(self):
|
||||
logout_api = "/api/v2/auth/logout"
|
||||
@@ -131,17 +131,7 @@ class QbDownloader:
|
||||
self._client = httpx.AsyncClient(
|
||||
base_url=self.host,
|
||||
)
|
||||
try:
|
||||
authed = await self.auth()
|
||||
if not authed == "Ok.":
|
||||
logger.error("[Downloader] Failed authing to qbittorrent.")
|
||||
logger.warning("[Downloader] Please check username/password in settings.")
|
||||
raise RuntimeError(authed)
|
||||
return self
|
||||
except httpx.ReadTimeout:
|
||||
logger.error("[Downloader] Failed connecting to qbittorrent.")
|
||||
logger.warning("[Downloader] Please check host in settings.")
|
||||
raise RuntimeError("Failed connecting to qbittorrent.")
|
||||
return self
|
||||
|
||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||
await self.logout()
|
||||
|
||||
Reference in New Issue
Block a user