Skip to content

Commit

Permalink
yup
Browse files Browse the repository at this point in the history
  • Loading branch information
plainenglishh committed Feb 26, 2024
0 parents commit 5220f20
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


# LPM

/out
/lpm_modules
5 changes: 5 additions & 0 deletions .luaurc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"aliases": {
"lpm": "./lpm_modules/"
}
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"luau-lsp.require.directoryAliases": {
"@lpm/": "./lpm_modules/",
"@lune/": "~/.lune/.typedefs/0.8.0/"
},
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.types.definitionFiles": [
"C:\\Users\\plain/.lpm/.typedefs/1.0.1/def.d.lua"
]
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# asset-dl

Download assets by version.

## Usage

```bash
asset-dl <ASSET_ID> <DOWNLOAD PATH> [VERSION NUMBER]
```
11 changes: 11 additions & 0 deletions lpm-package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Autogenerated by Spearhead-Industries/lpm

author = "plainenglish"
description = "CLI Tool for downloading roblox assets by version."
entrypoint = "./src/main.lua"
licence = "MIT"
name = "asset-dl"
repository = ""
version = "1.0.0"

[dependencies]
34 changes: 34 additions & 0 deletions src/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local process = require("@lune/process");
local net = require("@lune/net");
local fs = require("@lune/fs");

function main(argc: number, argv: {string}): number
local asset_id = argv[1];
local output = argv[2];
local version_id = argv[3];

local ver = "";
if version_id then
ver = `version/{version_id}`;
end

local info = net.request({
url = `https://assetdelivery.roblox.com/v1/assetId/{asset_id}/{ver}`
});

assert(info.ok, "Request for asset metadata failed.");
info = net.jsonDecode(info.body);
assert(info.location, "No location available");

local asset = net.request({
url = info.location
});

assert(asset.ok, "Asset failed to download");

fs.writeFile(output, asset.body);

return 0;
end

process.exit(main(#process.args, process.args))

0 comments on commit 5220f20

Please sign in to comment.