From 3070a4011b6d8f7cdc3292ddb0de216f68ab2d2e Mon Sep 17 00:00:00 2001 From: XuanRan_Nyan <31968665+xxxxuanran@users.noreply.github.com> Date: Fri, 7 Feb 2025 20:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E4=BC=BC=E5=A4=87=E6=B3=A8=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E8=B7=B3=E8=BF=87=E8=87=AA=E8=BA=AB=EF=BC=9B=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E7=94=A8=E6=88=B7=E6=A8=A1=E6=9D=BF=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=B9=8B=E6=95=B0=E6=8D=AE=20(#1157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 相似备注检查跳过自身;格式化用户模板提交之数据 * fix * 更新配置文件模板 --- app/ui/TemplateModal.tsx | 6 ++++++ biliup/handler.py | 10 +++++++++- biliup/web/__init__.py | 27 ++++++++++++++++++--------- public/config.toml | 3 ++- public/config.yaml | 3 +++ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/ui/TemplateModal.tsx b/app/ui/TemplateModal.tsx index eb70e30..66a29e8 100644 --- a/app/ui/TemplateModal.tsx +++ b/app/ui/TemplateModal.tsx @@ -73,6 +73,12 @@ const TemplateModal: React.FC = ({ children, entity, onOk }) } const handleOk = async () => { let values = await api.current?.validate() + values = { + ...values, + remark: values?.remark?.trim(), + url: values?.url?.trim(), + format: values?.format?.trim(), + } await onOk(values) setVisible(false) } diff --git a/biliup/handler.py b/biliup/handler.py index 19a580b..f5c2591 100644 --- a/biliup/handler.py +++ b/biliup/handler.py @@ -154,7 +154,15 @@ def uploaded(name, live_cover_path, data: List): file_list.append(i.danmaku) for post_processor in post_processor: - if post_processor == 'rm': + if ( # 兼容新WEB字段 + isinstance(post_processor, str) + and + post_processor == 'rm' + ) or ( + isinstance(post_processor, dict) + and + post_processor.get('rm') + ): # 删除封面 if live_cover_path is not None: UploadBase.remove_file(live_cover_path) diff --git a/biliup/web/__init__.py b/biliup/web/__init__.py index 531b536..675724e 100644 --- a/biliup/web/__init__.py +++ b/biliup/web/__init__.py @@ -6,6 +6,7 @@ import pathlib import concurrent.futures import threading +import copy import aiohttp_cors import requests import stream_gears @@ -136,15 +137,19 @@ async def cookie_login(request): def check_similar_remark(json_data): ''' - :return: True if similar remark exists + :return: similar remark or None ''' - for fname in config['streamers'].keys(): + _cache = copy.deepcopy(config['streamers']) + for fname, data in _cache.items(): if ( - json_data['remark'] in fname or + json_data['remark'] in fname + or fname in json_data['remark'] + ) and ( + json_data['url'] != data['url'] ): - return True - return False + return fname + return None @routes.get('/v1/get_qrcode') async def qrcode_get(request): @@ -256,8 +261,10 @@ async def streamers(request): async def add_lives(request): from biliup.app import context json_data = await request.json() - if check_similar_remark(json_data): - return web.HTTPBadRequest(text=f"{json_data['remark']} 与现存备注存在部分重复,禁止添加") + similar_remark = check_similar_remark(json_data) + if similar_remark: + return web.HTTPBadRequest(text= + f"{json_data['remark']} 与现存备注 {similar_remark} 存在部分重复,禁止添加") uid = json_data.get('upload_id') with SessionLocal() as db: if uid: @@ -289,8 +296,10 @@ async def lives(request): old_url = old.url # 如果备注修改,才需要检查是否与现存备注存在部分重复 if json_data['remark'] != old.remark: - if check_similar_remark(json_data): - return web.HTTPBadRequest(text=f"{json_data['remark']} 与现存备注存在部分重复,禁止修改") + similar_remark = check_similar_remark(json_data) + if similar_remark: + return web.HTTPBadRequest(text= + f"{json_data['remark']} 与现存备注 {similar_remark} 存在部分重复,禁止修改") uid = json_data.get('upload_id') # semi-ui 不能直接为 ArrayField 设置空默认值 # 当前端更新后,应移除这里的数据修改 diff --git a/public/config.toml b/public/config.toml index 91ce98d..a4f4e79 100644 --- a/public/config.toml +++ b/public/config.toml @@ -253,7 +253,8 @@ tags = ["biliup", "视频标签"] ### ffmpeg参数 #opt_args = [ "-ss", "00:00:16" # 跳过开始的16秒 ] - +[streamers."星际2INnoVation吕布卫星人族天梯第一视角".override] ## 覆盖全局配置 +downloader = "sync-downloader" ################### 用户cookie ################### ### 在使用下方配置时,请确认下方第一行([user])取消了注释。 diff --git a/public/config.yaml b/public/config.yaml index 9bfb90b..4e2b5ae 100644 --- a/public/config.yaml +++ b/public/config.yaml @@ -242,6 +242,9 @@ streamers: #opt_args: ### ffmpeg参数 # - '-ss' # - '00:00:16' # 跳过开始的16秒 + override: # 覆盖全局配置 + downloader: 'sync-downloader' + bili_qn: 30000