forked from StrafesNET/asset-tool
Merge pull request 'use old api for download, error on http status' (#4) from staging into master
Reviewed-on: StrafesNET/asset-tool#4
This commit is contained in:
commit
68d751f81f
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -110,7 +110,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asset-tool"
|
name = "asset-tool"
|
||||||
version = "0.4.3"
|
version = "0.4.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@ -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,7 +1,7 @@
|
|||||||
workspace = { members = ["rbx_asset", "rox_compiler"] }
|
workspace = { members = ["rbx_asset", "rox_compiler"] }
|
||||||
[package]
|
[package]
|
||||||
name = "asset-tool"
|
name = "asset-tool"
|
||||||
version = "0.4.3"
|
version = "0.4.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -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"]
|
||||||
|
|
||||||
|
@ -37,22 +37,27 @@ pub struct UpdateAssetRequest{
|
|||||||
//woo nested roblox stuff
|
//woo nested roblox stuff
|
||||||
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
#[allow(nonstandard_style,dead_code)]
|
#[allow(nonstandard_style,dead_code)]
|
||||||
pub struct Creator{
|
pub enum Creator{
|
||||||
pub userId:u64,
|
userId(String),//u64 string
|
||||||
pub groupId:u64,
|
groupId(String),//u64 string
|
||||||
}
|
}
|
||||||
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
#[allow(nonstandard_style,dead_code)]
|
#[allow(nonstandard_style,dead_code)]
|
||||||
pub struct CreationContext{
|
pub struct CreationContext{
|
||||||
pub creator:Creator,
|
pub creator:Creator,
|
||||||
pub expectedPrice:u64,
|
pub expectedPrice:Option<u64>,
|
||||||
}
|
}
|
||||||
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
#[allow(nonstandard_style,dead_code)]
|
#[allow(nonstandard_style,dead_code)]
|
||||||
pub enum ModerationResult{
|
pub enum ModerationState{
|
||||||
MODERATION_STATE_REVIEWING,
|
Reviewing,
|
||||||
MODERATION_STATE_REJECTED,
|
Rejected,
|
||||||
MODERATION_STATE_APPROVED,
|
Approved,
|
||||||
|
}
|
||||||
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
|
#[allow(nonstandard_style,dead_code)]
|
||||||
|
pub struct ModerationResult{
|
||||||
|
pub moderationState:ModerationState,
|
||||||
}
|
}
|
||||||
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
#[allow(nonstandard_style,dead_code)]
|
#[allow(nonstandard_style,dead_code)]
|
||||||
@ -83,6 +88,51 @@ impl std::fmt::Display for UpdateError{
|
|||||||
}
|
}
|
||||||
impl std::error::Error for UpdateError{}
|
impl std::error::Error for UpdateError{}
|
||||||
|
|
||||||
|
#[allow(nonstandard_style,dead_code)]
|
||||||
|
pub struct GetAssetInfoRequest{
|
||||||
|
pub asset_id:u64,
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"assetId": "5692158972",
|
||||||
|
"assetType": "Model",
|
||||||
|
"creationContext":{
|
||||||
|
"creator":
|
||||||
|
{
|
||||||
|
"groupId": "6980477"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "DisplayName: Ares\nCreator: titanicguy54",
|
||||||
|
"displayName": "bhop_ares.rbxmx",
|
||||||
|
"path": "assets/5692158972",
|
||||||
|
"revisionCreateTime": "2020-09-14T16:08:05.063Z",
|
||||||
|
"revisionId": "1",
|
||||||
|
"moderationResult":{
|
||||||
|
"moderationState": "Approved"
|
||||||
|
},
|
||||||
|
"state": "Active"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
|
#[allow(nonstandard_style,dead_code)]
|
||||||
|
pub struct AssetResponse{
|
||||||
|
pub assetId:String,//u64 wrapped in quotes wohoo!!
|
||||||
|
pub assetType:AssetType,
|
||||||
|
pub creationContext:CreationContext,
|
||||||
|
pub description:String,
|
||||||
|
pub displayName:String,
|
||||||
|
pub path:String,
|
||||||
|
pub revisionCreateTime:chrono::DateTime<chrono::Utc>,
|
||||||
|
pub revisionId:String,//u64
|
||||||
|
pub moderationResult:ModerationResult,
|
||||||
|
pub icon:Option<String>,
|
||||||
|
pub previews:Option<Vec<Preview>>,
|
||||||
|
}
|
||||||
|
#[allow(nonstandard_style,dead_code)]
|
||||||
|
pub struct GetAssetVersionRequest{
|
||||||
|
pub asset_id:u64,
|
||||||
|
pub version:u64,
|
||||||
|
}
|
||||||
#[allow(nonstandard_style,dead_code)]
|
#[allow(nonstandard_style,dead_code)]
|
||||||
pub struct GetAssetRequest{
|
pub struct GetAssetRequest{
|
||||||
pub asset_id:u64,
|
pub asset_id:u64,
|
||||||
@ -278,19 +328,21 @@ impl CloudContext{
|
|||||||
|
|
||||||
Ok(resp.json::<RobloxOperation>().await.map_err(UpdateError::Reqwest)?)
|
Ok(resp.json::<RobloxOperation>().await.map_err(UpdateError::Reqwest)?)
|
||||||
}
|
}
|
||||||
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
pub async fn get_asset_info(&self,config:GetAssetInfoRequest)->Result<AssetResponse,GetError>{
|
||||||
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;
|
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}",config.asset_id);
|
||||||
//url borrow scope
|
let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?;
|
||||||
{
|
|
||||||
let mut query=url.query_pairs_mut();//borrow here
|
|
||||||
query.append_pair("ID",config.asset_id.to_string().as_str());
|
|
||||||
if let Some(version)=config.version{
|
|
||||||
query.append_pair("version",version.to_string().as_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let resp=self.get(url).await.map_err(GetError::Reqwest)?;
|
|
||||||
|
|
||||||
let body=resp.bytes().await.map_err(GetError::Reqwest)?;
|
Ok(self.get(url).await.map_err(GetError::Reqwest)?
|
||||||
|
.error_for_status().map_err(GetError::Reqwest)?
|
||||||
|
.json::<AssetResponse>().await.map_err(GetError::Reqwest)?)
|
||||||
|
}
|
||||||
|
pub async fn get_asset_version(&self,config:GetAssetVersionRequest)->Result<Vec<u8>,GetError>{
|
||||||
|
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}/versions/{}",config.asset_id,config.version);
|
||||||
|
let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?;
|
||||||
|
|
||||||
|
let body=self.get(url).await.map_err(GetError::Reqwest)?
|
||||||
|
.error_for_status().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),
|
||||||
@ -298,11 +350,22 @@ impl CloudContext{
|
|||||||
Err(e)=>Err(e),
|
Err(e)=>Err(e),
|
||||||
}.map_err(GetError::IO)
|
}.map_err(GetError::IO)
|
||||||
}
|
}
|
||||||
|
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
||||||
|
let version=match config.version{
|
||||||
|
Some(version)=>version,
|
||||||
|
None=>self.get_asset_info(GetAssetInfoRequest{asset_id:config.asset_id}).await?.revisionId.parse().unwrap(),
|
||||||
|
};
|
||||||
|
self.get_asset_version(GetAssetVersionRequest{
|
||||||
|
asset_id:config.asset_id,
|
||||||
|
version,
|
||||||
|
}).await
|
||||||
|
}
|
||||||
pub async fn get_asset_versions(&self,config:AssetVersionsRequest)->Result<AssetVersionsResponse,AssetVersionsError>{
|
pub async fn get_asset_versions(&self,config:AssetVersionsRequest)->Result<AssetVersionsResponse,AssetVersionsError>{
|
||||||
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}/versions",config.asset_id);
|
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}/versions",config.asset_id);
|
||||||
let url=reqwest::Url::parse(raw_url.as_str()).map_err(AssetVersionsError::ParseError)?;
|
let url=reqwest::Url::parse(raw_url.as_str()).map_err(AssetVersionsError::ParseError)?;
|
||||||
|
|
||||||
Ok(self.get(url).await.map_err(AssetVersionsError::Reqwest)?
|
Ok(self.get(url).await.map_err(AssetVersionsError::Reqwest)?
|
||||||
|
.error_for_status().map_err(AssetVersionsError::Reqwest)?
|
||||||
.json::<AssetVersionsResponse>().await.map_err(AssetVersionsError::Reqwest)?)
|
.json::<AssetVersionsResponse>().await.map_err(AssetVersionsError::Reqwest)?)
|
||||||
}
|
}
|
||||||
pub async fn inventory_page(&self,config:InventoryPageRequest)->Result<InventoryPageResponse,InventoryPageError>{
|
pub async fn inventory_page(&self,config:InventoryPageRequest)->Result<InventoryPageResponse,InventoryPageError>{
|
||||||
@ -316,6 +379,7 @@ impl CloudContext{
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)?)
|
||||||
}
|
}
|
||||||
pub async fn update_place(&self,config:UpdatePlaceRequest,body:impl Into<reqwest::Body>+Clone)->Result<UpdatePlaceResponse,UpdateError>{
|
pub async fn update_place(&self,config:UpdatePlaceRequest,body:impl Into<reqwest::Body>+Clone)->Result<UpdatePlaceResponse,UpdateError>{
|
||||||
@ -327,9 +391,8 @@ impl CloudContext{
|
|||||||
query.append_pair("versionType","Published");
|
query.append_pair("versionType","Published");
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp=self.post(url,body).await.map_err(UpdateError::Reqwest)?
|
Ok(self.post(url,body).await.map_err(UpdateError::Reqwest)?
|
||||||
.error_for_status().map_err(UpdateError::Reqwest)?;
|
.error_for_status().map_err(UpdateError::Reqwest)?
|
||||||
|
.json::<UpdatePlaceResponse>().await.map_err(UpdateError::Reqwest)?)
|
||||||
Ok(resp.json::<UpdatePlaceResponse>().await.map_err(UpdateError::Reqwest)?)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
54
src/main.rs
54
src/main.rs
@ -1,6 +1,6 @@
|
|||||||
use std::{io::Read,path::PathBuf};
|
use std::{io::Read,path::PathBuf};
|
||||||
use clap::{Args,Parser,Subcommand};
|
use clap::{Args,Parser,Subcommand};
|
||||||
use anyhow::Result as AResult;
|
use anyhow::{anyhow,Result as AResult};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use rbx_asset::cloud::{ApiKey,CloudContext};
|
use rbx_asset::cloud::{ApiKey,CloudContext};
|
||||||
use rbx_asset::cookie::{Cookie,CookieContext,AssetVersion,InventoryItem};
|
use rbx_asset::cookie::{Cookie,CookieContext,AssetVersion,InventoryItem};
|
||||||
@ -58,12 +58,12 @@ struct DownloadHistorySubcommand{
|
|||||||
}
|
}
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct DownloadSubcommand{
|
struct DownloadSubcommand{
|
||||||
#[arg(long,group="api_key",required=true)]
|
#[arg(long,group="cookie",required=true)]
|
||||||
api_key_literal:Option<String>,
|
cookie_literal:Option<String>,
|
||||||
#[arg(long,group="api_key",required=true)]
|
#[arg(long,group="cookie",required=true)]
|
||||||
api_key_envvar:Option<String>,
|
cookie_envvar:Option<String>,
|
||||||
#[arg(long,group="api_key",required=true)]
|
#[arg(long,group="cookie",required=true)]
|
||||||
api_key_file:Option<PathBuf>,
|
cookie_file:Option<PathBuf>,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
output_folder:Option<PathBuf>,
|
output_folder:Option<PathBuf>,
|
||||||
#[arg(required=true)]
|
#[arg(required=true)]
|
||||||
@ -119,9 +119,9 @@ struct CreateAssetMediaSubcommand{
|
|||||||
input_file:PathBuf,
|
input_file:PathBuf,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
asset_type:AssetType,
|
asset_type:AssetType,
|
||||||
#[arg(long)]
|
#[arg(long,group="creator",required=true)]
|
||||||
creator_user_id:u64,
|
creator_user_id:Option<u64>,
|
||||||
#[arg(long)]
|
#[arg(long,group="creator",required=true)]
|
||||||
creator_group_id:Option<u64>,
|
creator_group_id:Option<u64>,
|
||||||
/// Expected price limits how much robux can be spent to create the asset (defaults to 0)
|
/// Expected price limits how much robux can be spent to create the asset (defaults to 0)
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
@ -358,10 +358,10 @@ async fn main()->AResult<()>{
|
|||||||
Commands::Download(subcommand)=>{
|
Commands::Download(subcommand)=>{
|
||||||
let output_folder=subcommand.output_folder.unwrap_or_else(||std::env::current_dir().unwrap());
|
let output_folder=subcommand.output_folder.unwrap_or_else(||std::env::current_dir().unwrap());
|
||||||
download_list(
|
download_list(
|
||||||
api_key_from_args(
|
cookie_from_args(
|
||||||
subcommand.api_key_literal,
|
subcommand.cookie_literal,
|
||||||
subcommand.api_key_envvar,
|
subcommand.cookie_envvar,
|
||||||
subcommand.api_key_file,
|
subcommand.cookie_file,
|
||||||
).await?,
|
).await?,
|
||||||
subcommand.asset_ids.into_iter().map(|asset_id|{
|
subcommand.asset_ids.into_iter().map(|asset_id|{
|
||||||
let mut path=output_folder.clone();
|
let mut path=output_folder.clone();
|
||||||
@ -413,8 +413,11 @@ async fn main()->AResult<()>{
|
|||||||
subcommand.api_key_envvar,
|
subcommand.api_key_envvar,
|
||||||
subcommand.api_key_file,
|
subcommand.api_key_file,
|
||||||
).await?,
|
).await?,
|
||||||
creator_user_id:subcommand.creator_user_id,
|
creator:match (subcommand.creator_user_id,subcommand.creator_group_id){
|
||||||
creator_group_id:subcommand.creator_group_id,
|
(Some(user_id),None)=>rbx_asset::cloud::Creator::userId(user_id.to_string()),
|
||||||
|
(None,Some(group_id))=>rbx_asset::cloud::Creator::groupId(group_id.to_string()),
|
||||||
|
other=>Err(anyhow!("Invalid creator {other:?}"))?,
|
||||||
|
},
|
||||||
input_file:subcommand.input_file,
|
input_file:subcommand.input_file,
|
||||||
asset_type:subcommand.asset_type.cloud(),
|
asset_type:subcommand.asset_type.cloud(),
|
||||||
model_name:subcommand.model_name,
|
model_name:subcommand.model_name,
|
||||||
@ -568,8 +571,7 @@ struct CreateAssetMediaConfig{
|
|||||||
model_name:String,
|
model_name:String,
|
||||||
description:String,
|
description:String,
|
||||||
input_file:PathBuf,
|
input_file:PathBuf,
|
||||||
creator_user_id:u64,
|
creator:rbx_asset::cloud::Creator,
|
||||||
creator_group_id:Option<u64>,
|
|
||||||
expected_price:Option<u64>,
|
expected_price:Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,11 +582,8 @@ async fn create_asset_media(config:CreateAssetMediaConfig)->AResult<()>{
|
|||||||
displayName:config.model_name,
|
displayName:config.model_name,
|
||||||
description:config.description,
|
description:config.description,
|
||||||
creationContext:rbx_asset::cloud::CreationContext{
|
creationContext:rbx_asset::cloud::CreationContext{
|
||||||
creator:rbx_asset::cloud::Creator{
|
creator:config.creator,
|
||||||
userId:config.creator_user_id,
|
expectedPrice:Some(config.expected_price.unwrap_or(0)),
|
||||||
groupId:config.creator_group_id.unwrap_or(0),
|
|
||||||
},
|
|
||||||
expectedPrice:config.expected_price.unwrap_or(0),
|
|
||||||
}
|
}
|
||||||
},tokio::fs::read(config.input_file).await?).await?;
|
},tokio::fs::read(config.input_file).await?).await?;
|
||||||
println!("CreateResponse={:?}",resp);
|
println!("CreateResponse={:?}",resp);
|
||||||
@ -646,13 +645,13 @@ async fn upload_place(config:UploadPlaceConfig)->AResult<()>{
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn download_list(api_key:ApiKey,asset_id_file_map:AssetIDFileMap)->AResult<()>{
|
async fn download_list(cookie:Cookie,asset_id_file_map:AssetIDFileMap)->AResult<()>{
|
||||||
let context=CloudContext::new(api_key);
|
let context=CookieContext::new(cookie);
|
||||||
futures::stream::iter(asset_id_file_map.into_iter()
|
futures::stream::iter(asset_id_file_map.into_iter()
|
||||||
.map(|(asset_id,file)|{
|
.map(|(asset_id,file)|{
|
||||||
let context=&context;
|
let context=&context;
|
||||||
async move{
|
async move{
|
||||||
Ok((file,context.get_asset(rbx_asset::cloud::GetAssetRequest{asset_id,version:None}).await?))
|
Ok((file,context.get_asset(rbx_asset::cookie::GetAssetRequest{asset_id,version:None}).await?))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.buffer_unordered(CONCURRENT_REQUESTS)
|
.buffer_unordered(CONCURRENT_REQUESTS)
|
||||||
@ -1200,9 +1199,10 @@ async fn compile_upload_place(config:CompileUploadPlaceConfig)->AResult<()>{
|
|||||||
|
|
||||||
//upload it
|
//upload it
|
||||||
let context=CloudContext::new(config.api_key);
|
let context=CloudContext::new(config.api_key);
|
||||||
context.update_place(rbx_asset::cloud::UpdatePlaceRequest{
|
let resp=context.update_place(rbx_asset::cloud::UpdatePlaceRequest{
|
||||||
universeId:config.universe_id,
|
universeId:config.universe_id,
|
||||||
placeId:config.place_id,
|
placeId:config.place_id,
|
||||||
},data).await?;
|
},data).await?;
|
||||||
|
println!("UploadResponse={:?}",resp);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user