forked from StrafesNET/asset-tool
more options for create
This commit is contained in:
parent
312c0e7cd9
commit
ae181fd401
46
src/main.rs
46
src/main.rs
@ -79,9 +79,15 @@ struct CreateSubcommand{
|
||||
#[arg(long)]
|
||||
model_name:String,
|
||||
#[arg(long)]
|
||||
description:Option<String>,
|
||||
#[arg(long)]
|
||||
input_file:PathBuf,
|
||||
#[arg(long)]
|
||||
group:Option<u64>,
|
||||
#[arg(long)]
|
||||
free_model:Option<bool>,
|
||||
#[arg(long)]
|
||||
allow_comments:Option<bool>,
|
||||
}
|
||||
#[derive(Args)]
|
||||
struct UploadSubcommand{
|
||||
@ -247,12 +253,15 @@ async fn main()->AResult<()>{
|
||||
subcommand.group,
|
||||
subcommand.output_folder.unwrap_or_else(||std::env::current_dir().unwrap()),
|
||||
).await,
|
||||
Commands::Create(subcommand)=>create(
|
||||
Cookie::from_type(subcommand.cookie_type,subcommand.cookie).await?.0,
|
||||
subcommand.group,
|
||||
subcommand.input_file,
|
||||
subcommand.model_name,
|
||||
).await,
|
||||
Commands::Create(subcommand)=>create(CreateConfig{
|
||||
cookie:Cookie::from_type(subcommand.cookie_type,subcommand.cookie).await?.0,
|
||||
group:subcommand.group,
|
||||
input_file:subcommand.input_file,
|
||||
model_name:subcommand.model_name,
|
||||
description:subcommand.description.unwrap_or_else(||String::with_capacity(0)),
|
||||
free_model:subcommand.free_model.unwrap_or(false),
|
||||
allow_comments:subcommand.allow_comments.unwrap_or(false),
|
||||
}).await,
|
||||
Commands::Upload(subcommand)=>upload_list(
|
||||
Cookie::from_type(subcommand.cookie_type,subcommand.cookie).await?.0,
|
||||
subcommand.group,
|
||||
@ -321,25 +330,38 @@ fn maybe_gzip_decode<R:Read>(input:R)->AResult<ReaderType<R>>{
|
||||
}
|
||||
}
|
||||
|
||||
async fn create(cookie:String,group:Option<u64>,file:PathBuf,model_name:String)->AResult<()>{
|
||||
struct CreateConfig{
|
||||
cookie:String,
|
||||
model_name:String,
|
||||
description:String,
|
||||
input_file:PathBuf,
|
||||
group:Option<u64>,
|
||||
free_model:bool,
|
||||
allow_comments:bool,
|
||||
}
|
||||
|
||||
async fn create(config:CreateConfig)->AResult<()>{
|
||||
let client=reqwest::Client::new();
|
||||
let client=&client;
|
||||
let cookie=cookie.as_str();
|
||||
let group=&group;
|
||||
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1&description&ispublic=False&allowComments=False")?;
|
||||
let cookie=config.cookie.as_str();
|
||||
let group=&config.group;
|
||||
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")?;
|
||||
//url borrow scope
|
||||
{
|
||||
let mut query=url.query_pairs_mut();//borrow here
|
||||
//archaic roblox api uses 0 for new asset
|
||||
query.append_pair("assetid","0");
|
||||
query.append_pair("name",model_name.as_str());
|
||||
query.append_pair("name",config.model_name.as_str());
|
||||
query.append_pair("description",config.description.as_str());
|
||||
query.append_pair("ispublic",if config.free_model{"True"}else{"False"});
|
||||
query.append_pair("allowComments",if config.allow_comments{"True"}else{"False"});
|
||||
match group{
|
||||
Some(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());},
|
||||
None=>(),
|
||||
}
|
||||
}
|
||||
|
||||
let body=tokio::fs::read(file).await?;
|
||||
let body=tokio::fs::read(config.input_file).await?;
|
||||
let mut resp=client.post(url.clone())
|
||||
.header("Cookie",cookie)
|
||||
.body(body.clone())
|
||||
|
Loading…
Reference in New Issue
Block a user