From 0d156ff28033985340280cf5b137dd466a416941 Mon Sep 17 00:00:00 2001 From: ForgQi <34411314+ForgQi@users.noreply.github.com> Date: Wed, 17 Apr 2024 23:33:36 +0800 Subject: [PATCH] Bumping version --- README.md | 2 -- app/lib/api-streamer.ts | 6 ++---- biliup/__init__.py | 2 +- biliup/common/tools.py | 20 +++++++++++++++++++ biliup/database/__init__.py | 2 +- biliup/engine/download.py | 6 ++++-- biliup/handler.py | 19 ++++-------------- biliup/web/__init__.py | 8 -------- .../docs/getting-started/introduction.md | 2 +- docs/content/docs/guide/CHANGELOG.md | 11 ++++++++++ docs/content/docs/guide/introduction.md | 2 +- 11 files changed, 45 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 08e6fa0..9755794 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,6 @@ Twitch,YY直播等,并于录制结束后自动上传到哔哩哔哩视频网 **更新日志**:[CHANGELOG.md](https://biliup.github.io/biliup/docs/guide/changelog) -**文档地址**:[DOCS.md](https://biliup.github.io/biliup/docs/guide/introduction/) - **社区教程**: [图文教程](https://www.bilibili.com/read/cv33195912) by [@ikun1993](https://github.com/ikun1993) ## Quick Start diff --git a/app/lib/api-streamer.ts b/app/lib/api-streamer.ts index 8b519c5..7b19888 100644 --- a/app/lib/api-streamer.ts +++ b/app/lib/api-streamer.ts @@ -2,8 +2,6 @@ // The extra argument will be passed via the `arg` property of the 2nd parameter. // In the example below, `arg` will be `'my_token'` export async function sendRequest(url: string, { arg }: {arg: T}) { - console.log(JSON.stringify(arg)); - const res = await fetch((process.env.NEXT_PUBLIC_API_SERVER ?? '') + url, { method: 'POST', headers: { @@ -38,7 +36,7 @@ export const proxy = async (input: RequestInfo | URL, init?: RequestInit | undef } export async function requestDelete(url: string, { arg }: {arg: T}) { - const res = await fetch(`${(process.env.NEXT_PUBLIC_API_SERVER ?? '')}${url}/${arg}`, { + const res = await fetch(`${process.env.NEXT_PUBLIC_API_SERVER ?? ''}${url}/${arg}`, { method: 'DELETE', }) if (!res.ok) { @@ -48,7 +46,7 @@ export async function requestDelete(url: string, { arg }: {arg: T}) { } export async function put(url: string, { arg }: {arg: T}) { - const res = await fetch(`${(process.env.NEXT_PUBLIC_API_SERVER ?? '')}${url}`, { + const res = await fetch(`${process.env.NEXT_PUBLIC_API_SERVER ?? ''}${url}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' diff --git a/biliup/__init__.py b/biliup/__init__.py index 9b0c06a..d11d145 100644 --- a/biliup/__init__.py +++ b/biliup/__init__.py @@ -2,7 +2,7 @@ import logging import platform import sys -__version__ = "0.4.50" +__version__ = "0.4.51" LOG_CONF = { 'version': 1, diff --git a/biliup/common/tools.py b/biliup/common/tools.py index 1597827..bd4d729 100644 --- a/biliup/common/tools.py +++ b/biliup/common/tools.py @@ -1,3 +1,9 @@ +import logging +import subprocess + +logger = logging.getLogger('biliup') + + class NamedLock: """ 简单实现的命名锁 @@ -52,3 +58,17 @@ def get_file_create_timestamp(file: str) -> float: pass return stat_result.st_mtime + + +def processor(processors, data): + for process in processors: + if process.get('run'): + try: + process_output = subprocess.check_output( + process['run'], shell=True, + input=data, + stderr=subprocess.STDOUT, text=True) + logger.info(process_output.rstrip()) + except subprocess.CalledProcessError as e: + logger.exception(e.output) + continue diff --git a/biliup/database/__init__.py b/biliup/database/__init__.py index 09baf1b..d73b7c6 100644 --- a/biliup/database/__init__.py +++ b/biliup/database/__init__.py @@ -1 +1 @@ -# from .db import DB # noqa: F401 \ No newline at end of file +# from .db import DB # noqa: F401 diff --git a/biliup/engine/download.py b/biliup/engine/download.py index 6e01b57..2cb781d 100644 --- a/biliup/engine/download.py +++ b/biliup/engine/download.py @@ -5,6 +5,7 @@ import subprocess import sys import time import shutil +from abc import ABC, abstractmethod from typing import Generator, List from urllib.parse import urlparse @@ -21,7 +22,7 @@ from biliup.config import config logger = logging.getLogger('biliup') -class DownloadBase: +class DownloadBase(ABC): def __init__(self, fname, url, suffix=None, opt_args=None): self.danmaku = None self.room_title = None @@ -80,6 +81,7 @@ class DownloadBase: self.default_output_args += \ ['-fs', f"{config.get('file_size', '2621440000')}"] + @abstractmethod def check_stream(self, is_check=False): # is_check 是否是检测可以避免在检测是否可以录制的时候忽略一些耗时的操作 logger.debug(self.fname, is_check) @@ -245,7 +247,7 @@ class DownloadBase: try: segment_processor = config['streamers'].get(self.fname, {}).get('segment_processor') if segment_processor: - from biliup.handler import processor + from biliup.common.tools import processor from multiprocessing import Process from biliup.database.db import get_file_list with SessionLocal() as db: diff --git a/biliup/handler.py b/biliup/handler.py index 4c7a4ea..f920f32 100644 --- a/biliup/handler.py +++ b/biliup/handler.py @@ -10,7 +10,7 @@ from typing import List from biliup.config import config from .app import event_manager, context -from .common.tools import NamedLock +from .common.tools import NamedLock, processor from .database.db import get_stream_info_by_filename, SessionLocal from .downloader import download from .engine.event import Event @@ -72,6 +72,7 @@ def pre_processor(name, url): }, ensure_ascii=False)) yield Event(DOWNLOAD, (name, url)) + @event_manager.register(DOWNLOAD, block='Asynchronous1') def process(name, url): url_status = context['PluginInfo'].url_status @@ -96,6 +97,7 @@ def process(name, url): # 下载结束 url_status[url] = 0 + @event_manager.register(DOWNLOADED, block='Asynchronous1') def processed(stream_info): name = stream_info['name'] @@ -144,6 +146,7 @@ def process_upload(stream_info): with NamedLock(f'upload_count_{url}'): url_upload_count[url] -= 1 + def uploaded(name, live_cover_path, data: List): # data = file_list post_processor = config['streamers'].get(name, {}).get("postprocessor", None) @@ -188,17 +191,3 @@ def uploaded(name, live_cover_path, data: List): except subprocess.CalledProcessError as e: logger.exception(e.output) continue - - -def processor(processors, data): - for processor in processors: - if processor.get('run'): - try: - process_output = subprocess.check_output( - processor['run'], shell=True, - input=data, - stderr=subprocess.STDOUT, text=True) - logger.info(process_output.rstrip()) - except subprocess.CalledProcessError as e: - logger.exception(e.output) - continue diff --git a/biliup/web/__init__.py b/biliup/web/__init__.py index e28795a..c1535d7 100644 --- a/biliup/web/__init__.py +++ b/biliup/web/__init__.py @@ -545,7 +545,6 @@ async def service(args): res.append(web.get('/' + str(fname.with_suffix('')).replace('\\', '/'), _copy(fname))) # res.append(web.static('/'+fdir.replace('\\', '/'), files('biliup.web').joinpath('public/'+fdir))) - print(res) res.append(web.static('/', files('biliup.web').joinpath('public'))) app.add_routes(res) if args.password: @@ -576,13 +575,6 @@ async def service(args): return runner -# @web.middleware -# async def get_session(request, handler): -# -# resp = await handler(request) -# return resp - - async def handle_404(request): return web.FileResponse(files('biliup.web').joinpath('public').joinpath('404.html')) diff --git a/docs/content/docs/getting-started/introduction.md b/docs/content/docs/getting-started/introduction.md index 8550ab3..15dce7e 100644 --- a/docs/content/docs/getting-started/introduction.md +++ b/docs/content/docs/getting-started/introduction.md @@ -1,5 +1,5 @@ +++ -title = "Introduction" +title = "说明" description = "AdiDoks is a Zola theme helping you build modern documentation websites, which is a port of the Hugo theme Doks for Zola." date = 2021-05-01T08:00:00+00:00 updated = 2021-05-01T08:00:00+00:00 diff --git a/docs/content/docs/guide/CHANGELOG.md b/docs/content/docs/guide/CHANGELOG.md index 544672b..10fa0b1 100644 --- a/docs/content/docs/guide/CHANGELOG.md +++ b/docs/content/docs/guide/CHANGELOG.md @@ -19,6 +19,17 @@ top = false - 🔧已修复的问题 - ⚠️需要手动操作的更新信息 +## 0.4.50 +### What's Changed +* 修复排序错误 by @xxxxuanran in https://github.com/biliup/biliup/pull/865 +* 修复Youtube在下载完成前的意外错误 by @CoolZxp in https://github.com/biliup/biliup/pull/869 +* 适配FlexTv by @CoolZxp in https://github.com/biliup/biliup/pull/870 +* 避免虎牙在选取码率时发生错误后依旧继续执行 by @CoolZxp in https://github.com/biliup/biliup/pull/871 +* 适配 Twitcasting.TV by @xxxxuanran in https://github.com/biliup/biliup/pull/874 + + +**Full Changelog**: https://github.com/biliup/biliup/compare/v0.4.49...v0.4.50 + ## 0.4.47-0.4.49 ### What's Changed * 修复录播管理页卡片重叠问题 by @alpzmj9 in https://github.com/biliup/biliup/pull/851 diff --git a/docs/content/docs/guide/introduction.md b/docs/content/docs/guide/introduction.md index 8d6a9d9..f940565 100644 --- a/docs/content/docs/guide/introduction.md +++ b/docs/content/docs/guide/introduction.md @@ -1,5 +1,5 @@ +++ -title = "说明" +title = "Introduction" description = "AdiDoks is a Zola theme helping you build modern documentation websites, which is a port of the Hugo theme Doks for Zola." date = 2021-05-01T08:00:00+00:00 updated = 2021-05-01T08:00:00+00:00