Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/4t145/bilibili-client
bilibili api rust实现/bilibili 独轮车/直播工具
https://github.com/4t145/bilibili-client
bilibili bilibili-api bilibili-live bilibli-download bilibli-login rust
Last synced: about 2 months ago
JSON representation
bilibili api rust实现/bilibili 独轮车/直播工具
- Host: GitHub
- URL: https://github.com/4t145/bilibili-client
- Owner: 4t145
- Created: 2022-08-26T19:52:38.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-02T17:39:42.000Z (about 1 year ago)
- Last Synced: 2024-04-20T09:01:29.596Z (9 months ago)
- Topics: bilibili, bilibili-api, bilibili-live, bilibli-download, bilibli-login, rust
- Language: Rust
- Homepage:
- Size: 398 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# BILIBILI-CLIENT
在rust中使用blibili api,using bilibili api in rust本项目还在快速迭代中, this project is still working in progress
## 使用 USAGE
## 使用nightly版本(将会在rust 1.75版本后稳定)
```bash
rustup override set nightly
```
### 例程
在`cargo.toml`加入
```toml
[dependencies.bilibili-client]
git = "https://github.com/4t145/bilibili-client"
branch = "master"
```在 `main.rs` 中
```rust
#![feature(async_fn_in_trait)]#[tokio::main]
async fn main() {
let jar = Arc::new(cookie::Jar::default());
let client = Client::new(jar.clone());
if let Ok(login_info) = fs::read_to_string(&config_file).await {
let login_info = toml::from_str(&login_info).expect("cannot parse cookie");
client.set_login_info(&login_info);
} else {
let loginer = FileLogin::new("qr.svg");
let login = client
.qr_login(loginer)
.await
.expect("fail to login");
println!("login: {:?}", login);
let login_info = client.get_login_info_from_cookie();
let mut cookie_file = fs::File::create(config_file).await.expect("fail to save");
cookie_file.write_all(toml::to_string(&login_info).expect("cant save cookie as toml file").as_bytes()).await.expect("fail to write cookie to file");
}
let cookie = client.get_login_info_from_cookie();
println!("cookie: {:?}", cookie);
let request = RoomPlayUrlRequest::new(851181).platform(StreamPlatform::H5).qn(StreamQuality::BlueLight);
let play_url = client.get_room_play_url(&request).await.unwrap();
dbg!(&play_url);
}```
[这个例程的完整版](./examples/reqwest-client/main.rs)