89 lines
3.1 KiB
Markdown
89 lines
3.1 KiB
Markdown
# Process for Uploading Charts
|
|
|
|
1. Find a bms bundle/zip ie. `p_stands_for_party_newbga_ogg.zip`
|
|
2. Upload zip to BackBlaze B2 storage bucket
|
|
3. Open the admin dashboard for bms-repository
|
|
4. Unzip the bms bundle/zip on your local machine
|
|
5. For each bms file in the unzipped folder:
|
|
1. Copy the zip friendly url from BackBlaze B2
|
|
2. Create a new chart in the admin dashboard
|
|
3. Paste the zip friendly url into the `resourceUri` field
|
|
4. Set the `md5` and `sha256` fields to the md5 and sha256 of the bms file
|
|
5. Set the `name` field to the name of the chart + difficulty
|
|
- ie. `"P" stands for "Party!" [Another]`
|
|
|
|
## Script for generating chart JSON
|
|
Run in the freshly unzipped folder
|
|
|
|
```shell
|
|
#!/bin/bash
|
|
|
|
FILES=($(find . -name "*.bm*"));
|
|
|
|
JSON="["
|
|
for CHART in "${FILES[@]}"
|
|
do
|
|
MD5=$(md5sum "$CHART" | cut -d ' ' -f 1)
|
|
SHA256=$(sha256sum "$CHART" | cut -d ' ' -f 1)
|
|
TITLE=$(cat "$CHART" | grep "#TITLE" | sed -e s/^.*\#TITLE// | xargs | tr -d '\r')
|
|
UUID=$(uuidgen)
|
|
COMMENT="Extracted from $CHART"
|
|
|
|
JSON+=$(jq -n \
|
|
--arg chartId "$UUID" \
|
|
--arg md5 "$MD5" \
|
|
--arg sha256 "$SHA256" \
|
|
--arg name "$TITLE" \
|
|
--arg resourceUri "$1" \
|
|
--arg comment "$COMMENT" \
|
|
'. += $ARGS.named')
|
|
done
|
|
|
|
echo "$JSON]" | sed -e s/\}\{/},{/g | jq # Lazy, couldn't get JQ append working lol
|
|
```
|
|
|
|
First argument is the upload url
|
|
```shell
|
|
./export.sh https://example.com/zips/myzip.zip
|
|
```
|
|
|
|
While authenticated as an admin user, hit the `bulk` endpoint with the generated JSON after confirming that it is valid.
|
|
|
|
|
|
```shell
|
|
curl --request POST \
|
|
--url https://<API_URL>/chart/admin/bulk \
|
|
--header 'Authorization: Bearer Token' \
|
|
--header 'Content-Type: application/json' \
|
|
--data '[
|
|
{
|
|
"chartId": "9923c511-355c-4ed8-9551-4b31fec45560",
|
|
"md5": "8d80d1732fa4c81dcbd4ddfd1673d949",
|
|
"sha256": "b796cdef4fa8865035d282be275cbda878203359c8ba630ac9ba619b52322346",
|
|
"name": "P stands for Party! [Hyper]",
|
|
"resourceUri": "https://f002.backblazeb2.com/file/bms-chart-storage-staging/p_stands_for_party_newbga_ogg.zip"
|
|
},
|
|
{
|
|
"chartId": "4684b205-d1d9-4bcc-ace3-47e044988ff0",
|
|
"md5": "b81eea46f8600fabab3e3f6bce2a2cc7",
|
|
"sha256": "806c56cbb413d390c84a8d49b9888fecaac4571d5a2337b450ec23f28b10c725",
|
|
"name": "P stands for Party! [Another]",
|
|
"resourceUri": "https://f002.backblazeb2.com/file/bms-chart-storage-staging/p_stands_for_party_newbga_ogg.zip"
|
|
},
|
|
{
|
|
"chartId": "ce9af400-4726-49ed-9ee2-13652bd98410",
|
|
"md5": "b963e1f212e3783cfd566b59b5cb472d",
|
|
"sha256": "17588424eea6479ed90dec7d7ffa1991bc049fd4c2ea218a1408f8febed64121",
|
|
"name": "P stands for Party! [Beginner]",
|
|
"resourceUri": "https://f002.backblazeb2.com/file/bms-chart-storage-staging/p_stands_for_party_newbga_ogg.zip"
|
|
},
|
|
{
|
|
"chartId": "9834898f-c0ba-4a4f-a0b9-ac701e8a6f3a",
|
|
"md5": "c6c5e5e20b53983ba59252ddcc205b5b",
|
|
"sha256": "a60bdb0e6d2cd9d54c53decc33932b2eee7cd15966e0dd0666c368ff58070a3a",
|
|
"name": "P stands for Party! [Normal]",
|
|
"resourceUri": "https://f002.backblazeb2.com/file/bms-chart-storage-staging/p_stands_for_party_newbga_ogg.zip"
|
|
}
|
|
]'
|
|
```
|