Skip to content

Commit

Permalink
[mod] 添加 pandalive 平台支持
Browse files Browse the repository at this point in the history
  • Loading branch information
Borber committed Jan 15, 2023
1 parent 3ca9509 commit 39c08dd
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.9]

### Added

- 添加 pandalive 直播源获取

## [0.1.8]

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "seam"
version = "0.1.8"
version = "0.1.9"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
|[afreeca](https://afreecatv.com/)|`https://bj.afreecatv.com/<RID>` 主播名字而非直播间号|

# 路线
- [x] 改进 CI 自动编译
- [ ] 拆分子模块
- [ ] gui
- [ ] mpv播放
- [ ] 是否一次性链接标识字段

[seam](https://github.com/users/Borber/projects/4/views/1)

# 说明

Expand Down
2 changes: 1 addition & 1 deletion src/declarative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ macro_rules! get_source_url_command {

// 展开宏命令
// 添加新的直播平台可以在括号末尾添加,并在live文件夹里添加对应的文件
get_source_url_command!(Bili, Douyu, Douyin, Huya, Kuaishou, Cc, Huajiao, Yqs, Mht, Afreeca);
get_source_url_command!(Bili, Douyu, Douyin, Huya, Kuaishou, Cc, Huajiao, Yqs, Mht, Afreeca, Panda);
1 change: 1 addition & 0 deletions src/live/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod mht;
pub mod yqs;
pub mod cc;
pub mod afreeca;
pub mod panda;
45 changes: 45 additions & 0 deletions src/live/panda.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use std::collections::HashMap;

use anyhow::{Ok, Result};

const URL: &str = "https://api.pandalive.co.kr/v1/live/play/";

use crate::{
common::CLIENT,
model::{Node, ShowType},
};
/// pandalive
///
/// https://www.pandalive.co.kr/
pub async fn get(rid: &str) -> Result<ShowType> {
let mut form = HashMap::new();
form.insert("action", "watch");
form.insert("userId", rid);
let json: serde_json::Value = CLIENT.post(URL).form(&form).send().await?.json().await?;
match &json["PlayList"] {
serde_json::Value::Null => Ok(ShowType::Off),
list => {
let mut nodes = vec![];
for item in ["hls", "hls2", "hls3", "rtmp"] {
if list.get(item).is_some() {
nodes.push(Node {
rate: "原画".to_string(),
url: list[item][0]["url"].as_str().unwrap().to_string(),
});
}
}
Ok(ShowType::On(nodes))
}
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::util::match_show_type;

#[tokio::test]
async fn test_panda() {
match_show_type(get("wpsl1002").await.unwrap());
}
}

0 comments on commit 39c08dd

Please sign in to comment.