Skip to content

Commit

Permalink
支持下载protobuf弹幕
Browse files Browse the repository at this point in the history
  • Loading branch information
HFrost0 committed May 3, 2022
1 parent 96a4e68 commit 880aa00
Show file tree
Hide file tree
Showing 12 changed files with 1,309 additions and 89 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## 依赖环境 Environment
1. Python 相关依赖(需要python3.8及以上)
```shell
pip install 'httpx[http2]' rich json5
pip install 'httpx[http2]' rich json5 protobuf
```
2. [FFmpeg](https://ffmpeg.org/contact.html#MailingLists) :一个命令行视频工具,用于合成下载的音频和视频

Expand Down Expand Up @@ -127,7 +127,7 @@ asyncio.run(main())
- [x] 下载视频封面
- [ ] 每日测试(GitHub Action),但目前Github Action不能正常访问b站?
- [x] 支持下载字幕,目前已支持下载json,以及转换成srt格式
- [ ] 支持弹幕下载
- [ ] 支持弹幕下载,目前已支持下载protobuf的的弹幕文件,各位可以在[issue](https://github.com/HFrost0/Lighting-bilibili-download/issues/7)中讨论这个问题
- [ ] 支持直播录播,在`live.py`中有获取m3u8的例子,但已考虑废弃,因为有更多专精的优质仓库解决此问题
### 已知的bug 🤡
* 出现未被正常捕捉的异常后断点重连可能导致视频画面或者音频部分缺失(例如突然拉闸😅)
Expand Down
25 changes: 0 additions & 25 deletions all_test.py

This file was deleted.

5 changes: 3 additions & 2 deletions bili_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
async def main(args):
d = Downloader(videos_dir=args.dir, video_concurrency=args.max_con, sess_data=args.cookie)
if args.method == 'get_series':
await d.get_series(args.key, quality=args.q, image=args.image, subtitle=args.subtitle,
await d.get_series(args.key, quality=args.q, image=args.image, subtitle=args.subtitle, dm=args.dm,
only_audio=args.only_audio)
elif args.method == 'get_video':
await d.get_video(args.key, quality=args.q, image=args.image, subtitle=args.subtitle,
await d.get_video(args.key, quality=args.q, image=args.image, subtitle=args.subtitle, dm=args.dm,
only_audio=args.only_audio)
elif args.method == 'get_up':
await d.get_up_videos(
Expand Down Expand Up @@ -57,6 +57,7 @@ async def main(args):
# todo support in search
parser.add_argument('--image', action='store_true', default=False, help='下载视频封面,暂时仅get_series,get_video时生效')
parser.add_argument('--subtitle', action='store_true', default=False, help='下载srt字幕,暂时仅get_series,get_video时生效')
parser.add_argument('--dm', action='store_true', default=False, help='下载弹幕,暂时仅get_series,get_video时生效')
parser.add_argument('--only_audio', action='store_true', default=False,
help='仅下载音频,下载的音质固定为最高音质,暂时仅get_series,get_video时生效')

Expand Down
18 changes: 18 additions & 0 deletions dm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json
from google.protobuf.json_format import MessageToJson
from .reply_pb2 import DmSegMobileReply
from .view_pb2 import DmWebViewReply


def parse_view(content):
dm_view = DmWebViewReply()
dm_view.ParseFromString(content)
dm_view = json.loads(MessageToJson(dm_view))
return dm_view


def parse_seg(content):
seg = DmSegMobileReply()
seg.ParseFromString(content)
seg = json.loads(MessageToJson(seg))
return seg
Loading

0 comments on commit 880aa00

Please sign in to comment.