Compare commits
6 Commits
15c6623ed8
...
373ad4e747
| Author | SHA1 | Date | |
|---|---|---|---|
| 373ad4e747 | |||
| b5c6de9c17 | |||
| 69ab1ec4d6 | |||
| eff0a979ec | |||
| c6954372c0 | |||
| e7b0bcbfed |
20
Cargo.lock
generated
20
Cargo.lock
generated
@@ -413,9 +413,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "compio"
|
||||
version = "0.16.1"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6829f76b635c05ef91f97dc44c3b27eb72f346179bd47c5018cd033d913420d"
|
||||
checksum = "a8a7cc183295c36483f1c9616f43c4ac1a9030ce6d9321d6cebb4c4bb21164c4"
|
||||
dependencies = [
|
||||
"compio-buf",
|
||||
"compio-driver",
|
||||
@@ -440,9 +440,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "compio-driver"
|
||||
version = "0.9.2"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f8915a1e560ab8be655c23771502a107d2802941a83fbf142734bed60a11441"
|
||||
checksum = "ff5c12800e82a01d12046ccc29b014e1cbbb2fbe38c52534e0d40d4fc58881d5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
@@ -464,9 +464,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "compio-fs"
|
||||
version = "0.9.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea585c274239b9fd350a484c75a31fd0df5f031805b6664d83a98f5e8b019e2f"
|
||||
checksum = "c568022f90c2e2e8ea7ff4c4e8fde500753b5b9b6b6d870e25b5e656f9ea2892"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
@@ -514,9 +514,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "compio-net"
|
||||
version = "0.9.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e6ea7aa4a9f38d68dd0098a11232236cb3efd0ef3cab50ecdada3d745f1f776"
|
||||
checksum = "bffab78b8a876111ca76450912ca6a5a164b0dd93973e342c5f438a6f478c735"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"compio-buf",
|
||||
@@ -533,9 +533,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "compio-runtime"
|
||||
version = "0.9.5"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b467b43c646a60bae3bb3a55c2c200ea7c4416a63cc5a6070450aa6771b3c62e"
|
||||
checksum = "83fd890a129a8086af857bbe18401689c130aa6ccfc7f3c029a7800f7256af3e"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"cfg-if",
|
||||
|
||||
@@ -20,7 +20,7 @@ serde = { version = "1.0.226", features = ["derive"] }
|
||||
serde_json = "1.0.145"
|
||||
strum = { version = "0.27.2", features = ["derive"] }
|
||||
tokio = { version = "1.47.1", features = ["rt-multi-thread"] }
|
||||
compio = { version = "0.16.0", features = ["runtime"] }
|
||||
compio = { version = "0.17.0", features = ["runtime"] }
|
||||
redb = "3.1.0"
|
||||
crabtime = { git = "https://github.com/wdanilo/crabtime.git", rev = "2ed856f5" }
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#![feature(test)]
|
||||
extern crate test;
|
||||
|
||||
use sdgb_api::title::{MaiVersionExt, Sdgb1_50};
|
||||
|
||||
#[bench]
|
||||
pub fn sdgb_150_enc_short(b: &mut test::Bencher) {
|
||||
b.iter(|| _ = Sdgb1_50::encode(b"Hello world"));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
pub fn sdgb_150_enc_4k(b: &mut test::Bencher) {
|
||||
let data = [1u8; 4096];
|
||||
b.iter(|| _ = Sdgb1_50::encode(data));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
pub fn sdgb_150_dec_4k(b: &mut test::Bencher) {
|
||||
let data = [1u8; 4096];
|
||||
let enc_data = Sdgb1_50::encode(data).unwrap();
|
||||
b.iter(|| _ = Sdgb1_50::decode(enc_data.clone()));
|
||||
}
|
||||
@@ -9,25 +9,7 @@ use flate2::write::{ZlibDecoder, ZlibEncoder};
|
||||
use spdlog::debug;
|
||||
|
||||
use crate::error::ApiError;
|
||||
use crate::title::{MaiVersion, MaiVersionExt, Sdgb1_50, Sdgb1_53};
|
||||
|
||||
impl MaiVersionExt for Sdgb1_50 {
|
||||
fn decode(mut data: impl AsMut<[u8]>) -> Result<Vec<u8>, ApiError> {
|
||||
if data.as_mut().is_empty() {
|
||||
return Err(ApiError::EmptyResponse);
|
||||
}
|
||||
|
||||
debug!("data size: {}", data.as_mut().len());
|
||||
let decrypted = decrypt(&mut data, Self::AES_KEY, Self::AES_IV)?;
|
||||
Ok(decompress(decrypted))
|
||||
}
|
||||
|
||||
fn encode(data: impl AsRef<[u8]>) -> Result<Vec<u8>, ApiError> {
|
||||
let compressed = compress(data)?;
|
||||
let enc = encrypt(compressed, Self::AES_KEY, Self::AES_IV)?;
|
||||
Ok(enc)
|
||||
}
|
||||
}
|
||||
use crate::title::{MaiVersion, MaiVersionExt, Sdgb1_53};
|
||||
|
||||
impl MaiVersionExt for Sdgb1_53 {
|
||||
fn decode(mut data: impl AsMut<[u8]>) -> Result<Vec<u8>, ApiError> {
|
||||
@@ -93,101 +75,3 @@ fn decrypt<'ct>(
|
||||
let result = decryptor.decrypt_padded_mut::<Pkcs7>(data.as_mut())?;
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod _tests {
|
||||
|
||||
use crate::title::{Sdgb1_50, encryption::*};
|
||||
|
||||
#[test]
|
||||
fn test_ping_dec() -> Result<(), ApiError> {
|
||||
let mut data = b"\x72\x5c\xa5\x55\x27\x14\x85\xd1\x64\xc8\x64\x5b\x6e\x5f\xd8\xe3\
|
||||
\x3f\x36\x4c\x9a\x3b\xa5\xb0\x9e\x75\xae\x83\xee\xb3\xb9\x2a\x75"
|
||||
.to_vec();
|
||||
let decoded = Sdgb1_50::decode(&mut data)?;
|
||||
assert_eq!(decoded, b"{\"result\":\"Pong\"}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sdgb_150_dec_enc() -> Result<(), ApiError> {
|
||||
let data = [
|
||||
161, 166, 3, 157, 202, 233, 151, 73, 40, 113, 186, 162, 177, 46, 118, 113, 98, 231, 67,
|
||||
185, 246, 180, 109, 253, 1, 152, 0, 31, 81, 211, 28, 137, 95, 12, 110, 105, 181, 246,
|
||||
177, 1, 45, 59, 182, 113, 56, 97, 56, 100, 34, 168, 27, 51, 228, 77, 192, 194, 248, 45,
|
||||
118, 80, 21, 159, 37, 248, 54, 85, 94, 61, 48, 59, 117, 163, 161, 165, 206, 36, 23, 71,
|
||||
73, 231, 214, 81, 82, 117, 115, 32, 122, 8, 161, 213, 252, 125, 35, 131, 144, 147, 74,
|
||||
27, 138, 26, 133, 240, 73, 197, 25, 173, 213, 237, 216, 76, 101, 210, 202, 172, 216,
|
||||
91, 83, 87, 243, 79, 143, 42, 149, 130, 210, 13, 63, 98, 198, 165, 122, 58, 254, 39,
|
||||
150, 71, 155, 231, 55, 142, 5, 102, 253, 148, 191, 9, 212, 188, 69, 236, 60, 152, 13,
|
||||
40, 111, 219, 162, 160, 34, 150, 211, 85, 190, 176, 137, 60, 25, 228, 218, 163, 240,
|
||||
143, 44, 238, 77, 92, 12, 166, 209, 238, 100, 92, 98, 142, 10, 104, 213, 12, 89, 236,
|
||||
114, 212, 222, 0, 237, 1, 208, 216, 114, 114, 71, 135, 21, 213, 61, 6, 162, 155, 119,
|
||||
143, 70, 83, 136, 136, 136, 251, 94, 137, 244, 26, 125, 15, 132, 207, 60, 57, 105, 78,
|
||||
177, 84, 85, 152, 183, 77, 67, 163, 61, 165, 144, 125, 255, 89, 108, 58, 137, 142, 9,
|
||||
8, 54, 228, 34, 55, 124, 158, 83, 36,
|
||||
];
|
||||
let dec = Sdgb1_50::decode(data)?;
|
||||
assert_eq!(dec, r#"{"userId":10103750,"userName":"舞萌","isLogin":false,"lastGameId":null,"lastRomVersion":"1.01.00","lastDataVersion":"1.05.03","lastLoginDate":"1970-01-01 00:00:00","lastPlayDate":"1970-01-01 00:00:00","playerRating":1024,"nameplateId":0,"iconId":11,"trophyId":0,"isNetMember":1,"isInherit":false,"totalAwake":5,"dispRate":0,"dailyBonusDate":"1970-01-01 09:00:00","headPhoneVolume":null,"banState":0}"#.as_bytes());
|
||||
let enc = Sdgb1_50::encode(dec)?;
|
||||
assert_eq!(enc, data);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_user_data_dec() -> Result<(), ApiError> {
|
||||
let data = [
|
||||
112, 133, 192, 229, 116, 195, 219, 220, 56, 176, 98, 148, 246, 73, 179, 157, 181, 251,
|
||||
9, 7, 190, 113, 101, 8, 144, 58, 23, 196, 16, 176, 78, 96, 106, 53, 191, 118, 86, 247,
|
||||
50, 250, 168, 155, 164, 108, 7, 152, 251, 123, 186, 121, 113, 41, 104, 79, 29, 71, 47,
|
||||
228, 214, 97, 223, 29, 27, 163, 159, 113, 82, 45, 29, 41, 176, 246, 33, 235, 22, 202,
|
||||
1, 61, 133, 126, 8, 20, 9, 214, 153, 11, 203, 207, 5, 195, 129, 172, 70, 81, 58, 156,
|
||||
240, 87, 203, 137, 110, 183, 245, 177, 210, 63, 231, 136, 82, 97, 201, 184, 236, 117,
|
||||
89, 85, 22, 29, 2, 238, 250, 148, 158, 151, 139, 179, 9, 42, 47, 220, 88, 137, 135,
|
||||
139, 57, 35, 0, 50, 123, 133, 103, 15, 87, 86, 208, 203, 235, 153, 214, 87, 236, 46,
|
||||
78, 50, 72, 50, 8, 46, 30, 242, 44, 184, 72, 118, 51, 120, 99, 158, 247, 255, 168, 181,
|
||||
119, 156, 214, 143, 253, 185, 21, 76, 117, 201, 38, 38, 79, 171, 8, 251, 90, 53, 59,
|
||||
89, 30, 136, 69, 168, 57, 34, 115, 145, 159, 110, 182, 5, 126, 208, 202, 216, 92, 200,
|
||||
168, 63, 114, 119, 129, 38, 139, 189, 101, 215, 102, 76, 29, 228, 219, 46, 79, 166,
|
||||
127, 194, 60, 183, 169, 167, 210, 120, 77, 219, 58, 16, 231, 233, 189, 66, 215, 202,
|
||||
28, 209, 59, 192, 141, 91, 65, 17, 187, 88, 189, 149, 139, 48, 237, 152, 161, 87, 120,
|
||||
99, 2, 50, 12, 120, 179, 50, 235, 255, 223, 162, 216, 84, 13, 135, 196, 131, 121, 97,
|
||||
171, 106, 240, 189, 112, 92, 41, 59, 204, 24, 72, 91, 14, 220, 249, 10, 166, 4, 254,
|
||||
183, 194, 227, 53, 163, 35, 165, 253, 149, 83, 253, 191, 138, 236, 208, 146, 242, 31,
|
||||
185, 152, 226, 100, 191, 2, 2, 82, 101, 141, 31, 71, 106, 2, 83, 1, 231, 140, 20, 16,
|
||||
156, 171, 108, 109, 14, 93, 168, 203, 50, 20, 21, 142, 135, 97, 7, 80, 61, 110, 76,
|
||||
152, 106, 231, 100, 78, 187, 28, 39, 191, 10, 206, 78, 127, 79, 247, 192, 164, 51, 237,
|
||||
9, 63, 201, 7, 27, 81, 243, 88, 30, 244, 205, 57, 14, 126, 60, 61, 173, 21, 84, 15,
|
||||
105, 38, 239, 249, 82, 202, 245, 219, 88, 195, 112, 113, 40, 60, 76, 10, 243, 232, 52,
|
||||
27, 0, 84, 247, 85, 140, 99, 140, 165, 145, 140, 96, 55, 0, 174, 155, 241, 166, 252,
|
||||
150, 87, 106, 42, 58, 33, 154, 222, 83, 69, 172, 226, 216, 108, 115, 203, 38, 133, 43,
|
||||
171, 172, 78, 142, 70, 78, 186, 146, 24, 126, 203, 106, 221, 144, 17, 32, 42, 186, 125,
|
||||
134, 186, 174, 214, 137, 212, 234, 202, 79, 241, 28, 222, 98, 83, 76, 254, 90, 210, 12,
|
||||
141, 40, 191, 123, 143, 170, 154, 39, 137, 222, 224, 241, 61, 136, 184, 104, 106, 209,
|
||||
184, 128, 30, 95, 36, 250, 163, 47, 82, 19, 121, 123, 134, 142, 31, 170, 23, 148, 20,
|
||||
80, 157, 252, 103, 192, 204, 229, 10, 66, 84, 49, 21, 197, 110, 208, 202, 124, 217,
|
||||
117, 19, 190, 241, 154, 178, 83, 37, 175, 209, 52, 228, 219, 137, 238, 146, 111, 228,
|
||||
254, 89, 219, 49, 85, 30, 214, 162, 234, 138, 122, 9, 93, 164, 133, 136, 160, 75, 118,
|
||||
87, 14, 170, 92, 109, 244, 40, 234, 40, 216, 72, 207, 81, 161, 252, 252, 0, 38, 206,
|
||||
123, 212, 93, 252, 225, 205, 16, 5, 197, 59, 93, 100, 56, 93, 125, 214, 150, 133, 208,
|
||||
12, 0, 226, 246, 94, 62, 235, 164, 48, 134, 205, 77, 14, 107, 162, 60, 23, 150, 47,
|
||||
198, 5, 214, 125, 12, 150, 63, 128, 95, 237, 209, 55, 5, 11, 59, 187, 0, 254, 180, 226,
|
||||
126, 88, 87, 172, 38, 169, 27, 25, 92, 204, 24, 103, 78, 226, 65, 163, 114, 16, 202,
|
||||
31, 160, 182, 100, 226, 15, 64, 5, 71, 117, 237, 31, 145, 250, 97, 105, 103, 67, 243,
|
||||
2, 208, 60, 72, 16, 199, 57, 170, 99, 151, 62, 100, 53, 23, 45, 123, 225, 170, 149, 65,
|
||||
26, 142, 240, 82, 214, 88, 93, 100, 158, 84, 42, 5, 112, 165, 194, 1, 160, 149, 103,
|
||||
238, 63, 75, 3, 134, 113, 197, 251, 251, 90, 34, 184, 248, 214, 183, 168, 135, 4, 169,
|
||||
134, 194, 106, 83, 108, 176, 26, 159, 80, 143, 105, 111, 53, 4, 1, 240, 44, 240, 149,
|
||||
118, 189, 208, 190, 235, 145, 166, 163, 231, 158, 219, 221, 208, 61, 158, 132, 39, 75,
|
||||
235, 36, 199, 169, 34, 119, 150, 223, 74, 5, 107, 123, 132, 116, 97, 241, 53, 43, 238,
|
||||
115, 189, 195, 124, 127, 172, 5, 109, 112, 149, 190, 19, 202, 253, 171, 53, 105, 123,
|
||||
173, 50, 50, 145, 56, 232, 13, 169, 47, 60, 112, 35, 100, 205, 35, 142, 5, 198, 235,
|
||||
206, 112, 145, 99, 21, 214, 1, 184, 57, 125, 87, 245, 204, 162, 167, 124, 18, 154, 49,
|
||||
25, 144, 181, 58, 184, 212, 59, 252, 72, 167, 228, 60, 118, 113, 65, 50, 150, 235, 163,
|
||||
121, 215, 82, 91, 100, 78, 54, 199, 238, 93, 21, 21, 29, 215, 18, 201, 205, 106, 211,
|
||||
78, 141, 155,
|
||||
];
|
||||
let _ = Sdgb1_50::decode(data)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use nyquest::AsyncClient;
|
||||
use crate::{
|
||||
ApiError,
|
||||
title::{
|
||||
MaiVersionExt as _, Sdgb1_50,
|
||||
MaiVersionExt as _, Sdgb1_53,
|
||||
methods::APIMethod,
|
||||
model::{GetUserMusicApi, GetUserMusicApiResp},
|
||||
},
|
||||
@@ -21,7 +21,7 @@ pub async fn get_user_all_music(
|
||||
next_index,
|
||||
user_music_list: mut new_list,
|
||||
..
|
||||
} = Sdgb1_50::request::<_, GetUserMusicApiResp>(
|
||||
} = Sdgb1_53::request::<_, GetUserMusicApiResp>(
|
||||
&client,
|
||||
APIMethod::GetUserMusicApi,
|
||||
user_id,
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
use crate::title::methods::HasUid;
|
||||
|
||||
#[crabtime::function]
|
||||
fn uid_get_impl(api_names: Vec<String>) {
|
||||
for api_name in api_names {
|
||||
crabtime::output!(
|
||||
impl HasUid for crate::title::model::{{api_name}}Resp {
|
||||
fn get_uid(&self) -> u32 {
|
||||
self.user_id
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
uid_get_impl!([
|
||||
"GetUserDataApi",
|
||||
"GetUserMusicApi",
|
||||
"GetUserPreviewApi",
|
||||
"GetUserRatingApi"
|
||||
]);
|
||||
@@ -53,30 +53,25 @@ pub trait APIExt {
|
||||
type Response: for<'de> Deserialize<'de>;
|
||||
}
|
||||
|
||||
pub trait HasUid {
|
||||
fn get_uid(&self) -> u32;
|
||||
}
|
||||
|
||||
mod api_ext;
|
||||
mod has_uid;
|
||||
pub use api_ext::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod _test {
|
||||
use crate::title::{MaiVersionExt, Sdgb1_50, methods::APIMethod};
|
||||
use crate::title::{MaiVersionExt, Sdgb1_53, methods::APIMethod};
|
||||
|
||||
#[test]
|
||||
fn test_obfuscate_1_50() {
|
||||
assert_eq!(
|
||||
Sdgb1_50::api_hash(APIMethod::Ping),
|
||||
Sdgb1_53::api_hash(APIMethod::Ping),
|
||||
"250b3482854e7697de7d8eb6ea1fabb1"
|
||||
);
|
||||
assert_eq!(
|
||||
Sdgb1_50::api_hash(APIMethod::GetUserPreviewApi),
|
||||
Sdgb1_53::api_hash(APIMethod::GetUserPreviewApi),
|
||||
"004cf848f96d393a5f2720101e30b93d"
|
||||
);
|
||||
assert_eq!(
|
||||
Sdgb1_50::api_hash(APIMethod::GetUserDataApi),
|
||||
Sdgb1_53::api_hash(APIMethod::GetUserDataApi),
|
||||
"3af1e5b298bb5b7379c94934b2e038c5"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,17 +135,8 @@ pub trait MaiVersionExt: MaiVersion {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Sdgb1_50;
|
||||
pub struct Sdgb1_53;
|
||||
|
||||
impl MaiVersion for Sdgb1_50 {
|
||||
const AES_KEY: &[u8; 32] = b"a>32bVP7v<63BVLkY[xM>daZ1s9MBP<R";
|
||||
const AES_IV: &[u8; 16] = b"d6xHIKq]1J]Dt^ue";
|
||||
const OBFUSECATE_SUFFIX: &str = "MaimaiChnB44df8yT";
|
||||
|
||||
const VERSION: &str = "1.50";
|
||||
}
|
||||
|
||||
impl MaiVersion for Sdgb1_53 {
|
||||
const AES_KEY: &[u8; 32] = b"o2U8F6<adcYl25f_qwx_n]5_qxRcbLN>";
|
||||
const AES_IV: &[u8; 16] = b"AL<G:k:X6Vu7@_U]";
|
||||
|
||||
@@ -6,11 +6,15 @@ use serde::{Deserialize, Serialize};
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GetUserPreviewApi {
|
||||
pub user_id: u32,
|
||||
pub token: Option<String>,
|
||||
}
|
||||
|
||||
impl From<u32> for GetUserPreviewApi {
|
||||
fn from(user_id: u32) -> Self {
|
||||
Self { user_id }
|
||||
Self {
|
||||
user_id,
|
||||
token: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ pub struct UserLoginApi {
|
||||
pub acsess_code: String,
|
||||
pub place_id: String,
|
||||
pub client_id: String,
|
||||
|
||||
/// QR Login 结果的 Token
|
||||
pub token: Option<String>,
|
||||
|
||||
/// false 的情况,二维码扫描后半小时可登录。
|
||||
///
|
||||
/// true 的情况,可延长至二维码扫描后的两小时可登录。
|
||||
@@ -36,7 +40,7 @@ pub struct UserLoginApiResp {
|
||||
}
|
||||
|
||||
impl UserLoginApi {
|
||||
pub fn new(user_id: u32, is_continue: bool) -> Self {
|
||||
pub fn new(user_id: u32, is_continue: bool, token: Option<String>) -> Self {
|
||||
let date_time = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|t| t.as_secs())
|
||||
@@ -51,8 +55,10 @@ impl UserLoginApi {
|
||||
region_id: 13,
|
||||
acsess_code: "".to_owned(),
|
||||
place_id: 3223.to_string(),
|
||||
is_continue,
|
||||
generic_flag: 0,
|
||||
|
||||
token,
|
||||
is_continue,
|
||||
client_id: "A63E01E6170".into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ pub enum Commands {
|
||||
|
||||
/// Retrieve update package of SDGB
|
||||
AuthLite {
|
||||
#[arg(short, long, default_value = "1.50")]
|
||||
#[arg(short, long, default_value = "1.53")]
|
||||
title_ver: String,
|
||||
#[arg(long, default_value = "SDGB")]
|
||||
variant: AuthLiteVariant,
|
||||
@@ -43,6 +43,8 @@ pub enum Commands {
|
||||
Preview {
|
||||
#[arg(short, long)]
|
||||
user_id: u32,
|
||||
#[arg(short, long)]
|
||||
token: Option<String>,
|
||||
},
|
||||
/// Get B35 + B15 play records
|
||||
Rating {
|
||||
@@ -79,6 +81,8 @@ pub enum Commands {
|
||||
user_id: u32,
|
||||
#[arg(long)]
|
||||
skip_login: bool,
|
||||
#[arg(short, long)]
|
||||
token: Option<String>,
|
||||
},
|
||||
|
||||
/// Scrape all user, read possible id from stdin
|
||||
|
||||
@@ -14,7 +14,7 @@ use sdgb_api::{
|
||||
all_net::{GetResponse, QRCode},
|
||||
auth_lite::{SDGB, SDHJ, delivery_raw},
|
||||
title::{
|
||||
MaiVersionExt, Sdgb1_50, Sdgb1_53,
|
||||
MaiVersionExt, Sdgb1_53,
|
||||
helper::get_user_all_music,
|
||||
methods::APIMethod,
|
||||
model::{
|
||||
@@ -118,7 +118,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
}
|
||||
}
|
||||
Commands::Rating { user_id, format } => {
|
||||
let rating: GetUserRatingApiResp = Sdgb1_50::request(
|
||||
let rating: GetUserRatingApiResp = Sdgb1_53::request(
|
||||
&client,
|
||||
APIMethod::GetUserRatingApi,
|
||||
user_id,
|
||||
@@ -147,7 +147,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
}
|
||||
}
|
||||
Commands::Logout { user_id, timestamp } => {
|
||||
let logout: UserLogoutApiResp = Sdgb1_50::request(
|
||||
let logout: UserLogoutApiResp = Sdgb1_53::request(
|
||||
&client,
|
||||
APIMethod::UserLogoutApi,
|
||||
user_id,
|
||||
@@ -165,34 +165,34 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
json_display(logout)?;
|
||||
}
|
||||
}
|
||||
Commands::Preview { user_id } => {
|
||||
let preview: GetUserPreviewApiResp = Sdgb1_50::request(
|
||||
Commands::Preview { user_id, token } => {
|
||||
let preview: GetUserPreviewApiResp = Sdgb1_53::request(
|
||||
&client,
|
||||
APIMethod::GetUserPreviewApi,
|
||||
user_id,
|
||||
GetUserPreviewApi { user_id },
|
||||
GetUserPreviewApi { user_id, token },
|
||||
)
|
||||
.await?;
|
||||
|
||||
human_readable_display(preview, human_readable)?;
|
||||
}
|
||||
Commands::Ping => {
|
||||
for _ in 0..10 {
|
||||
let time = SystemTime::now();
|
||||
let decoded: PingResp =
|
||||
Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?;
|
||||
info!(
|
||||
"sdgb 1.50 resp: {decoded}, {}ms",
|
||||
time.elapsed().unwrap_or_default().as_millis()
|
||||
);
|
||||
|
||||
let time = SystemTime::now();
|
||||
let decoded: PingResp =
|
||||
Sdgb1_53::request(&client, APIMethod::Ping, "", Ping {}).await?;
|
||||
match Sdgb1_53::request::<_, PingResp>(&client, APIMethod::Ping, "", Ping {}).await
|
||||
{
|
||||
Ok(decoded) => {
|
||||
info!(
|
||||
"sdgb 1.53 resp: {decoded}, {}ms",
|
||||
time.elapsed().unwrap_or_default().as_millis()
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("sdgb 1.53 error: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Commands::QRLogin { ref qrcode_content } => {
|
||||
let qrcode = QRCode { qrcode_content };
|
||||
let resp = qrcode.login(&client).await;
|
||||
@@ -430,8 +430,9 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
Commands::Userdata {
|
||||
user_id,
|
||||
skip_login,
|
||||
token,
|
||||
} => {
|
||||
let action = async |_| match Sdgb1_50::request::<_, GetUserDataApiResp>(
|
||||
let action = async |_| match Sdgb1_53::request::<_, GetUserDataApiResp>(
|
||||
&client,
|
||||
APIMethod::GetUserDataApi,
|
||||
user_id,
|
||||
@@ -450,7 +451,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
if skip_login {
|
||||
action(UserLoginApiResp::default()).await;
|
||||
} else {
|
||||
login_action(&client, user_id, action).await?;
|
||||
login_action(&client, user_id, token, action).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use redb::TableDefinition;
|
||||
use spdlog::{error, info};
|
||||
|
||||
use sdgb_api::title::MaiVersionExt;
|
||||
use sdgb_api::title::{Sdgb1_50, methods::APIExt};
|
||||
use sdgb_api::title::{Sdgb1_53, methods::APIExt};
|
||||
use sdgb_api::{ApiError, bincode};
|
||||
|
||||
use bincode::{BorrowDecode, Encode, borrow_decode_from_slice};
|
||||
@@ -111,7 +111,7 @@ where
|
||||
concurrency,
|
||||
definition,
|
||||
async |client, user_id| {
|
||||
Sdgb1_50::request_ext::<A>(client, A::Payload::from(user_id), user_id).await
|
||||
Sdgb1_53::request_ext::<A>(client, A::Payload::from(user_id), user_id).await
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -4,7 +4,7 @@ use nyquest_preset::nyquest::AsyncClient;
|
||||
use sdgb_api::{
|
||||
ApiError,
|
||||
title::{
|
||||
MaiVersionExt as _, Sdgb1_50,
|
||||
MaiVersionExt as _, Sdgb1_53,
|
||||
methods::APIMethod,
|
||||
model::{UserLoginApi, UserLoginApiResp, UserLogoutApi, UserLogoutApiResp},
|
||||
},
|
||||
@@ -15,13 +15,14 @@ use spdlog::info;
|
||||
pub async fn login_action<R>(
|
||||
client: &AsyncClient,
|
||||
user_id: u32,
|
||||
token: Option<String>,
|
||||
action: impl AsyncFnOnce(UserLoginApiResp) -> R,
|
||||
) -> Result<R, ApiError> {
|
||||
let login = UserLoginApi::new(user_id, true);
|
||||
let login = UserLoginApi::new(user_id, true, token);
|
||||
let date_time = login.date_time;
|
||||
|
||||
let login_resp: UserLoginApiResp =
|
||||
Sdgb1_50::request(&client, APIMethod::UserLoginApi, user_id, login).await?;
|
||||
Sdgb1_53::request(&client, APIMethod::UserLoginApi, user_id, login).await?;
|
||||
|
||||
match login_resp.error() {
|
||||
None => info!("login succeed"),
|
||||
@@ -30,7 +31,7 @@ pub async fn login_action<R>(
|
||||
|
||||
let return_data = action(login_resp).await;
|
||||
|
||||
let logout_resp = Sdgb1_50::request::<_, UserLogoutApiResp>(
|
||||
let logout_resp = Sdgb1_53::request::<_, UserLogoutApiResp>(
|
||||
&client,
|
||||
APIMethod::UserLogoutApi,
|
||||
user_id,
|
||||
|
||||
Reference in New Issue
Block a user