| Crates.io | bililive |
| lib.rs | bililive |
| version | 0.2.0-beta.5 |
| created_at | 2021-09-25 14:26:37.711249+00 |
| updated_at | 2022-03-10 16:58:24.927216+00 |
| description | A simple stream-based bilibili live client library. |
| homepage | |
| repository | https://github.com/PhotonQuantum/bililive-rs |
| max_upload_size | |
| id | 456201 |
| size | 89,424 |
A simple stream-based bilibili live client library backed by async-tungstenite.
To use with your project, add the following to your Cargo.toml:
bililive = "0.2.0-beta.1"
Minimum supported rust version: 1.56.0
This crate supports both tokio and async-std runtime.
tokio support is enabled by default. While used on an async-std runtime, change the corresponding dependency in
Cargo.toml to
bililive = { version = "0.2.0-beta.1", default-features = false, features = ["async-native-tls"] }
See Crates Features section for more.
Stream/Sink interface.Zlib payloads automatically.use bililive::connect::tokio::connect_with_retry;
use bililive::{ConfigBuilder, RetryConfig};
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);
}
}
}
tokio-native-tls(default): Enables tokio support with TLS implemented
via tokio-native-tls.tokio-rustls-native-certs: Enables tokio support with TLS implemented
via tokio-rustls and uses native system certificates found
with rustls-native-certs.tokio-rustls-webpki-roots: Enables tokio support with TLS implemented
via tokio-rustls and uses the
certificates webpki-roots provides.async-native-tls: Enables async_std support with TLS implemented
via async-native-tls.