diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx
index 9f1bfb4..8309257 100644
--- a/app/dashboard/page.tsx
+++ b/app/dashboard/page.tsx
@@ -431,9 +431,9 @@ bilibili支持 mp4 mkv webm 无需筛选也能上传
twitch_cookie获取方式:在浏览器中打开Twitch.tv,F12调出控制台,在控制台中执行:
- document.cookie.split("; ").find(item={'>'}item.startsWith("auth-token="))?.split("=")[1]
+ {`document.cookie.split("; ").find(item={'>'}item.startsWith("auth-token="))?.split("=")[1]`}
- twitch_cookie需要在downloader= "ffmpeg"时候才会生效
+ twitch_cookie需要在downloader= "ffmpeg"时候才会生效
}
label="twitch_cookie"
diff --git a/app/ui/Player.tsx b/app/ui/Player.tsx
index 3c3f502..9b2efb4 100644
--- a/app/ui/Player.tsx
+++ b/app/ui/Player.tsx
@@ -18,7 +18,7 @@ const Players: React.FC<{url: string}> = ({url}) => {
player?.destroy();
player = null;
};
- }, [])
+ }, [url])
return
;
}
diff --git a/app/ui/TemplateFields.tsx b/app/ui/TemplateFields.tsx
index a5d86ce..8ce4c39 100644
--- a/app/ui/TemplateFields.tsx
+++ b/app/ui/TemplateFields.tsx
@@ -53,7 +53,7 @@ const TemplateFields: React.FC = ({ formState, formApi, values }) =
简介:{'\u007B'}streamer{'\u007D'}主播直播间地址:{'\u007B'}url{'\u007D'} 【@credit】
- 其中的"@credits"会依次替换为下面输入的@
+ 其中的"@credits"会依次替换为下面输入的@
} onClick={add} theme="light">
添加行
diff --git a/app/ui/TemplateModal.tsx b/app/ui/TemplateModal.tsx
index 8b3a5b8..30c692a 100644
--- a/app/ui/TemplateModal.tsx
+++ b/app/ui/TemplateModal.tsx
@@ -212,7 +212,7 @@ const TemplateModal: React.FC = ({ children, entity , onOk})
{({ add, arrayFields }) => (
- 如:"-ss"、"00:00:16",每个参数需单独一行
+ 如:"-ss"、"00:00:16",每个参数需单独一行
} onClick={add} theme="light">
添加行
diff --git a/biliup/web/__init__.py b/biliup/web/__init__.py
index 4a6c001..a23b5e6 100644
--- a/biliup/web/__init__.py
+++ b/biliup/web/__init__.py
@@ -1,5 +1,6 @@
import json
import os
+import pathlib
import aiohttp_cors
import requests
@@ -381,9 +382,17 @@ async def service(args):
if args.static_dir:
app.add_routes([web.static('/', args.static_dir, show_index=False)])
else:
- res = [web.static('/', files('biliup.web').joinpath('public'))]
- for fdir in find_all_folders(files('biliup.web').joinpath('public')):
- res.append(web.static('/'+fdir.replace('\\', '/'), files('biliup.web').joinpath('public/'+fdir)))
+ # res = [web.static('/', files('biliup.web').joinpath('public'))]
+ res = []
+ for fdir in pathlib.Path(files('biliup.web').joinpath('public')).glob('*.html'):
+ fname = fdir.relative_to(files('biliup.web').joinpath('public'))
+ def _copy(fname):
+ async def static_view(request):
+ return web.FileResponse(files('biliup.web').joinpath('public/' + str(fname)))
+ return static_view
+ res.append(web.get('/' + str(fname.with_suffix('')), _copy(fname)))
+ # res.append(web.static('/'+fdir.replace('\\', '/'), files('biliup.web').joinpath('public/'+fdir)))
+ res.append(web.static('/', files('biliup.web').joinpath('public')))
app.add_routes(res)
if args.password:
app.middlewares.append(basic_auth_middleware(('/',), {'biliup': args.password}, ))
@@ -402,6 +411,37 @@ async def service(args):
cors.add(route)
runner = web.AppRunner(app)
+ setup_middlewares(app)
await runner.setup()
site = web.TCPSite(runner, host=args.host, port=args.port)
return runner, site
+
+
+async def handle_404(request):
+ return web.HTTPFound('404')
+
+
+def create_error_middleware(overrides):
+
+ @web.middleware
+ async def error_middleware(request, handler):
+ try:
+ return await handler(request)
+ except web.HTTPException as ex:
+ override = overrides.get(ex.status)
+ if override:
+ return await override(request)
+
+ raise
+ except Exception:
+ request.protocol.logger.exception("Error handling request")
+ return await overrides[500](request)
+
+ return error_middleware
+
+
+def setup_middlewares(app):
+ error_middleware = create_error_middleware({
+ 404: handle_404
+ })
+ app.middlewares.append(error_middleware)
\ No newline at end of file