mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-10 05:59:53 +08:00
Fix startup bugs
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import sqlite3
|
||||
|
||||
from .api import router
|
||||
|
||||
from module.models import BangumiData
|
||||
@@ -7,8 +9,11 @@ from module.manager import TorrentManager
|
||||
|
||||
@router.get("/api/v1/bangumi/getAll", tags=["bangumi"], response_model=list[BangumiData])
|
||||
async def get_all_data():
|
||||
with BangumiDatabase() as database:
|
||||
return database.search_all()
|
||||
try:
|
||||
with BangumiDatabase() as database:
|
||||
return database.search_all()
|
||||
except sqlite3.OperationalError:
|
||||
return []
|
||||
|
||||
|
||||
@router.get("/api/v1/bangumi/getData/{bangumi_id}", tags=["bangumi"], response_model=BangumiData)
|
||||
|
||||
@@ -17,6 +17,7 @@ async def get_config():
|
||||
async def update_config(config: Config):
|
||||
try:
|
||||
settings.save(config_dict=config.dict())
|
||||
settings.load()
|
||||
logger.info("Config updated")
|
||||
return {"message": "Success"}
|
||||
except Exception as e:
|
||||
|
||||
@@ -13,7 +13,7 @@ if VERSION != "DEV_VERSION":
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
# HTML Response
|
||||
@router.get("/#/{full_path:path}", response_class=HTMLResponse, tags=["html"])
|
||||
@router.get("/{full_path:path}", response_class=HTMLResponse, tags=["html"])
|
||||
def index(request: Request):
|
||||
context = {"request": request}
|
||||
return templates.TemplateResponse("index.html", context)
|
||||
|
||||
@@ -68,18 +68,20 @@ def stop_thread():
|
||||
|
||||
def start_thread():
|
||||
global rss_thread, rename_thread
|
||||
if not check_status():
|
||||
stop_event.set()
|
||||
return {"status": "start failed"}
|
||||
if stop_event.is_set():
|
||||
stop_event.clear()
|
||||
time.sleep(1)
|
||||
settings.load()
|
||||
if check_status():
|
||||
rss_thread = threading.Thread(target=rss_loop, args=(stop_event,))
|
||||
rename_thread = threading.Thread(target=rename_loop, args=(stop_event,))
|
||||
if settings.rss_parser.enable:
|
||||
rss_thread.start()
|
||||
if settings.bangumi_manage.enable:
|
||||
rename_thread.start()
|
||||
return {"status": "ok"}
|
||||
rss_thread = threading.Thread(target=rss_loop, args=(stop_event,))
|
||||
rename_thread = threading.Thread(target=rename_loop, args=(stop_event,))
|
||||
if settings.rss_parser.enable:
|
||||
rss_thread.start()
|
||||
if settings.bangumi_manage.enable:
|
||||
rename_thread.start()
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
def first_run():
|
||||
|
||||
@@ -17,7 +17,8 @@ class QbDownloader:
|
||||
username=username,
|
||||
password=password,
|
||||
VERIFY_WEBUI_CERTIFICATE=ssl,
|
||||
DISABLE_LOGGING_DEBUG_OUTPUT=True
|
||||
DISABLE_LOGGING_DEBUG_OUTPUT=True,
|
||||
REQUESTS_ARGS={'timeout': (3.1, 10)}
|
||||
)
|
||||
self.host = host
|
||||
self.username = username
|
||||
|
||||
Reference in New Issue
Block a user