forked from StrafesNET/asset-tool
download_user_inventory_json
This commit is contained in:
parent
ea0239c78b
commit
28bcf8005b
52
src/main.rs
52
src/main.rs
@ -24,6 +24,7 @@ enum Commands{
|
|||||||
Download(DownloadSubcommand),
|
Download(DownloadSubcommand),
|
||||||
DownloadDecompile(DownloadDecompileSubcommand),
|
DownloadDecompile(DownloadDecompileSubcommand),
|
||||||
DownloadCreationsJson(DownloadCreationsJsonSubcommand),
|
DownloadCreationsJson(DownloadCreationsJsonSubcommand),
|
||||||
|
DownloadUserInventoryJson(DownloadUserInventoryJsonSubcommand),
|
||||||
CreateAsset(CreateAssetSubcommand),
|
CreateAsset(CreateAssetSubcommand),
|
||||||
CreateAssetMedia(CreateAssetMediaSubcommand),
|
CreateAssetMedia(CreateAssetMediaSubcommand),
|
||||||
CreateAssetMedias(CreateAssetMediasSubcommand),
|
CreateAssetMedias(CreateAssetMediasSubcommand),
|
||||||
@ -88,6 +89,20 @@ struct DownloadCreationsJsonSubcommand{
|
|||||||
#[arg(long,group="owner",required=true)]
|
#[arg(long,group="owner",required=true)]
|
||||||
user_id:Option<u64>,
|
user_id:Option<u64>,
|
||||||
}
|
}
|
||||||
|
/// Download the list of asset ids (not the assets themselves) in a user's inventory. The output is written to `output_folder/versions.json`
|
||||||
|
#[derive(Args)]
|
||||||
|
struct DownloadUserInventoryJsonSubcommand{
|
||||||
|
#[arg(long,group="cookie",required=true)]
|
||||||
|
cookie_literal:Option<String>,
|
||||||
|
#[arg(long,group="cookie",required=true)]
|
||||||
|
cookie_envvar:Option<String>,
|
||||||
|
#[arg(long,group="cookie",required=true)]
|
||||||
|
cookie_file:Option<PathBuf>,
|
||||||
|
#[arg(long)]
|
||||||
|
output_folder:Option<PathBuf>,
|
||||||
|
#[arg(long)]
|
||||||
|
user_id:u64,
|
||||||
|
}
|
||||||
/// Upload a (.rbxm, .rbxmx) model file, creating a new asset. Can be any type of model, including modulescripts.
|
/// Upload a (.rbxm, .rbxmx) model file, creating a new asset. Can be any type of model, including modulescripts.
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct CreateAssetSubcommand{
|
struct CreateAssetSubcommand{
|
||||||
@ -441,6 +456,15 @@ async fn main()->AResult<()>{
|
|||||||
)?,
|
)?,
|
||||||
subcommand.output_folder.unwrap_or_else(||std::env::current_dir().unwrap()),
|
subcommand.output_folder.unwrap_or_else(||std::env::current_dir().unwrap()),
|
||||||
).await,
|
).await,
|
||||||
|
Commands::DownloadUserInventoryJson(subcommand)=>download_user_inventory_json(
|
||||||
|
cookie_from_args(
|
||||||
|
subcommand.cookie_literal,
|
||||||
|
subcommand.cookie_envvar,
|
||||||
|
subcommand.cookie_file,
|
||||||
|
).await?,
|
||||||
|
subcommand.user_id,
|
||||||
|
subcommand.output_folder.unwrap_or_else(||std::env::current_dir().unwrap()),
|
||||||
|
).await,
|
||||||
Commands::CreateAsset(subcommand)=>create_asset(CreateAssetConfig{
|
Commands::CreateAsset(subcommand)=>create_asset(CreateAssetConfig{
|
||||||
cookie:cookie_from_args(
|
cookie:cookie_from_args(
|
||||||
subcommand.cookie_literal,
|
subcommand.cookie_literal,
|
||||||
@ -931,6 +955,34 @@ async fn download_creations_json(cookie:Cookie,owner:rbx_asset::cookie::Owner,ou
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_user_inventory_pages(context:&CookieContext,user_id:u64)->AResult<Vec<rbx_asset::cookie::UserInventoryItem>>{
|
||||||
|
let mut config=rbx_asset::cookie::UserInventoryPageRequest{
|
||||||
|
user_id,
|
||||||
|
cursor:None,
|
||||||
|
};
|
||||||
|
let mut asset_list=Vec::new();
|
||||||
|
loop{
|
||||||
|
let mut page=context.get_user_inventory_page(&config).await?;
|
||||||
|
asset_list.append(&mut page.data);
|
||||||
|
if page.nextPageCursor.is_none(){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
config.cursor=page.nextPageCursor;
|
||||||
|
}
|
||||||
|
Ok(asset_list)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn download_user_inventory_json(cookie:Cookie,user_id:u64,output_folder:PathBuf)->AResult<()>{
|
||||||
|
let context=CookieContext::new(cookie);
|
||||||
|
let item_list=get_user_inventory_pages(&context,user_id).await?;
|
||||||
|
|
||||||
|
let mut path=output_folder.clone();
|
||||||
|
path.set_file_name("versions.json");
|
||||||
|
tokio::fs::write(path,serde_json::to_string(&item_list)?).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_version_history(context:&CookieContext,asset_id:AssetID)->AResult<Vec<AssetVersion>>{
|
async fn get_version_history(context:&CookieContext,asset_id:AssetID)->AResult<Vec<AssetVersion>>{
|
||||||
let mut cursor:Option<String>=None;
|
let mut cursor:Option<String>=None;
|
||||||
let mut asset_list=Vec::new();
|
let mut asset_list=Vec::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user