-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodrinth-prefetch.nu
More file actions
26 lines (15 loc) · 835 Bytes
/
modrinth-prefetch.nu
File metadata and controls
26 lines (15 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def getModrinthId [] {
$in.downloads.0 | str substring 30..37
}
def getProjects [ids] {
{ scheme: "https", host: "api.modrinth.com", path: "v2/projects", params: { ids: ($ids | to json ) } } | url join | http get --headers {User-Agent: "example"} $in
}
export def modrinth-prefetch [modpack] {
let mrindex = ^unzip -p $modpack modrinth.index.json | from json;
let files = $mrindex.files;
let ids = $files | each { getModrinthId };
let projects = getProjects $ids;
let newfiles = $files | each {|filespec| let id = $filespec | getModrinthId; let project = $projects | where id == $id | first; $filespec | update env { $project | select server_side client_side | rename --block { str replace "_side" "" } } };
$mrindex | update files {$newfiles} | to json | save -f modrinth.index.json;
^zip $modpack modrinth.index.json
}