Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit 106e06e

Browse files
authored
fix: remove lines (#46)
* fix: remove lines * fix: add reset function
1 parent 85083d5 commit 106e06e

8 files changed

Lines changed: 39 additions & 41 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ LoginController().logout_bilibili()
183183
LoginController().check_bilibili_login()
184184

185185
# 上传
186-
UploadController().upload_video_entry(video_path: str, yaml: str, line: str, copyright: int, tid: int, title: str, desc: str, tag: str, source: str, cover: str, dynamic: str)
186+
UploadController().upload_video_entry(video_path: str, yaml: str, copyright: int, tid: int, title: str, desc: str, tag: str, source: str, cover: str, dynamic: str)
187187

188188
# 追加投稿(分p)
189189
UploadController().append_video_entry(video_path: str, bvid: str)

bilitool/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def cli():
5151
upload_parser.add_argument('--desc', default='', help='(default is empty) The description of video')
5252
upload_parser.add_argument('--tid', type=int, default=138, help='(default is 138) For more info to the type id, refer to https://biliup.github.io/tid-ref.html')
5353
upload_parser.add_argument('--tag', default='bilitool', help='(default is bilitool) Video tags, separated by comma')
54-
upload_parser.add_argument('--line', default='bda2', help='(default is bda2) Line refer to https://biliup.github.io/upload-systems-analysis.html')
5554
upload_parser.add_argument('--source', default='来源于网络', help='(default is 来源于网络) The source of video (if your video is re-print)')
5655
upload_parser.add_argument('--cover', default='', help='(default is empty) The cover of video (if you want to customize, set it as the path to your cover image)')
5756
upload_parser.add_argument('--dynamic', default='', help='(default is empty) The dynamic information')
@@ -109,8 +108,8 @@ def cli():
109108

110109
if args.subcommand == 'upload':
111110
# print(args)
112-
UploadController().upload_video_entry(args.video_path, args.yaml, args.line,
113-
args.copyright, args.tid, args.title, args.desc, args.tag, args.source, args.cover, args.dynamic)
111+
UploadController().upload_video_entry(args.video_path, args.yaml, args.copyright,
112+
args.tid, args.title, args.desc, args.tag, args.source, args.cover, args.dynamic)
114113

115114
if args.subcommand == 'append':
116115
UploadController().append_video_entry(args.video_path, args.vid)

bilitool/controller/upload_controller.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ def __init__(self):
1515
self.bili_uploader = BiliUploader(self.logger)
1616

1717
@staticmethod
18-
def package_upload_metadata(line, copyright, tid, title, desc, tag, source, cover, dynamic):
18+
def package_upload_metadata(copyright, tid, title, desc, tag, source, cover, dynamic):
1919
return {
20-
'line': line,
2120
'copyright': copyright,
2221
'tid': tid,
2322
'title': title,
@@ -84,7 +83,7 @@ def publish_video(self, file):
8483
else:
8584
self.logger.error(publish_video_response['message'])
8685
# reset the video title
87-
Model().update_specific_config("upload", "title", "")
86+
Model().reset_upload_config()
8887

8988
def append_video_entry(self, video_path, bvid):
9089
bilibili_filename = self.upload_video(video_path)
@@ -96,15 +95,15 @@ def append_video_entry(self, video_path, bvid):
9695
else:
9796
self.logger.error(response['message'])
9897
# reset the video title
99-
Model().update_specific_config("upload", "title", "")
98+
Model().reset_upload_config()
10099

101-
def upload_video_entry(self, video_path, yaml, line, copyright, tid, title, desc, tag, source, cover, dynamic):
100+
def upload_video_entry(self, video_path, yaml, copyright, tid, title, desc, tag, source, cover, dynamic):
102101
if yaml:
103102
# * is used to unpack the tuple
104103
upload_metadata = self.package_upload_metadata(*parse_yaml(yaml))
105104
else:
106105
upload_metadata = self.package_upload_metadata(
107-
line, copyright, tid, title,
106+
copyright, tid, title,
108107
desc, tag, source, cover, dynamic
109108
)
110109
Model().update_multiple_config('upload', upload_metadata)

bilitool/model/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"sid": ""
1212
},
1313
"upload": {
14-
"line": "bda2",
1514
"copyright": 2,
1615
"title": "",
1716
"desc": "",

bilitool/model/model.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def __init__(self, path=None) -> None:
4242
"desc": "",
4343
"tid": 138,
4444
"tag": "bilitool",
45-
"line": "bda2",
4645
"source": "\u6765\u6e90\u4e8e\u4e92\u8054\u7f51",
4746
"cover": "",
4847
"dynamic": ""
@@ -90,6 +89,18 @@ def update_multiple_config(self, action, updates: dict):
9089
config_info[action][key] = value
9190
self.write(config_info)
9291

92+
def reset_upload_config(self):
93+
config_info = self.get_config()
94+
config_info['upload']['copyright'] = 2
95+
config_info['upload']['title'] = ""
96+
config_info['upload']['desc'] = ""
97+
config_info['upload']['tid'] = 138
98+
config_info['upload']['tag'] = "bilitool"
99+
config_info['upload']['source'] = "\u6765\u6e90\u4e8e\u4e92\u8054\u7f51"
100+
config_info['upload']['cover'] = ""
101+
config_info['upload']['dynamic'] = ""
102+
self.write(config_info)
103+
93104
def reset_cookies(self):
94105
config_info = self.get_config()
95106
config_info['cookies']['access_key'] = ""

bilitool/utils/parse_yaml.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ def parse_yaml(yaml_path):
66
with open(yaml_path, 'r', encoding='utf-8') as file:
77
data = yaml.safe_load(file)
88

9-
# Extracting the required values
10-
line = data.get('line')
11-
streamers = data.get('streamers', {})
12-
139
# Assuming there's only one streamer entry
14-
for streamer_path, streamer_info in streamers.items():
15-
copyright = streamer_info.get('copyright')
16-
tid = streamer_info.get('tid')
17-
title = streamer_info.get('title')
18-
desc = streamer_info.get('desc')
19-
tag = streamer_info.get('tag')
20-
source = streamer_info.get('source')
21-
cover = streamer_info.get('cover')
22-
dynamic = streamer_info.get('dynamic')
23-
return line, copyright, tid, title, desc, tag, source, cover, dynamic
10+
copyright = data.get('copyright')
11+
tid = data.get('tid')
12+
title = data.get('title')
13+
desc = data.get('desc')
14+
tag = data.get('tag')
15+
source = data.get('source')
16+
cover = data.get('cover')
17+
dynamic = data.get('dynamic')
18+
return copyright, tid, title, desc, tag, source, cover, dynamic
2419

2520
if __name__ == '__main__':
2621
res = parse_yaml('')

docs/upload.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
`bilitool upload -h ` 打印帮助信息:
66

77
```bash
8-
usage: bilitool upload [-h] [-y YAML] [--copyright COPYRIGHT] [--title TITLE] [--desc DESC] [--tid TID] [--tag TAG] [--line LINE] [--source SOURCE] [--cover COVER]
8+
usage: bilitool upload [-h] [-y YAML] [--copyright COPYRIGHT] [--title TITLE] [--desc DESC] [--tid TID] [--tag TAG] [--source SOURCE] [--cover COVER]
99
[--dynamic DYNAMIC]
1010
video_path
1111

@@ -21,7 +21,6 @@ options:
2121
--desc DESC (default is empty) The description of video
2222
--tid TID (default is 138) For more info to the type id, refer to https://biliup.github.io/tid-ref.html
2323
--tag TAG (default is bilitool) video tags, separated by comma
24-
--line LINE (default is bda2) line refer to https://biliup.github.io/upload-systems-analysis.html
2524
--source SOURCE (default is 来源于网络) The source of video (if your video is re-print)
2625
--cover COVER (default is empty) The cover of video (if you want to customize, set it as the path to your cover image)
2726
--dynamic DYNAMIC (default is empty) The dynamic information
@@ -36,7 +35,7 @@ options:
3635
bilitool upload /path/to/your/video.mp4
3736

3837
# 使用命令行参数上传视频
39-
bilitool upload /path/to/your/video.mp4 --title "test" --desc "test" --tid 138 --tag "test" --line bda2
38+
bilitool upload /path/to/your/video.mp4 --title "test" --desc "test" --tid 138 --tag "test"
4039

4140
# 使用 yaml 配置上传视频
4241
bilitool upload /path/to/your/video.mp4 -y /path/to/your/upload/template.yaml

template/example-config.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
line: bda2 # the cdn upload line(don't change this)
2-
limit: 5 # the limit of video upload threads
3-
streamers:
4-
patterns-example: # the pattern matching(WIP, you can ignore this field and just leave it as this example)
5-
copyright: 1 # the copyright of video (1 for original, 2 for reprint)
6-
source: https://live.bilibili.com/xxxxxxxx # the source of video (required if your video is re-print)
7-
title: "your video title"
8-
desc: "your video description"
9-
tid: 138 # the type id of video
10-
tag: "your, video, tags" # the tags of video, separated by comma
11-
cover: '' # the cover of video (if you want to customize, set it as the path to your cover image)
12-
dynamic: '' # the dynamic information of video
1+
copyright: 1 # the copyright of video (1 for original, 2 for reprint)
2+
source: https://live.bilibili.com/xxxxxxxx # the source of video (required if your video is re-print)
3+
title: "your video title"
4+
desc: "your video description"
5+
tid: 138 # the type id of video
6+
tag: "your, video, tags" # the tags of video, separated by comma
7+
cover: '' # the cover of video (if you want to customize, set it as the path to your cover image)
8+
dynamic: '' # the dynamic information of video

0 commit comments

Comments
 (0)