feat: prepare for 1.53 preview/login

This commit is contained in:
2026-01-09 01:33:18 +08:00
parent 15c6623ed8
commit e7b0bcbfed
5 changed files with 23 additions and 7 deletions

View File

@@ -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

View File

@@ -165,12 +165,12 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
json_display(logout)?;
}
}
Commands::Preview { user_id } => {
Commands::Preview { user_id, token } => {
let preview: GetUserPreviewApiResp = Sdgb1_50::request(
&client,
APIMethod::GetUserPreviewApi,
user_id,
GetUserPreviewApi { user_id },
GetUserPreviewApi { user_id, token },
)
.await?;
@@ -430,6 +430,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
Commands::Userdata {
user_id,
skip_login,
token,
} => {
let action = async |_| match Sdgb1_50::request::<_, GetUserDataApiResp>(
&client,
@@ -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?;
}
}
}

View File

@@ -15,9 +15,10 @@ 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 =