mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-14 18:41:04 +08:00
@@ -5,6 +5,7 @@ import uvicorn
|
||||
from module.api import router
|
||||
from module.conf import settings
|
||||
from module.conf.uvicorn_logging import logging_config
|
||||
from module.core import reset_log
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -13,6 +14,7 @@ logger = logging.getLogger(__name__)
|
||||
if __name__ == "__main__":
|
||||
if not os.path.isdir("data"):
|
||||
os.mkdir("data")
|
||||
reset_log()
|
||||
uvicorn.run(
|
||||
router, host="0.0.0.0", port=settings.program.webui_port,
|
||||
log_config=logging_config,
|
||||
|
||||
@@ -14,7 +14,8 @@ router = FastAPI()
|
||||
@router.get("/api/v1/log", tags=["log"])
|
||||
async def get_log():
|
||||
if os.path.isfile(LOG_PATH):
|
||||
return FileResponse(LOG_PATH)
|
||||
with open(LOG_PATH, "r") as f:
|
||||
return Response(f.read(), media_type="text/plain")
|
||||
else:
|
||||
return Response("Log file not found", status_code=404)
|
||||
|
||||
|
||||
@@ -7,13 +7,18 @@ from module.rss import RSSAnalyser, add_rules
|
||||
from module.manager import Renamer, FullSeasonGet
|
||||
from module.database import BangumiDatabase
|
||||
from module.downloader import DownloadClient
|
||||
from module.conf import settings, VERSION, DATA_PATH
|
||||
from module.conf import settings, VERSION, DATA_PATH, LOG_PATH
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
stop_event = threading.Event()
|
||||
|
||||
|
||||
def reset_log():
|
||||
if os.path.isfile(LOG_PATH):
|
||||
os.remove(LOG_PATH)
|
||||
|
||||
|
||||
def rss_loop(stop_event):
|
||||
rss_analyser = RSSAnalyser()
|
||||
rss_link = settings.rss_link()
|
||||
@@ -71,8 +76,10 @@ def start_thread():
|
||||
settings.load()
|
||||
rss_thread = threading.Thread(target=rss_loop, args=(stop_event,))
|
||||
rename_thread = threading.Thread(target=rename_loop, args=(stop_event,))
|
||||
rss_thread.start()
|
||||
rename_thread.start()
|
||||
if settings.rss_parser.enable:
|
||||
rss_thread.start()
|
||||
if settings.bangumi_manage.enable:
|
||||
rename_thread.start()
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
@@ -87,5 +94,7 @@ def start_program():
|
||||
database.update_table()
|
||||
rss_thread = threading.Thread(target=rss_loop, args=(stop_event,))
|
||||
rename_thread = threading.Thread(target=rename_loop, args=(stop_event,))
|
||||
rss_thread.start()
|
||||
rename_thread.start()
|
||||
if settings.rss_parser.enable:
|
||||
rss_thread.start()
|
||||
if settings.bangumi_manage.enable:
|
||||
rename_thread.start()
|
||||
|
||||
@@ -132,6 +132,7 @@ class Renamer(DownloadClient):
|
||||
torrent_path=subtitle_path,
|
||||
torrent_name=torrent_name,
|
||||
season=season,
|
||||
file_type="subtitle",
|
||||
)
|
||||
new_path = self.gen_path(sub, bangumi_name, method=method)
|
||||
if subtitle_path != new_path:
|
||||
|
||||
@@ -17,8 +17,12 @@ class TitleParser:
|
||||
torrent_path: str,
|
||||
torrent_name: str | None = None,
|
||||
season: int | None = None,
|
||||
file_type: str = "media",
|
||||
):
|
||||
return torrent_parser(torrent_path, torrent_name, season)
|
||||
try:
|
||||
return torrent_parser(torrent_path, torrent_name, season, file_type)
|
||||
except Exception as e:
|
||||
logger.warning(f"Cannot parse {torrent_path} with error {e}")
|
||||
|
||||
@staticmethod
|
||||
def tmdb_parser(title: str, season: int, language: str):
|
||||
|
||||
Reference in New Issue
Block a user