diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 4f9a577..c044dd3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install setuptools wheel twine build npm install - name: Build and publish env: diff --git a/biliup/__init__.py b/biliup/__init__.py index 9822db4..31f5ca4 100644 --- a/biliup/__init__.py +++ b/biliup/__init__.py @@ -1,7 +1,7 @@ import logging import sys -__version__ = "0.2.11" +__version__ = "0.2.12" LOG_CONF = { 'version': 1, diff --git a/biliup/__main__.py b/biliup/__main__.py index 87be91e..905e82d 100644 --- a/biliup/__main__.py +++ b/biliup/__main__.py @@ -20,7 +20,8 @@ def arg_parser(): parser.add_argument('-H', help='web api host [default: localhost]', dest='host') parser.add_argument('-P', help='web api port [default: 19159]', default=19159, dest='port') parser.add_argument('--http', action='store_true', help='enable web api') - parser.add_argument('--password',help='web ui password ,default username is biliup', dest='password') + parser.add_argument('--static-dir', help='web static files directory for custom ui') + parser.add_argument('--password', help='web ui password ,default username is biliup', dest='password') parser.add_argument('-v', '--verbose', action="store_const", const=logging.DEBUG, help="Increase output verbosity") parser.add_argument('--config', type=argparse.FileType(encoding='UTF-8'), help='Location of the configuration file (default "./config.yaml")') @@ -34,7 +35,7 @@ def arg_parser(): parser_restart.set_defaults(func=daemon.restart) parser.set_defaults(func=lambda: asyncio.run(main(args))) args = parser.parse_args() - if(args.http): + if args.http: config.create_without_config_input(args.config) else: config.load(args.config) @@ -48,7 +49,6 @@ def arg_parser(): args.func() - async def main(args): from .handler import CHECK_UPLOAD, CHECK, event_manager diff --git a/biliup/web/__init__.py b/biliup/web/__init__.py index 99b8f2f..15b5e3d 100644 --- a/biliup/web/__init__.py +++ b/biliup/web/__init__.py @@ -80,8 +80,11 @@ async def service(args, event_manager): app.add_routes([web.post('/api/setconfig', set_streamer_config)]) app.add_routes([web.get('/api/save', save_config)]) app.add_routes([web.get('/', root_handler)]) - app.add_routes([web.static('/', files('biliup.web').joinpath('public'), show_index=False)]) - app.add_routes([web.static('/build', files('biliup.web').joinpath('public/build'), show_index=False)]) + if args.static_dir: + app.add_routes([web.static('/', args.static_dir, show_index=False)]) + else: + app.add_routes([web.static('/', files('biliup.web').joinpath('public'), show_index=False)]) + app.add_routes([web.static('/build', files('biliup.web').joinpath('public/build'), show_index=False)]) if args.password: app.middlewares.append(basic_auth_middleware(('/',), {'biliup': args.password}, )) cors = aiohttp_cors.setup(app, defaults={ diff --git a/src/Sidebar.svelte b/src/Sidebar.svelte index 713c486..93149b4 100644 --- a/src/Sidebar.svelte +++ b/src/Sidebar.svelte @@ -86,6 +86,32 @@ body:JSON.stringify(ret_json) }) } + let urlStatus; + let streamStatus = {}; + fetch('/url-status',{ + method: "GET", + }).then(res => res.json()) + .then(status => { + urlStatus = status; + console.log(urlStatus); + console.log($template); + statusToColor(); + }) + + function statusToColor() { + for (const item of items) { + streamStatus[item] = 'green'; + for (const url of $template[item].url) { + if (urlStatus[url] === 1) { + streamStatus[item] = 'red'; + } + if (urlStatus[url] === 2) { + streamStatus[item] = 'yellow'; + } + } + } + } +