Skip to content

Commit

Permalink
More songs
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasasfk committed Sep 30, 2023
1 parent 122e4e7 commit 6f7df5b
Show file tree
Hide file tree
Showing 93 changed files with 258,704 additions and 5,633 deletions.
1 change: 1 addition & 0 deletions fs2dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def create_dd_tracks_from_fs(fs_map_dir: str) -> DDBeatMapInfoFile:

create_ticks = yyyymmdd_to_ticks(datetime.now().strftime('%Y%m%d'))
dd_beat_map_info = DDBeatMapInfoFile(
OstId=random_9_digit_int(),
CreateTicks=create_ticks,
CreateTime=str(create_ticks),
BeatMapId=random_9_digit_int(),
Expand Down
51 changes: 47 additions & 4 deletions resources/drs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,54 @@ find . -type f -name "song.json" -exec rm -f {} \;
```

```bash
# Find all M4A audio files in the current directory and its subdirectories, and convert them to ogg format using ffmpeg.
find . -type f -name "*.m4a" -exec sh -c 'ffmpeg -y -i "$1" "${1%.m4a}.ogg"' sh {} \;
# remove 10 seconds from all m4as and convert to ogg files
find . -type f -name "*.m4a" -exec sh -c 'DURATION=$(ffprobe -i "$0" -show_entries format=duration -v quiet -of csv="p=0"); TRIM_TIME=$(awk "BEGIN {print $DURATION - 10}"); ffmpeg -y -ss 0 -t $TRIM_TIME -i "$0" "${0%.m4a}.ogg"' {} \;
```

```bash
# remove 10 seconds from all ogg files
find . -type f -name "*.m4a" -exec sh -c 'DURATION=$(ffprobe -i "$0" -show_entries format=duration -v quiet -of csv="p=0"); TRIM_TIME=$(awk "BEGIN {print $DURATION - 10}"); ffmpeg -ss 0 -t $TRIM_TIME -i "$0" "${0%.m4a}.ogg"' {} \;
#!/bin/bash
find . -type f -name "*.2dx" -exec sh -c '
dir=$(dirname "$0")
filename=$(basename "$0")
file_without_extension="${filename%.*}"
if echo "$filename" | grep -qE "clip|pre"; then
echo "Skipping $filename"
exit 0
fi
cd "$dir" || exit 1
2dxdump "$filename"
ffmpeg -y -i "0.wav" "${file_without_extension}clip1.ogg"
' {} \;
```

```bash
find . -type f -name "1.wav" -exec rm -f {} \;
```

```bash
#!/bin/bash
find . -type f -name "*.s3p" -exec sh -c '
dir=$(dirname "$0")
filename=$(basename "$0")
file_without_extension="${filename%.*}"
output_file="${file_without_extension}clip1.ogg"
if echo "$filename" | grep -qE "clip|pre"; then
echo "Skipping $filename"
exit 0
fi
cd "$dir" || exit 1
if [ -f "$output_file" ]; then
echo "Skipping as $output_file already exists."
exit 0
fi
# uhh yea deal with it lol
../../../../../.venv/Scripts/python ../../../../../s3p_unpack.py --input "$filename"
ffmpeg -y -i "0.wma" "$output_file"
' {} \;
```
2 changes: 1 addition & 1 deletion resources/drs/datax/music/00298/songs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"song_id": 298,
"difficulties": {
"difficulty_1a": {
Expand Down
44 changes: 44 additions & 0 deletions s3p_unpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from __future__ import annotations

import argparse
import os
import struct


def get_s3v0_header(file):
header = {}
magic = file.read(4)
if magic != b'S3V0':
raise ValueError('Invalid S3V0 magic')

header['size'], header['original_size'], header['data_hash'] = struct.unpack(
'<III', file.read(12),
)
file.read(16) # skip 16 bytes
return header


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--input', help='Input S3P file', required=True)
args = parser.parse_args()

with open(args.input, 'rb') as infile:
magic = infile.read(4)
if magic != b'S3P0':
raise ValueError('Invalid S3P0 magic')

num_files = struct.unpack('<I', infile.read(4))[0]
index = []

for i in range(num_files):
offset, size = struct.unpack('<II', infile.read(8))
index.append((offset, size))

for i, (offset, size) in enumerate(index):
infile.seek(offset, 0)
header = get_s3v0_header(infile)
data = infile.read(header['original_size'])
output_file = os.path.join(f'{i}.wma')
with open(output_file, 'wb') as outfile:
outfile.write(data)
Loading

0 comments on commit 6f7df5b

Please sign in to comment.