73 Commits

Author SHA1 Message Date
01c61c71d9 set file extension for known file types using fourcc 2024-06-04 11:16:26 -07:00
8e933111e4 set file extension for download_list 2024-05-31 04:45:40 -07:00
13786f941b update deps 2024-05-31 04:45:24 -07:00
dde85fbf8a use an empty dom instead of an empty template 2024-05-04 19:37:33 -07:00
59deac0155 implicitly set input/output folder to current directory 2024-04-28 18:41:03 -07:00
66104be2d9 v0.3.1 asset lib 2024-04-27 23:57:42 -07:00
ca81d06998 use asset lib 2024-04-27 23:57:42 -07:00
4bea61558e asset lib 2024-04-27 23:57:42 -07:00
bd382ef885 decode to UploadResponse struct 2024-04-25 23:28:55 -07:00
809d6df3f0 silence FALSE "dead code" 2024-04-25 23:27:10 -07:00
e28a58d747 v0.3.0 rewrite clap usage + create asset + get inventory 2024-04-25 23:13:16 -07:00
c29396f44b update deps 2024-04-25 23:13:16 -07:00
ae181fd401 more options for create 2024-04-25 18:50:57 -07:00
312c0e7cd9 get inventory function 2024-04-25 17:45:58 -07:00
5ceb118ba1 create assets 2024-04-25 01:09:53 -07:00
c084219534 clarify 2024-04-25 00:28:54 -07:00
90aa03f86e change arg 2024-04-25 00:28:54 -07:00
53755caad5 found out why clap seemed insane 2024-04-19 00:08:47 -07:00
561a94c4d3 what a bug! 2024-04-10 03:59:04 -07:00
6b689c8d6c hack for model uploads 2024-04-10 03:45:22 -07:00
a96715ecaf error for bad status 2024-04-10 03:45:11 -07:00
eac6546aed fix upload 2024-03-15 11:07:30 -07:00
c43ed400c9 try this 2024-03-15 10:52:49 -07:00
91aa21a993 v0.2.0 compile+decompile 2024-03-08 10:32:27 -08:00
1dff5d6856 rewrite clap usage 2024-03-08 09:50:56 -08:00
b64da4511c import PathBuf 2024-03-08 09:48:47 -08:00
8f2115ebf2 eternal license 2024-03-08 09:42:05 -08:00
f23be6f445 tweak history gen 2024-03-08 09:42:05 -08:00
0d1692f253 compile feature 2024-03-08 09:42:05 -08:00
7ad7fa3d41 misc fixes 2024-03-08 09:42:05 -08:00
b8d5efe168 update deps 2024-03-08 09:42:05 -08:00
48ab23bae5 tabs 2024-01-22 20:28:24 -08:00
97286612b7 path 2024-01-22 12:28:32 -08:00
8e589f7f0f download asset list 2024-01-16 21:50:35 -08:00
cbb5805d54 fix download path 2024-01-14 18:43:03 -08:00
d6add611fb fix error message 2024-01-14 13:24:33 -08:00
ebd5bb526e force update 2024-01-14 11:12:57 -08:00
858ed8a89c todo 2024-01-14 11:07:33 -08:00
35657d4d51 versions not correctly updated 2024-01-13 23:08:30 -08:00
15e8c8208f add --continue feature for download history 2024-01-13 21:24:50 -08:00
5574c34045 end_version for download_history + catch download error and write versions.json 2024-01-13 20:49:06 -08:00
e5322ad711 todo 2024-01-13 20:32:54 -08:00
0d0f1b1792 limit concurrent downloads using JoinSet 2024-01-12 17:07:06 -08:00
1b3a8be142 start version argument 2024-01-12 16:43:37 -08:00
eb20f8056d make download_history faster 2024-01-12 16:43:34 -08:00
b3f5dd6c4d opti 2024-01-12 15:53:25 -08:00
10f1ac313c DecompileStyle 2024-01-12 13:14:21 -08:00
2260d9a565 fix analyzer 2024-01-12 11:23:45 -08:00
ee8e59b898 rearrange and comment args 2024-01-12 11:20:22 -08:00
a9a40cd2f0 I think this is better 2024-01-11 22:25:00 -08:00
cef0f38482 pray rayon doesn't spawn 600 threads and crash 2024-01-11 22:07:01 -08:00
c2041b33e4 add rayon dep 2024-01-11 22:06:43 -08:00
29b4211484 limit stupid bs 2024-01-11 22:02:10 -08:00
bbbbd6bf64 wrong tab 2024-01-11 21:32:28 -08:00
e8ef06c2cb tokio looks like this on some random dude's webpage 2024-01-11 21:29:06 -08:00
9dc67a22c1 call this function because it makes it work better 2024-01-11 21:18:37 -08:00
67048cccf6 update deleted or moved files 2024-01-11 21:18:37 -08:00
b9eaefe056 note about default signature 2024-01-11 21:18:37 -08:00
1bdfbf96c3 write no empty commits 2024-01-11 21:18:37 -08:00
db44cf12be fix code duplication 2024-01-11 21:18:37 -08:00
30169ddc5b respect config 2024-01-11 21:18:37 -08:00
4d77895260 use less ram lol 2024-01-11 21:18:37 -08:00
aeb72503f0 print for each 2024-01-11 17:13:05 -08:00
1ba8d636f1 not sure if this drops file earlier 2024-01-11 17:13:05 -08:00
a5c01ff9cf DownloadAndDecompileHistoryIntoGit 2024-01-11 16:11:46 -08:00
c3ca545119 write some stupid stuff using unlimited scoped threads 2024-01-11 16:06:12 -08:00
def0d1a69a async decompile 2024-01-11 14:51:31 -08:00
00f4788169 prepare to write files with TOKIO!!! 2024-01-11 13:59:32 -08:00
e12c13a1dd add args for committer name and email 2024-01-11 13:48:57 -08:00
816461e9f4 async download -> unzip -> decompile -> git history 2024-01-11 02:47:20 -08:00
13ebb96ed6 refactor 2024-01-11 02:46:47 -08:00
097c92f602 add git2 dep 2024-01-11 02:06:50 -08:00
82eb78db23 rewrite stuff as functions 2024-01-11 02:06:15 -08:00
7 changed files with 2149 additions and 720 deletions

878
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -1,24 +1,24 @@
workspace = { members = ["rbx_asset"] }
[package]
name = "asset-tool"
version = "0.1.0"
version = "0.3.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.75"
chrono = { version = "0.4.31", features = ["serde"] }
clap = { version = "4.4.2", features = ["derive"] }
flate2 = "1.0.28"
futures = "0.3.30"
git2 = "0.18.1"
lazy-regex = "3.1.0"
pollster = "0.3.0"
rbx_binary = "0.7.1"
rbx_dom_weak = "2.5.0"
rbx_reflection_database = "0.2.7"
rbx_xml = "0.13.1"
reqwest = { version = "0.11.23", features = ["cookies", "json"] }
serde = { version = "1.0.195", features = ["derive"] }
rayon = "1.8.0"
rbx_asset = { path = "rbx_asset" }
rbx_binary = "0.7.4"
rbx_dom_weak = "2.7.0"
rbx_reflection_database = "0.2.10"
rbx_xml = "0.13.3"
serde_json = "1.0.111"
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "fs"] }

28
LICENSE

@ -1,9 +1,23 @@
MIT License
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
Copyright (c) 2023 Quaternions
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

14
rbx_asset/Cargo.toml Normal file

@ -0,0 +1,14 @@
[package]
name = "rbx_asset"
version = "0.1.0"
edition = "2021"
publish = ["strafesnet"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = { version = "0.4.38", features = ["serde"] }
flate2 = "1.0.29"
reqwest = { version = "0.12.4", features = ["json"] }
serde = { version = "1.0.199", features = ["derive"] }
url = "2.5.0"

311
rbx_asset/src/context.rs Normal file

@ -0,0 +1,311 @@
#[derive(Debug)]
pub enum PostError{
Reqwest(reqwest::Error),
CSRF,
}
impl std::fmt::Display for PostError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"{self:?}")
}
}
impl std::error::Error for PostError{}
#[derive(Debug,serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct CreateRequest{
pub name:String,
pub description:String,
pub ispublic:bool,
pub allowComments:bool,
pub groupId:Option<u64>,
}
#[derive(Debug)]
pub enum CreateError{
ParseError(url::ParseError),
PostError(PostError),
Reqwest(reqwest::Error),
}
impl std::fmt::Display for CreateError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"{self:?}")
}
}
impl std::error::Error for CreateError{}
#[allow(nonstandard_style,dead_code)]
pub struct UploadRequest{
pub assetid:u64,
pub name:Option<String>,
pub description:Option<String>,
pub ispublic:Option<bool>,
pub allowComments:Option<bool>,
pub groupId:Option<u64>,
}
#[derive(Debug)]
pub enum UploadError{
ParseError(url::ParseError),
PostError(PostError),
Reqwest(reqwest::Error),
AssetIdIsZero,
}
impl std::fmt::Display for UploadError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"{self:?}")
}
}
impl std::error::Error for UploadError{}
#[derive(Debug,serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct UploadResponse{
pub AssetId:u64,
pub AssetVersionId:u64,
}
#[allow(nonstandard_style,dead_code)]
pub struct DownloadRequest{
pub asset_id:u64,
pub version:Option<u64>,
}
#[derive(Debug)]
pub enum DownloadError{
ParseError(url::ParseError),
Reqwest(reqwest::Error),
IO(std::io::Error)
}
impl std::fmt::Display for DownloadError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"{self:?}")
}
}
impl std::error::Error for DownloadError{}
pub struct HistoryPageRequest{
pub asset_id:u64,
pub cursor:Option<String>,
}
#[derive(serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct AssetVersion{
pub Id:u64,
pub assetId:u64,
pub assetVersionNumber:u64,
pub creatorType:String,
pub creatorTargetId:u64,
pub creatingUniverseId:Option<u64>,
pub created:chrono::DateTime<chrono::Utc>,
pub isPublished:bool,
}
#[derive(serde::Deserialize)]
#[allow(nonstandard_style,dead_code)]
pub struct HistoryPageResponse{
pub previousPageCursor:Option<String>,
pub nextPageCursor:Option<String>,
pub data:Vec<AssetVersion>,
}
#[derive(Debug)]
pub enum HistoryPageError{
ParseError(url::ParseError),
Reqwest(reqwest::Error),
}
impl std::fmt::Display for HistoryPageError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"{self:?}")
}
}
impl std::error::Error for HistoryPageError{}
pub struct InventoryPageRequest{
pub group:u64,
pub cursor:Option<String>,
}
#[derive(serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct InventoryItem{
pub id:u64,
pub name:String,
}
#[derive(serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct InventoryPageResponse{
pub totalResults:u64,//up to 50
pub filteredKeyword:Option<String>,//""
pub searchDebugInfo:Option<String>,//null
pub spellCheckerResult:Option<String>,//null
pub queryFacets:Option<String>,//null
pub imageSearchStatus:Option<String>,//null
pub previousPageCursor:Option<String>,
pub nextPageCursor:Option<String>,
pub data:Vec<InventoryItem>,
}
#[derive(Debug)]
pub enum InventoryPageError{
ParseError(url::ParseError),
Reqwest(reqwest::Error),
}
impl std::fmt::Display for InventoryPageError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"{self:?}")
}
}
impl std::error::Error for InventoryPageError{}
//idk how to do this better
enum ReaderType<R:std::io::Read>{
GZip(flate2::read::GzDecoder<std::io::BufReader<R>>),
Raw(std::io::BufReader<R>),
}
fn maybe_gzip_decode<R:std::io::Read>(input:R)->std::io::Result<ReaderType<R>>{
let mut buf=std::io::BufReader::new(input);
let peek=std::io::BufRead::fill_buf(&mut buf)?;
match &peek[0..2]{
b"\x1f\x8b"=>Ok(ReaderType::GZip(flate2::read::GzDecoder::new(buf))),
_=>Ok(ReaderType::Raw(buf)),
}
}
fn read_readable(mut readable:impl std::io::Read)->std::io::Result<Vec<u8>>{
let mut contents=Vec::new();
readable.read_to_end(&mut contents)?;
Ok(contents)
}
#[derive(Clone)]
pub struct RobloxContext{
pub cookie:String,
pub client:reqwest::Client,
}
impl RobloxContext{
pub fn new(cookie:String)->Self{
Self{
cookie,
client:reqwest::Client::new(),
}
}
async fn get(&self,url:impl reqwest::IntoUrl)->Result<reqwest::Response,reqwest::Error>{
self.client.get(url)
.header("Cookie",self.cookie.as_str())
.send().await
}
async fn post(&self,url:url::Url,body:impl Into<reqwest::Body>+Clone)->Result<reqwest::Response,PostError>{
let mut resp=self.client.post(url.clone())
.header("Cookie",self.cookie.as_str())
.body(body.clone())
.send().await.map_err(PostError::Reqwest)?;
//This is called a CSRF challenge apparently
if resp.status()==reqwest::StatusCode::FORBIDDEN{
if let Some(csrf_token)=resp.headers().get("X-CSRF-Token"){
resp=self.client.post(url)
.header("X-CSRF-Token",csrf_token)
.header("Cookie",self.cookie.as_str())
.body(body)
.send().await.map_err(PostError::Reqwest)?;
}else{
Err(PostError::CSRF)?;
}
}
Ok(resp)
}
pub async fn create(&self,config:CreateRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,CreateError>{
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(CreateError::ParseError)?;
//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",config.name.as_str());
query.append_pair("description",config.description.as_str());
query.append_pair("ispublic",if config.ispublic{"True"}else{"False"});
query.append_pair("allowComments",if config.allowComments{"True"}else{"False"});
match config.groupId{
Some(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());},
None=>(),
}
}
let resp=self.post(url,body).await.map_err(CreateError::PostError)?;
Ok(resp.json::<UploadResponse>().await.map_err(CreateError::Reqwest)?)
}
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)?;
//url borrow scope
{
let mut query=url.query_pairs_mut();//borrow here
//archaic roblox api uses 0 for new asset
match config.assetid{
0=>return Err(UploadError::AssetIdIsZero),
assetid=>{query.append_pair("assetid",assetid.to_string().as_str());},
}
if let Some(name)=config.name.as_deref(){
query.append_pair("name",name);
}
if let Some(description)=config.description.as_deref(){
query.append_pair("description",description);
}
if let Some(ispublic)=config.ispublic{
query.append_pair("ispublic",if ispublic{"True"}else{"False"});
}
if let Some(allow_comments)=config.allowComments{
query.append_pair("allowComments",if allow_comments{"True"}else{"False"});
}
if let Some(group_id)=config.groupId{
query.append_pair("groupId",group_id.to_string().as_str());
}
}
let resp=self.post(url,body).await.map_err(UploadError::PostError)?;
Ok(resp.json::<UploadResponse>().await.map_err(UploadError::Reqwest)?)
}
pub async fn download(&self,config:DownloadRequest)->Result<Vec<u8>,DownloadError>{
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(DownloadError::ParseError)?;
//url borrow scope
{
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(DownloadError::Reqwest)?;
let body=resp.bytes().await.map_err(DownloadError::Reqwest)?;
match maybe_gzip_decode(&mut std::io::Cursor::new(body)){
Ok(ReaderType::GZip(readable))=>read_readable(readable),
Ok(ReaderType::Raw(readable))=>read_readable(readable),
Err(e)=>Err(e),
}.map_err(DownloadError::IO)
}
pub async fn history_page(&self,config:HistoryPageRequest)->Result<HistoryPageResponse,HistoryPageError>{
let mut url=reqwest::Url::parse(format!("https://develop.roblox.com/v1/assets/{}/saved-versions",config.asset_id).as_str()).map_err(HistoryPageError::ParseError)?;
//url borrow scope
{
let mut query=url.query_pairs_mut();//borrow here
//query.append_pair("sortOrder","Asc");
//query.append_pair("limit","100");
//query.append_pair("count","100");
if let Some(cursor)=config.cursor.as_deref(){
query.append_pair("cursor",cursor);
}
}
Ok(self.get(url).await.map_err(HistoryPageError::Reqwest)?
.json::<HistoryPageResponse>().await.map_err(HistoryPageError::Reqwest)?)
}
pub async fn inventory_page(&self,config:InventoryPageRequest)->Result<InventoryPageResponse,InventoryPageError>{
let mut url=reqwest::Url::parse(format!("https://apis.roblox.com/toolbox-service/v1/creations/group/{}/10?limit=50",config.group).as_str()).map_err(InventoryPageError::ParseError)?;
//url borrow scope
{
let mut query=url.query_pairs_mut();//borrow here
if let Some(cursor)=config.cursor.as_deref(){
query.append_pair("cursor",cursor);
}
}
Ok(self.get(url).await.map_err(InventoryPageError::Reqwest)?
.json::<InventoryPageResponse>().await.map_err(InventoryPageError::Reqwest)?)
}
}

1
rbx_asset/src/lib.rs Normal file

@ -0,0 +1 @@
pub mod context;

File diff suppressed because it is too large Load Diff