mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-14 18:41:04 +08:00
2.5.6 增加控制 AB 的 API 选项
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import re
|
||||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
@@ -23,6 +25,33 @@ app = FastAPI()
|
||||
# context = {"request": request}
|
||||
# return templates.TemplateResponse("index.html", context)
|
||||
|
||||
@app.get("/api/v1/data")
|
||||
def get_data():
|
||||
data = json_config.load(settings.info_path)
|
||||
return data
|
||||
|
||||
|
||||
@app.get("/api/v1/resetRule")
|
||||
def reset_rule():
|
||||
data = {}
|
||||
json_config.save(settings.info_path, data)
|
||||
return "Success"
|
||||
|
||||
|
||||
class RuleName(BaseModel):
|
||||
name: str
|
||||
|
||||
|
||||
@app.post("/api/v1/removeRule")
|
||||
def remove_rule(name: RuleName):
|
||||
datas = json_config.load(settings.info_path)["bangumi_info"]
|
||||
for data in datas:
|
||||
if re.search(name.name, data["raw_title"]) is not None:
|
||||
datas.remove(data)
|
||||
json_config.save(settings.info_path, datas)
|
||||
return "Success"
|
||||
return "Not matched"
|
||||
|
||||
|
||||
class Config(BaseModel):
|
||||
rss_link: str
|
||||
@@ -92,9 +121,8 @@ class AddRule(BaseModel):
|
||||
season: int
|
||||
|
||||
|
||||
@app.post("/api/v1/addrule")
|
||||
@app.post("/api/v1/addRule")
|
||||
async def add_rule(info: AddRule):
|
||||
|
||||
return "success"
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ def load_data_file():
|
||||
def save_data_file(bangumi_data):
|
||||
info_path = settings.info_path
|
||||
json_config.save(info_path, bangumi_data)
|
||||
logger.debug("Saved")
|
||||
|
||||
|
||||
def show_info():
|
||||
|
||||
@@ -165,5 +165,5 @@ class RawParser:
|
||||
|
||||
if __name__ == "__main__":
|
||||
test = RawParser()
|
||||
ep = test.analyse("[Nekomoe kissaten][Summer Time Rendering - 11 [1080p][JPTC].mp4")
|
||||
ep = test.analyse("[Lilith-Raws] 神渣☆偶像 / Kami Kuzu☆Idol - 01 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]")
|
||||
print(ep.title, ep.dpi)
|
||||
|
||||
@@ -54,7 +54,7 @@ class TitleParser:
|
||||
if __name__ == '__main__':
|
||||
import re
|
||||
T = TitleParser()
|
||||
raw = "[dasdas]sadasdsa S01 - 07[dasdasdas]"
|
||||
raw = "[Lilith-Raws] 神渣☆偶像 / Kami Kuzu☆Idol - 01 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]"
|
||||
season = int(re.search(r"\d{1,2}", "S02").group())
|
||||
title = T.download_parser(raw, "asdad", season)
|
||||
print(season,title)
|
||||
title = T.raw_parser(raw)
|
||||
print(season,title.title)
|
||||
Reference in New Issue
Block a user