-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ pub mod mht; | |
pub mod yqs; | ||
pub mod cc; | ||
pub mod afreeca; | ||
pub mod panda; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |