start version argument
This commit is contained in:
parent
eb20f8056d
commit
1b3a8be142
19
src/main.rs
19
src/main.rs
@ -25,6 +25,8 @@ struct Cli{
|
|||||||
cookie_env:Option<String>,
|
cookie_env:Option<String>,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
cookie_file:Option<std::path::PathBuf>,
|
cookie_file:Option<std::path::PathBuf>,
|
||||||
|
#[arg(long)]
|
||||||
|
start_version:Option<u64>,
|
||||||
|
|
||||||
//decompile options
|
//decompile options
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
@ -134,6 +136,7 @@ async fn main()->AResult<()>{
|
|||||||
|
|
||||||
match cli.command{
|
match cli.command{
|
||||||
Commands::DownloadHistory=>download_history(DownloadHistoryConfig{
|
Commands::DownloadHistory=>download_history(DownloadHistoryConfig{
|
||||||
|
start_version:cli.start_version.unwrap_or(0),
|
||||||
output_folder:cli.output.unwrap(),
|
output_folder:cli.output.unwrap(),
|
||||||
cookie:cookie.unwrap(),
|
cookie:cookie.unwrap(),
|
||||||
asset_id:cli.asset_id.unwrap(),
|
asset_id:cli.asset_id.unwrap(),
|
||||||
@ -348,6 +351,7 @@ async fn download_asset_version(client:&reqwest::Client,cookie:&str,asset_id_str
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct DownloadHistoryConfig{
|
struct DownloadHistoryConfig{
|
||||||
|
start_version:u64,
|
||||||
output_folder:std::path::PathBuf,
|
output_folder:std::path::PathBuf,
|
||||||
cookie:String,
|
cookie:String,
|
||||||
asset_id:AssetID,
|
asset_id:AssetID,
|
||||||
@ -364,8 +368,13 @@ async fn download_history(config:DownloadHistoryConfig)->AResult<()>{
|
|||||||
let mut join_handles=Vec::new();
|
let mut join_handles=Vec::new();
|
||||||
loop{
|
loop{
|
||||||
let mut page=download_page(&client,config.cookie.as_str(),config.asset_id,cursor).await?;
|
let mut page=download_page(&client,config.cookie.as_str(),config.asset_id,cursor).await?;
|
||||||
|
let mut cancel_paging=false;
|
||||||
for asset_version in &page.data{
|
for asset_version in &page.data{
|
||||||
let version_number=asset_version.assetVersionNumber;
|
let version_number=asset_version.assetVersionNumber;
|
||||||
|
if version_number<config.start_version{
|
||||||
|
cancel_paging=true;
|
||||||
|
continue;//don't trust roblox returned order
|
||||||
|
}
|
||||||
let client=client.clone();
|
let client=client.clone();
|
||||||
let cookie=config.cookie.clone();
|
let cookie=config.cookie.clone();
|
||||||
let asset_id_str=asset_id_string.clone();
|
let asset_id_str=asset_id_string.clone();
|
||||||
@ -385,9 +394,15 @@ async fn download_history(config:DownloadHistoryConfig)->AResult<()>{
|
|||||||
Ok::<_,anyhow::Error>(())
|
Ok::<_,anyhow::Error>(())
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
asset_list.append(&mut page.data);
|
if page.nextPageCursor.is_none()||cancel_paging{
|
||||||
if page.nextPageCursor.is_none(){
|
for asset_version in page.data.into_iter(){
|
||||||
|
if config.start_version<=asset_version.assetVersionNumber{
|
||||||
|
asset_list.push(asset_version);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}else{
|
||||||
|
asset_list.append(&mut page.data);
|
||||||
}
|
}
|
||||||
cursor=page.nextPageCursor;
|
cursor=page.nextPageCursor;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user