mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-13 18:11:03 +08:00
fix: #285, rss_feed 添加逻辑,启动逻辑
This commit is contained in:
Submodule docs/wiki updated: 4311a8def4...519e381e8a
@@ -54,8 +54,8 @@ async def get_search_result(searchstr: str):
|
||||
|
||||
|
||||
@router.get("/RSS/Bangumi", tags=["proxy"])
|
||||
async def get_bangumi(bangumiId: str, groupid: str):
|
||||
full_path = "Bangumi?bangumiId=" + bangumiId + "&groupid=" + groupid
|
||||
async def get_bangumi(bangumiId: str, subgroupid: str):
|
||||
full_path = "Bangumi?bangumiId=" + bangumiId + "&subgroupid=" + subgroupid
|
||||
content = get_rss_content(full_path)
|
||||
return Response(content, media_type="application/xml")
|
||||
|
||||
|
||||
@@ -9,14 +9,16 @@ class Checker:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def check_renamer(self) -> bool:
|
||||
if self.check_downloader() and settings.bangumi_manage.enable:
|
||||
@staticmethod
|
||||
def check_renamer() -> bool:
|
||||
if settings.bangumi_manage.enable:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def check_analyser(self) -> bool:
|
||||
if self.check_downloader() and settings.rss_parser.enable:
|
||||
@staticmethod
|
||||
def check_analyser() -> bool:
|
||||
if settings.rss_parser.enable:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -31,7 +31,6 @@ class Program(RenameThread, RSSThread):
|
||||
"Legacy data detected, starting data migration, please wait patiently."
|
||||
)
|
||||
data_migration()
|
||||
add_rss_feed()
|
||||
self.start()
|
||||
|
||||
def start(self):
|
||||
@@ -39,12 +38,16 @@ class Program(RenameThread, RSSThread):
|
||||
return {"status": "Not ready to start."}
|
||||
self.stop_event.clear()
|
||||
settings.load()
|
||||
if self.enable_renamer:
|
||||
self.rename_start()
|
||||
if self.enable_rss:
|
||||
self.rss_start()
|
||||
logger.info("Program running.")
|
||||
return {"status": "Program started."}
|
||||
if self.downloader_status:
|
||||
if self.enable_renamer:
|
||||
self.rename_start()
|
||||
if self.enable_rss:
|
||||
add_rss_feed()
|
||||
self.rss_start()
|
||||
logger.info("Program running.")
|
||||
return {"status": "Program started."}
|
||||
else:
|
||||
return {"status": "Can't connect to downloader. Program not paused."}
|
||||
|
||||
def stop(self):
|
||||
if self.is_running:
|
||||
|
||||
@@ -9,7 +9,6 @@ from qbittorrentapi.exceptions import (
|
||||
)
|
||||
|
||||
from module.ab_decorator import qb_connect_failed_wait
|
||||
from module.downloader.exceptions import ConflictError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -27,9 +26,9 @@ class QbDownloader:
|
||||
self.host = host
|
||||
self.username = username
|
||||
|
||||
def auth(self):
|
||||
def auth(self, retry=3):
|
||||
times = 0
|
||||
while times < 3:
|
||||
while times < retry:
|
||||
try:
|
||||
self._client.auth_log_in()
|
||||
return True
|
||||
@@ -46,7 +45,8 @@ class QbDownloader:
|
||||
except APIConnectionError:
|
||||
logger.error(f"Cannot connect to qBittorrent Server")
|
||||
logger.info(f"Please check the IP and port in WebUI settings")
|
||||
time.sleep(30)
|
||||
time.sleep(10)
|
||||
times += 1
|
||||
except Exception as e:
|
||||
logger.error(f"Unknown error: {e}")
|
||||
break
|
||||
@@ -55,6 +55,16 @@ class QbDownloader:
|
||||
def logout(self):
|
||||
self._client.auth_log_out()
|
||||
|
||||
def check_host(self):
|
||||
try:
|
||||
self._client.app_version()
|
||||
return True
|
||||
except APIConnectionError:
|
||||
return False
|
||||
|
||||
def check_rss(self, rss_link: str):
|
||||
pass
|
||||
|
||||
@qb_connect_failed_wait
|
||||
def prefs_init(self, prefs):
|
||||
return self._client.app_set_preferences(prefs=prefs)
|
||||
|
||||
@@ -33,6 +33,8 @@ class DownloadClient(TorrentPath):
|
||||
def __enter__(self):
|
||||
if not self.authed:
|
||||
self.auth()
|
||||
else:
|
||||
logger.error("[Downloader] Already authed.")
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
@@ -42,7 +44,13 @@ class DownloadClient(TorrentPath):
|
||||
|
||||
def auth(self):
|
||||
self.authed = self.client.auth()
|
||||
logger.debug("Authed.")
|
||||
if self.authed:
|
||||
logger.info("[Downloader] Authed.")
|
||||
else:
|
||||
logger.error("[Downloader] Auth failed.")
|
||||
|
||||
def check_host(self):
|
||||
return self.client.check_host()
|
||||
|
||||
def init_downloader(self):
|
||||
prefs = {
|
||||
|
||||
Reference in New Issue
Block a user