bms:bms

便利リンク

雑多

document.body.innerHTML = document.body.innerHTML.replace(/https:\/\/drive.google.com\/open\?id=(\w+)/g, "https:\/\/drive.google.com\/uc?export=download&id=$1")
document.body.innerHTML = document.body.innerHTML.replace(/https:\/\/drive.google.com\/file\/d\/(\w+)/g, "https:\/\/drive.google.com\/uc?export=download&id=$1")

F12のコンソールに入れる。

並列化した影響でエラー出力が重なる。それ以外は大丈夫(と思う)
並列数はCPU使用率とディスク使用率を見ながら調整する
成功した後にのみ削除するので途中で強制終了してもoggとwavのどっちかは残る
たまに削除が失敗する可能性がある
bmpをpngに置き換えるとかもコマンドの部分と拡張子を変えればできる

  • フォルダごとに見てるのでBGIだとそこがネックになっている
wavtoogg.py
import os, subprocess
from os.path import join, getsize
import multiprocessing
from multiprocessing.pool import ThreadPool
 
def call_oggenc(f):
    proc = subprocess.Popen(cmd + '\"' + f + '\"')
    proc.wait()
    outs = proc.returncode
    if outs == 0:
        try:
            os.remove(f)
        except PermissionError:
            print('{}の削除に失敗'.format(f))
    return outs
 
 
target = 'D:/BMS/' # target以下を見る
cmd = 'D:/BMS/bmstool/oggenc2.exe -q6 -Q ' # oggenc2.exeのパスを指定
success = 0
failure = 0
with ThreadPool(4) as pool:
    for root, dirs, files in os.walk(target):
        print(root)
        files = [f for f in files if f.endswith('.wav')]
        results = []
        for i in files:
            results.append(pool.apply_async(call_oggenc, (join(root, i),)))
        for result in results:
            result.wait()
            if result.get() == 0:
                success += 1
            else:
                failure += 1
print('success:{}, failure:{}'.format(success, failure))

mattaku氏のいくつかのBMSは、beatorajaで正常に再生されない。
対応していない形式が原因なので、ffmpegでoggなどに変換する。
https://ffmpeg.org/

convertwav.py
import os, subprocess
from os.path import join, getsize
import multiprocessing
from multiprocessing.pool import ThreadPool
 
target = 'D:/BMS/bmsbox/フォルダ分け済/copybms/'
cmd = 'D:/BMS/bmstool/ffmpeg.exe -y -i '
success = 0
failure = 0
 
def call_oggenc(f):
    proc = subprocess.Popen(cmd + '\"' + f + '\" ' + '\"' + f.replace('.wav', '.ogg') + '\"')
    proc.wait()
    outs = proc.returncode
    if outs == 0:
        try:
            os.remove(f)
        except PermissionError:
            print('{}の削除に失敗'.format(f))
    return outs
 
with ThreadPool(4) as pool:
    for root, dirs, files in os.walk(target):
        print(root)
        files = [f for f in files if f.endswith('.wav')]
        results = []
        for i in files:
            results.append(pool.apply_async(call_oggenc, (join(root, i),)))
        for result in results:
            result.wait()
            if result.get() == 0:
                success += 1
            else:
                failure += 1
print('success:{}, failure:{}'.format(success, failure))

TETRINET(葱&柳)、QNPM(FALL)は、そのままではbeatorajaで音が再生されない。拡張子のないファイルに.wavを付けることで音が鳴るようになる。(.bmeファイル側の変更は不要)

bash用、windowsならwslを入れる

getaria2c.sh
#!/usr/bin/env bash
# based on https://github.com/kajeagentspi/Datahoarder
set -e
 
URL=$1
ROOT_PATH=$2
LIST=./list.txt
MAX_CONNECTIONS_PER_SERVER=16
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
 
usage() {
	cat <<EOF
Uses wget's spider with aria2c's parallel for downloading open
directories.
Usage: $SCRIPT_NAME [options] URL PATH
EOF
}
 
spider() {
	local logfile=./opendir-$$.log
	wget -o $logfile -e robots=off -r --no-parent --spider -U "$USER_AGENT" "$URL" || true
	#Grabs all lines with the pattern --2017-07-12 15:40:31-- then from the results removes everthing that ends in / (meaning it's a directory
	#then removes pattern from every line
	grep -B 2 -E '... 404 Not Found|... 403 Forbidden|... 301 Moved Permanently' $logfile | \
	grep -i '^--[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]--' | \
	grep '[^'/']$'  | sed -e 's/^--[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]--  //g' > $logfile.tmp
	while read line; do
		sed -i "\|$line|d" $logfile
	done < $logfile.tmp
	cat $logfile | grep -i '^--[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]--' | \
	grep '[^'/']$'  | sed -e 's/^--[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]--  //g' > $LIST
	#Delete the folder made by wget (deletes all empty directories in the directory this script is run
	find . -type d -empty -delete #If you have a fix for this contact me since it should only delete the folder created by wget
}
 
if [[ -z $1 || -z $2 || $# -ge 3 ]]; then
	usage
	exit 1
fi
 
echo "Creating list of urls..."
spider
echo "List created!"

フォルダーの種類が勝手に変わってしまうことが原因なので、下の記事を参考にしてデフォルトをNotSpecifiedにする。
この記事はWindows Vista用とは書かれているが、Windows10でも同じ手順でできることを確認。
https://www.atmarkit.co.jp/fwin2k/win2ktips/1022foldertype/foldertype.html

  • 最終更新: 2021/09/20 05:23
  • by firiexp