8 个版本
0.1.0-beta.8 | 2022年3月10日 |
---|---|
0.1.0-beta.7 | 2021年12月24日 |
0.1.0-beta.5 | 2021年11月23日 |
0.1.0-beta.1 | 2021年10月31日 |
#4 in #danmaku
61KB
1.5K SLoC
actix-bililive
为 Actix 生态系统提供的一个简单的基于流的 bilibili 直播客户端库。
最低支持的 Rust 版本:1.56.0
运行时支持
此软件包支持 actix-rt
(单线程 tokio
)运行时。
功能
- 人体工程学
Stream
/Sink
接口。 - 通过提供的直播房间 ID 容易建立连接。
- 自动处理心跳包。
- 连接失败时自动重试(可选)。
- 自动解压缩
Zlib
有效载荷。
示例
use actix_bililive::{ConfigBuilder, RetryConfig, connect_with_retry};
use futures::StreamExt;
use log::info;
use serde_json::Value;
let config = ConfigBuilder::new()
.by_uid(1602085)
.await
.unwrap()
.fetch_conf()
.await
.unwrap()
.build();
let mut stream = connect_with_retry(config, RetryConfig::default()).await.unwrap();
while let Some(e) = stream.next().await {
match e {
Ok(packet) => {
info!("raw: {:?}", packet);
if let Ok(json) = packet.json::<Value>() {
info!("json: {:?}", json);
}
}
Err(e) => {
info!("err: {:?}", e);
}
}
}
依赖
~15–26MB
~465K SLoC