From 1712e0c7e3f39bafe54419a83fd9da97142e287e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 4 Jan 2024 17:46:40 -0800 Subject: [PATCH] download version history --- src/main.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2ef3bee..f0b00e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,17 +169,30 @@ fn read_readable(mut readable:impl Read)->AResult>{ Ok(contents) } +const BHOP_PLACEID:u64=252877716; + async fn download_list(cookie:String,asset_id_file_map:AssetIDFileMap)->AResult<()>{ let client=reqwest::Client::new(); - futures::stream::iter(asset_id_file_map) - .map(|(asset_id,file)|{ + futures::stream::iter(1..=1006) + .map(|version_id|{ let client=&client; let cookie=cookie.as_str(); async move{ - let resp=client.get(format!("https://assetdelivery.roblox.com/v1/asset/?ID={}",asset_id)) + let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/")?; + //url borrow scope + { + let mut query=url.query_pairs_mut();//borrow here + query.append_pair("ID",BHOP_PLACEID.to_string().as_str()); + query.append_pair("version",version_id.to_string().as_str()); + } + println!("url={}",url); + let resp=client.get(url) .header("Cookie",cookie) .send().await?; - Ok((file,resp.bytes().await?)) + + let mut path=std::path::PathBuf::new(); + path.set_file_name(BHOP_PLACEID.to_string()+"_v"+version_id.to_string().as_str()+".rbxl"); + Ok((path,resp.bytes().await?)) } }) .buffer_unordered(CONCURRENT_REQUESTS)