1
Fork 0

Make massive progress towards deployment

This commit is contained in:
prescientmoon 2025-02-11 05:55:57 +01:00
parent ce18db3d14
commit 489568650a
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
62 changed files with 2868 additions and 1311 deletions

View file

@ -1,12 +1,12 @@
#!/usr/bin/env bash
if [ "$#" != 2 ]; then
echo "Usage: $0 <from> <to>"
if [ "$#" != 1 ]; then
echo "Usage: $0 <to>"
exit 1
fi
from=$1
to=$2
from=$SHIMMERING_DATA_DIR/db.sqlite
to=$1
echo "Creating destination..."
rm -rf "$to"

View file

@ -1,123 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -p "pkgs.python3.withPackages (p: with p; [tabulate])"
#!nix-shell -i python3
import csv
import os
import sqlite3
data_dir = os.environ.get("SHIMMERING_DATA_DIR")
config_dir = os.environ.get("SHIMMERING_CONFIG_DIR")
db_path = data_dir + "/db.sqlite"
conn = sqlite3.connect(db_path)
# {{{ Import songs
def import_charts_from_csv():
chart_count = 0
song_count = 0
shorthand_count = 0
with open(config_dir + "/charts.csv", mode="r") as file:
for i, row in enumerate(csv.reader(file)):
if i == 0 or len(row) == 0:
continue
[
title,
artist,
pack,
*charts,
side,
bpm,
version,
date,
ext_version,
ext_date,
original,
] = map(lambda v: v.strip().replace("\n", " "), row)
existing_count = conn.execute(
"""
SELECT count()
FROM songs
WHERE title=?
AND artist=?
""",
(title, artist),
).fetchone()[0]
if existing_count > 0:
continue
song_count += 1
print(f'Importing "{title}" by "{artist}"')
song_id = conn.execute(
"""
INSERT INTO songs(title,artist,pack,side,bpm)
VALUES (?,?,?,?,?)
RETURNING id
""",
(title, artist, pack, side.lower(), bpm),
).fetchone()[0]
for i in range(4):
[note_design, level, cc, note_count] = charts[i * 4 : (i + 1) * 4]
if note_design == "N/A":
continue
chart_count += 1
[difficulty, level] = level.split(" ")
conn.execute(
"""
INSERT INTO charts(song_id, difficulty, level, note_count, chart_constant, note_design)
VALUES(?,?,?,?,?, ?)
""",
(
song_id,
difficulty,
level,
int(note_count.replace(",", "").replace(".", "")),
int(round(float(cc) * 100)),
note_design if len(note_design) else None,
),
)
with open(config_dir + "/shorthands.csv", mode="r") as file:
for i, row in enumerate(csv.reader(file)):
if i == 0 or len(row) == 0:
continue
shorthand_count += 1
[name, difficulty, artist, shorthand] = map(lambda v: v.strip(), row)
conn.execute(
f"""
UPDATE charts
SET shorthand=?
WHERE EXISTS (
SELECT 1 FROM songs s
WHERE s.id = charts.song_id
AND s.title=?
{"" if artist=="" else "AND artist=?"}
)
{"" if difficulty=="" else "AND difficulty=?"}
""",
[
shorthand,
name,
*([] if artist == "" else [artist]),
*([] if difficulty == "" else [difficulty]),
],
)
conn.commit()
print(
f"Imported {chart_count} charts, {song_count} songs, and {shorthand_count} shorthands"
)
# }}}
import_charts_from_csv()

View file

@ -1,25 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -p libsixel
#!nix-shell -i bash
if [ "$#" != 2 ]; then
echo "Usage: $0 <name> <url>"
exit 1
fi
name=$1
url=$2
curr=$(pwd)
dir_path=$SHIMMERING_ASSET_DIR/songs/raw/$name
mkdir -p $dir_path
cd $dir_path
http GET "$url" > temp
magick ./temp ./base.jpg
magick ./base.jpg -resize 256x256 ./base_256.jpg
rm temp
img2sixel ./base.jpg
cd $curr

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
dir_path=$SHIMMERING_ASSETS_DIR/songs/raw
# Find all files in the directory and its subdirectories
find "$dir_path" -type f | while read -r file; do
# Get the filename without the directory path
filename=$(basename "$file")
# Check if the filename starts with "1080_"
if [[ $filename == 1080_* ]]; then
# Remove the "1080_" prefix
new_filename="${filename#1080_}"
# Get the directory path without the filename
file_dir=$(dirname "$file")
# Construct the new file path
new_file_path="$file_dir/$new_filename"
# Rename the file
mv "$file" "$new_file_path"
echo "Renamed: $file -> $new_file_path"
fi
done
mv $dir_path/dropdead/3*.jpg $dir_path/overdead 2>/dev/null
mv $dir_path/singularity/3*.jpg $dir_path/singularityvvvip 2>/dev/null
mv $dir_path/redandblue/3*.jpg $dir_path/redandblueandgreen 2>/dev/null
mv $dir_path/ignotus/3*.jpg $dir_path/ignotusafterburn 2>/dev/null
rm -rf $dir_path/ifirmxrmx 2>/dev/null

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
echo "delete from songs" | sqlite3 $SHIMMERING_DATA_DIR/db.sqlite
echo "delete from charts" | sqlite3 $SHIMMERING_DATA_DIR/db.sqlite
./scripts/main.py import charts