use old api for download, error on http status #4
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1166,7 +1166,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rbx_asset"
|
name = "rbx_asset"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rbx_asset"
|
name = "rbx_asset"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = ["strafesnet"]
|
publish = ["strafesnet"]
|
||||||
|
|
||||||
|
@ -234,9 +234,9 @@ impl CookieContext{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp=self.post(url,body).await.map_err(CreateError::PostError)?;
|
Ok(self.post(url,body).await.map_err(CreateError::PostError)?
|
||||||
|
.error_for_status().map_err(CreateError::Reqwest)?
|
||||||
Ok(resp.json::<UploadResponse>().await.map_err(CreateError::Reqwest)?)
|
.json::<UploadResponse>().await.map_err(CreateError::Reqwest)?)
|
||||||
}
|
}
|
||||||
pub async fn upload(&self,config:UploadRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,UploadError>{
|
pub async fn upload(&self,config:UploadRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,UploadError>{
|
||||||
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?;
|
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?;
|
||||||
@ -265,9 +265,9 @@ impl CookieContext{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp=self.post(url,body).await.map_err(UploadError::PostError)?;
|
Ok(self.post(url,body).await.map_err(UploadError::PostError)?
|
||||||
|
.error_for_status().map_err(UploadError::Reqwest)?
|
||||||
Ok(resp.json::<UploadResponse>().await.map_err(UploadError::Reqwest)?)
|
.json::<UploadResponse>().await.map_err(UploadError::Reqwest)?)
|
||||||
}
|
}
|
||||||
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
||||||
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;
|
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;
|
||||||
@ -279,9 +279,9 @@ impl CookieContext{
|
|||||||
query.append_pair("version",version.to_string().as_str());
|
query.append_pair("version",version.to_string().as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let resp=self.get(url).await.map_err(GetError::Reqwest)?;
|
let body=self.get(url).await.map_err(GetError::Reqwest)?
|
||||||
|
.error_for_status().map_err(GetError::Reqwest)?
|
||||||
let body=resp.bytes().await.map_err(GetError::Reqwest)?;
|
.bytes().await.map_err(GetError::Reqwest)?;
|
||||||
|
|
||||||
match maybe_gzip_decode(&mut std::io::Cursor::new(body)){
|
match maybe_gzip_decode(&mut std::io::Cursor::new(body)){
|
||||||
Ok(ReaderType::GZip(readable))=>read_readable(readable),
|
Ok(ReaderType::GZip(readable))=>read_readable(readable),
|
||||||
@ -303,6 +303,7 @@ impl CookieContext{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(self.get(url).await.map_err(AssetVersionsPageError::Reqwest)?
|
Ok(self.get(url).await.map_err(AssetVersionsPageError::Reqwest)?
|
||||||
|
.error_for_status().map_err(AssetVersionsPageError::Reqwest)?
|
||||||
.json::<AssetVersionsPageResponse>().await.map_err(AssetVersionsPageError::Reqwest)?)
|
.json::<AssetVersionsPageResponse>().await.map_err(AssetVersionsPageError::Reqwest)?)
|
||||||
}
|
}
|
||||||
pub async fn get_inventory_page(&self,config:InventoryPageRequest)->Result<InventoryPageResponse,InventoryPageError>{
|
pub async fn get_inventory_page(&self,config:InventoryPageRequest)->Result<InventoryPageResponse,InventoryPageError>{
|
||||||
@ -316,6 +317,7 @@ impl CookieContext{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(self.get(url).await.map_err(InventoryPageError::Reqwest)?
|
Ok(self.get(url).await.map_err(InventoryPageError::Reqwest)?
|
||||||
|
.error_for_status().map_err(InventoryPageError::Reqwest)?
|
||||||
.json::<InventoryPageResponse>().await.map_err(InventoryPageError::Reqwest)?)
|
.json::<InventoryPageResponse>().await.map_err(InventoryPageError::Reqwest)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user