mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-01 05:51:27 +08:00
Fix API bugs
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import FileResponse, Response
|
||||
|
||||
@@ -24,13 +26,23 @@ async def startup_event():
|
||||
|
||||
@router.get("/api/v1/data")
|
||||
async def get_data():
|
||||
data = json_config.load(DATA_PATH)
|
||||
return data
|
||||
try:
|
||||
data = json_config.load(DATA_PATH)
|
||||
return data
|
||||
except FileNotFoundError:
|
||||
return {
|
||||
"rss_link": "",
|
||||
"data_version": settings.data_version,
|
||||
"bangumi_info": [],
|
||||
}
|
||||
|
||||
|
||||
@router.get("/api/v1/log")
|
||||
async def get_log():
|
||||
return FileResponse(LOG_PATH)
|
||||
if os.path.isfile(LOG_PATH):
|
||||
return FileResponse(LOG_PATH)
|
||||
else:
|
||||
return Response("Log file not found", status_code=404)
|
||||
|
||||
|
||||
@router.get("/api/v1/resetRule")
|
||||
|
||||
@@ -82,7 +82,7 @@ def run():
|
||||
download_client.init_downloader()
|
||||
if settings.rss_parser.token in ["", "token", None]:
|
||||
logger.error("Please set your RSS token in config file.")
|
||||
exit(0)
|
||||
exit(1)
|
||||
download_client.rss_feed()
|
||||
bangumi_data = load_data_file()
|
||||
# 主程序循环
|
||||
|
||||
Reference in New Issue
Block a user