8000 fix: remove lines by timerring · Pull Request #46 · timerring/bilitool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: remove lines #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ LoginController().logout_bilibili()
LoginController().check_bilibili_login()

# 上传
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)
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)

# 追加投稿(分p)
UploadController().append_video_entry(video_path: str, bvid: str)
Expand Down
5 changes: 2 additions & 3 deletions bilitool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def cli():
upload_parser.add_argument('--desc', default='', help='(default is empty) The description of video')
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')
upload_parser.add_argument('--tag', default='bilitool', help='(default is bilitool) Video tags, separated by comma')
upload_parser.add_argument('--line', default='bda2', help='(default is bda2) Line refer to https://biliup.github.io/upload-systems-analysis.html')
upload_parser.add_argument('--source', default='来源于网络', help='(default is 来源于网络) The source of video (if your video is re-print)')
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)')
upload_parser.add_argument('--dynamic', default='', help='(default is empty) The dynamic information')
Expand Down Expand Up @@ -109,8 +108,8 @@ def cli():

if args.subcommand == 'upload':
# print(args)
UploadController().upload_video_entry(args.video_path, args.yaml, args.line,
args.copyright, args.tid, args.title, args.desc, args.tag, args.source, args.cover, args.dynamic)
UploadController().upload_video_entry(args.video_path, args.yaml, args.copyright,
args.tid, args.title, args.desc, args.tag, args.source, args.cover, args.dynamic)

if args.subcommand == 'append':
UploadController().append_video_entry(args.video_path, args.vid)
Expand Down
11 changes: 5 additions & 6 deletions bilitool/controller/upload_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def __init__(self):
self.bili_uploader = BiliUploader(self.logger)

@staticmethod
def package_upload_metadata(line, copyright, tid, title, desc, tag, source, cover, dynamic):
def package_upload_metadata(copyright, tid, title, desc, tag, source, cover, dynamic):
return {
'line': line,
'copyright': copyright,
'tid': tid,
'title': title,
Expand Down Expand Up @@ -84,7 +83,7 @@ def publish_video(self, file):
else:
self.logger.error(publish_video_response['message'])
# reset the video title
Model().update_specific_config("upload", "title", "")
Model().reset_upload_config()

def append_video_entry(self, video_path, bvid):
bilibili_filename = self.upload_video(video_path)
Expand All @@ -96,15 +95,15 @@ def append_video_entry(self, video_path, bvid):
else:
self.logger.error(response['message'])
# reset the video title
Model().update_specific_config("upload", "title", "")
Model().reset_upload_config()

def upload_video_entry(self, video_path, yaml, line, copyright, tid, title, desc, tag, source, cover, dynamic):
def upload_video_entry(self, video_path, yaml, copyright, tid, title, desc, tag, source, cover, dynamic):
if yaml:
# * is used to unpack the tuple
upload_metadata = self.package_upload_metadata(*parse_yaml(yaml))
else:
upload_metadata = self.package_upload_metadata(
line, copyright, tid, title,
copyright, tid, title,
desc, tag, source, cover, dynamic
)
Model().update_multiple_config('upload', upload_metadata)
Expand Down
1 change: 0 additions & 1 deletion bilitool/model/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"sid": ""
},
"upload": {
"line": "bda2",
"copyright": 2,
"title": "",
"desc": "",
Expand Down
13 changes: 12 additions & 1 deletion bilitool/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(self, path=None) -> None:
"desc": "",
"tid": 138,
"tag": "bilitool",
"line": "bda2",
"source": "\u6765\u6e90\u4e8e\u4e92\u8054\u7f51",
"cover": "",
"dynamic": ""
Expand Down Expand Up @@ -90,6 +89,18 @@ def update_multiple_config(self, action, updates: dict):
config_info[action][key] = value
self.write(config_info)

def reset_upload_config(self):
config_info = self.get_config()
config_info['upload']['copyright'] = 2
config_info['upload']['title'] = ""
config_info['upload']['desc'] = ""
config_info['upload']['tid'] = 138
config_info['upload']['tag'] = "bilitool"
config_info['upload']['source'] = "\u6765\u6e90\u4e8e\u4e92\u8054\u7f51"
config_info['upload']['cover'] = ""
config_info['upload']['dynamic'] = ""
self.write(config_info)

def reset_cookies(self):
config_info = self.get_config()
config_info['cookies']['access_key'] = ""
Expand Down
23 changes: 9 additions & 14 deletions bilitool/utils/parse_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@ def parse_yaml(yaml_path):
with open(yaml_path, 'r', encoding='utf-8') as file:
data = yaml.safe_load(file)

# Extracting the required values
line = data.get('line')
streamers = data.get('streamers', {})

# Assuming there's only one streamer entry
for streamer_path, streamer_info in streamers.items():
copyright = streamer_info.get('copyright')
tid = streamer_info.get('tid')
title = streamer_info.get('title')
desc = streamer_info.get('desc')
tag = streamer_info.get('tag')
source = streamer_info.get('source')
cover = streamer_info.get('cover')
dynamic = streamer_info.get('dynamic')
return line, copyright, tid, title, desc, tag, source, cover, dynamic
copyright = data.get('copyright')
tid = data.get('tid')
title = data.get('title')
desc = data.get('desc')
tag = data.get('tag')
source = data.get('source')
cover = data.get('cover')
dynamic = data.get('dynamic')
return copyright, tid, title, desc, tag, source, cover, dynamic

if __name__ == '__main__':
res = parse_yaml('')
Expand Down
5 changes: 2 additions & 3 deletions docs/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
`bilitool upload -h ` 打印帮助信息:

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

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

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

# 使用 yaml 配置上传视频
bilitool upload /path/to/your/video.mp4 -y /path/to/your/upload/template.yaml
Expand Down
20 changes: 8 additions & 12 deletions template/example-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
line: bda2 # the cdn upload line(don't change this)
limit: 5 # the limit of video upload threads
streamers:
patterns-example: # the pattern matching(WIP, you can ignore this field and just leave it as this example)
copyright: 1 # the copyright of video (1 for original, 2 for reprint)
source: https://live.bilibili.com/xxxxxxxx # the source of video (required if your video is re-print)
title: "your video title"
desc: "your video description"
tid: 138 # the type id of video
tag: "your, video, tags" # the tags of video, separated by comma
cover: '' # the cover of video (if you want to customize, set it as the path to your cover image)
dynamic: '' # the dynamic information of video
copyright: 1 # the copyright of video (1 for original, 2 for reprint)
source: https://live.bilibili.com/xxxxxxxx # the source of video (required if your video is re-print)
title: "your video title"
desc: "your video description"
tid: 138 # the type id of video
tag: "your, video, tags" # the tags of video, separated by comma
cover: '' # the cover of video (if you want to customize, set it as the path to your cover image)
dynamic: '' # the dynamic information of video
0