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

Commit a268593

Browse files
authored
feat: add video dict (#48)
1 parent 38af302 commit a268593

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

bilitool/controller/feed_controller.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ def print_video_info(self, vid: str):
1616
video_info = self.bili_video_list.get_video_info(bvid)
1717
extracted_info = self.bili_video_list.extract_video_info(video_info)
1818
self.bili_video_list.print_video_info(extracted_info)
19+
20+
def get_video_dict_info(self, size: int = 20, status_type: str = 'pubed,not_pubed,is_pubing'):
21+
return self.bili_video_list.get_video_dict_info(size, status_type)

bilitool/controller/upload_controller.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,24 @@ def publish_video(self, file):
8080
if publish_video_response['code'] == 0:
8181
bvid = publish_video_response['data']['bvid']
8282
self.logger.info(f'upload success!\tbvid:{bvid}')
83+
return True
8384
else:
8485
self.logger.error(publish_video_response['message'])
86+
return False
8587
# reset the video title
8688
Model().reset_upload_config()
8789

88-
def append_video_entry(self, video_path, bvid):
90+
def append_video_entry(self, video_path, bvid, video_name=None):
8991
bilibili_filename = self.upload_video(video_path)
90-
video_name = Path(video_path).name.strip(".mp4")
92+
video_name = video_name if video_name else Path(video_path).name.strip(".mp4")
9193
video_data = self.bili_uploader.get_video_list_info(bvid)
9294
response = self.bili_uploader.append_video(bilibili_filename, video_name, video_data)
9395
if response['code'] == 0:
9496
self.logger.info(f'append {video_name} to {bvid} success!')
97+
return True
9598
else:
9699
self.logger.error(response['message'])
100+
return False
97101
# reset the video title
98102
Model().reset_upload_config()
99103

@@ -107,5 +111,5 @@ def upload_video_entry(self, video_path, yaml, copyright, tid, title, desc, tag,
107111
desc, tag, source, cover, dynamic
108112
)
109113
Model().update_multiple_config('upload', upload_metadata)
110-
self.publish_video(video_path)
114+
return self.publish_video(video_path)
111115

bilitool/feed/bili_video_list.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ def print_video_list_info(self, size: int = 20, status_type: str = 'pubed,not_pu
6565
info += f" | {' | '.join(extra_info)}"
6666
print(info)
6767

68+
def get_video_dict_info(self, size: int = 20, status_type: str = 'pubed,not_pubed,is_pubing'):
69+
video_data = self.get_bili_video_list(size, status_type)
70+
data = dict()
71+
for item in video_data['items']:
72+
data[item['title']] = item['bvid']
73+
return data
74+
6875
def get_video_info(self, bvid: str) -> dict:
6976
"""Get the video info of the bvid"""
7077
url = f"https://api.bilibili.com/x/web-interface/view?bvid={bvid}"

bilitool/upload/bili_upload.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,6 @@ def append_video(self, bilibili_filename, video_name, data):
289289
'desc': "",
290290
}
291291
data['videos'].append(video_to_be_appended)
292-
print(data)
293-
print(type(data))
294292
headers = {
295293
'Connection': 'keep-alive',
296294
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)