move codegen to separate crate
This commit is contained in:
parent
8548bc81e9
commit
d6cfc7e914
15 changed files with 423 additions and 243 deletions
|
|
@ -65,7 +65,7 @@ impl ClientType {
|
|||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ContextYT {
|
||||
struct ContextYT {
|
||||
client: ClientInfo,
|
||||
/// only used on desktop
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
|||
|
|
@ -563,11 +563,7 @@ fn get_audio_codec(codecs: Vec<&str>) -> AudioCodec {
|
|||
mod tests {
|
||||
use std::{fs::File, io::BufReader, path::Path};
|
||||
|
||||
use crate::{
|
||||
client::{RustyPipe, CLIENT_TYPES},
|
||||
deobfuscate::DeobfData,
|
||||
report::TestFileReporter,
|
||||
};
|
||||
use crate::{client::RustyPipe, deobfuscate::DeobfData};
|
||||
|
||||
use super::*;
|
||||
use rstest::rstest;
|
||||
|
|
@ -581,50 +577,6 @@ mod tests {
|
|||
})
|
||||
});
|
||||
|
||||
#[test_log::test(tokio::test)]
|
||||
async fn download_response_testfiles() {
|
||||
let tf_dir = Path::new("testfiles/player");
|
||||
let video_id = "pPvd8UxmSbQ";
|
||||
|
||||
for client_type in CLIENT_TYPES {
|
||||
let mut json_path = tf_dir.to_path_buf();
|
||||
json_path.push(format!("{:?}_video.json", client_type).to_lowercase());
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let reporter = TestFileReporter::new(json_path);
|
||||
let rp = RustyPipe::new(None, Some(Box::new(reporter)), None);
|
||||
rp.test_query()
|
||||
.report(true)
|
||||
.get_player(video_id, client_type)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test_log::test(tokio::test)]
|
||||
async fn download_model_testfiles() {
|
||||
let tf_dir = Path::new("testfiles/player_model");
|
||||
let rp = RustyPipe::new_test();
|
||||
|
||||
for (name, id) in [("multilanguage", "tVWWp1PqDus"), ("hdr", "LXb3EKWsInQ")] {
|
||||
let mut json_path = tf_dir.to_path_buf();
|
||||
json_path.push(format!("{}.json", name).to_lowercase());
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let player_data = rp
|
||||
.test_query()
|
||||
.get_player(id, ClientType::Desktop)
|
||||
.await
|
||||
.unwrap();
|
||||
let file = File::create(json_path).unwrap();
|
||||
serde_json::to_writer_pretty(file, &player_data).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case::desktop("desktop")]
|
||||
#[case::desktop_music("desktopmusic")]
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ mod tests {
|
|||
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::{client::RustyPipe, report::TestFileReporter};
|
||||
use crate::client::RustyPipe;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
@ -355,27 +355,6 @@ mod tests {
|
|||
assert!(!playlist.thumbnails.is_empty());
|
||||
}
|
||||
|
||||
#[test_log::test(tokio::test)]
|
||||
async fn download_testfiles() {
|
||||
let tf_dir = Path::new("testfiles/playlist");
|
||||
|
||||
for (name, id) in [
|
||||
("short", "RDCLAK5uy_kFQXdnqMaQCVx2wpUM4ZfbsGCDibZtkJk"),
|
||||
("long", "PL5dDx681T4bR7ZF1IuWzOv1omlRbE7PiJ"),
|
||||
("nomusic", "PL1J-6JOckZtE_P9Xx8D3b2O6w0idhuKBe"),
|
||||
] {
|
||||
let mut json_path = tf_dir.to_path_buf();
|
||||
json_path.push(format!("playlist_{}.json", name));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let reporter = TestFileReporter::new(json_path);
|
||||
let rp = RustyPipe::new(None, Some(Box::new(reporter)), None);
|
||||
rp.test_query().report(true).get_playlist(id).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case::short("short", "RDCLAK5uy_kFQXdnqMaQCVx2wpUM4ZfbsGCDibZtkJk")]
|
||||
#[case::long("long", "PL5dDx681T4bR7ZF1IuWzOv1omlRbE7PiJ")]
|
||||
|
|
|
|||
Reference in a new issue