上传修改 (#910)

使上传转载来源生效
修复手动上传时未填写转载来源无默认值
This commit is contained in:
⁢4.435km/s authored and GitHub committed 2024-05-04 12:44:32 +00:00
1 parent a9de10e338
commit cc66587d2d
7 files changed
+22 -13

No files matched your search

+1 -1
View File
@@ -69,7 +69,7 @@ export interface StudioEntity {
template_name: string;
user_cookie: string;
copyright: number;
source: string;
copyright_source: string;
tid: number;
cover_path: string;
title: string;
+8 -3
View File
@@ -123,12 +123,17 @@ const TemplateFields: React.FC<FormFCChild> = ({ formState, formApi, values }) =
label='类型'
direction='vertical'
initValue={formApi.getValue('copyright') || 2}
extraText={
<div style={{fontSize: 14}}>
如不填写转载来源默认为直播间地址
</div>
}
>
<Radio value={2} style={{alignItems: 'center', flexShrink: 0}}>
<Radio value={2} style={{alignItems: 'center', flexShrink: 0}} >
<span style={{flexShrink: 0}}>转载</span>
<Input field='source' onClick={()=>formApi.setValue('copyright', 2)} placeholder="转载视频请注明来源(例:转自http://www.xx.com/yy)注明来源会更快地通过审核哦" noLabel fieldStyle={{padding: 0, marginLeft: 24, width: 560}}/>
<Input field='copyright_source' onClick={()=>formApi.setValue('copyright', 2)} placeholder="转载视频请注明来源(例:转自http://www.xx.com/yy)注明来源会更快地通过审核哦" noLabel fieldStyle={{padding: 0, marginLeft: 24, width: 560}} />
</Radio>
<div onClick={()=>formApi.setValue('source', '')}>
<div onClick={()=>formApi.setValue('copyright_source', '')}>
<Radio value={1}>自制</Radio>
</div>
</RadioGroup>
+1 -1
View File
@@ -47,7 +47,7 @@ export default function Add() {
user_cookie: values.user_cookie,
copyright: values.copyright,
id: values.id,
source: values.source ?? '',
copyright_source: values.copyright_source ?? '',
tid: values.tid[1],
cover_path: values.cover_path ?? '',
title: values.title ?? '',
+1 -1
View File
@@ -60,7 +60,7 @@ const Edit = () => {
user_cookie: values?.user_cookie,
copyright: values?.copyright,
id: values?.id,
source: values?.source ?? '',
copyright_source: values?.copyright_source ?? '',
tid: values?.tid[1],
cover_path: values?.cover_path ?? '',
title: values?.title ?? '',
+2 -1
View File
@@ -111,7 +111,8 @@ class UploadStreamers(BaseModel):
title: Mapped[str] = mapped_column(
nullable=True) # 自定义标题的时间格式, {title}代表当场直播间标题 {streamer}代表在本config里面设置的主播名称 {url}代表设置的该主播的第一条直播间链接
tid: Mapped[int] = mapped_column(nullable=True) # 投稿分区码,171为电子竞技分区
copyright: Mapped[int] = mapped_column(nullable=True) # 1为自制
copyright: Mapped[int] = mapped_column(nullable=True) # 1为自制 2转载
copyright_source: Mapped[str] = mapped_column(nullable=True) # 转载来源
cover_path: Mapped[str] = mapped_column(nullable=True) # 封面路径
# 支持strftime, {title}, {streamer}, {url}占位符。
description = mapped_column(TEXT(), nullable=True) # 视频简介
+5 -4
View File
@@ -13,8 +13,8 @@ class BiliWeb(UploadBase):
def __init__(
self, principal, data, submit_api=None, copyright=2, postprocessor=None, dtime=None,
dynamic='', lines='AUTO', threads=3, tid=122, tags=None, cover_path=None, description='',
dolby=0, hires=0, no_reprint=0, open_elec=0, credits=[],
user_cookie='cookies.json'
dolby=0, hires=0, no_reprint=0, open_elec=0, credits=None,
user_cookie='cookies.json', copyright_source=None
):
super().__init__(principal, data, persistence_path='bili.cookie', postprocessor=postprocessor)
if tags is None:
@@ -33,7 +33,7 @@ class BiliWeb(UploadBase):
else:
self.cover_path = None
self.desc = description
self.credits = credits
self.credits = credits if credits else []
self.dynamic = dynamic
self.copyright = copyright
self.dtime = dtime
@@ -42,6 +42,7 @@ class BiliWeb(UploadBase):
self.no_reprint = no_reprint
self.open_elec = open_elec
self.user_cookie = user_cookie
self.copyright_source = copyright_source
def upload(self, file_list: List[UploadBase.FileInfo]) -> List[UploadBase.FileInfo]:
if self.credits:
@@ -63,7 +64,7 @@ class BiliWeb(UploadBase):
"tid": self.tid,
"tag": ','.join(self.tags),
"copyright": self.copyright,
"source": self.data["url"] if self.copyright == 2 else "",
"source": self.copyright_source if self.copyright_source else self.data["url"],
"desc": self.desc,
"dynamic": self.dynamic,
"cover": self.cover_path if self.cover_path is not None else "",
+4 -2
View File
@@ -13,7 +13,7 @@ class BiliWeb(UploadBase):
self, principal, data, submit_api=None, copyright=2, postprocessor=None, dtime=None,
dynamic='', lines='AUTO', threads=3, tid=122, tags=None, cover_path=None, description='',
dolby=0, hires=0, no_reprint=0, open_elec=0, credits=None,
user_cookie='cookies.json'
user_cookie='cookies.json', copyright_source=None
):
super().__init__(principal, data, persistence_path='bili.cookie', postprocessor=postprocessor)
if credits is None:
@@ -41,6 +41,7 @@ class BiliWeb(UploadBase):
self.no_reprint = no_reprint
self.open_elec = open_elec
self.user_cookie = user_cookie
self.copyright_source = copyright_source
def upload(self, file_list) -> List[UploadBase.FileInfo]:
line = None
@@ -65,7 +66,8 @@ class BiliWeb(UploadBase):
"biz_id": "",
"type": 1
}]
source = self.data["url"] if self.copyright == 2 else ""
source = self.copyright_source if self.copyright_source else "https://github.com/biliup/biliup"
cover = self.cover_path if self.cover_path is not None else ""
dtime = None
if self.dtime: