first commit

This commit is contained in:
yuuki 2024-07-31 12:12:54 +09:00
commit def544bfd7
2 changed files with 32 additions and 0 deletions

3
requirements.txt Normal file
View file

@ -0,0 +1,3 @@
nkf==1.0.4
git+https://github.com/yuukiwww/tjaf.git@ebe79e3696d4e1ce0fcdae9e4164e7fd6288b22a
requests==2.32.3

29
upload.py Normal file
View file

@ -0,0 +1,29 @@
from argparse import ArgumentParser
from pathlib import Path
from nkf import nkf
from tjaf import Tja
from requests import post
def app():
parser = ArgumentParser()
parser.add_argument('folder', help='Folder path to process')
args = parser.parse_args()
folder = Path(args.folder)
for tja in folder.rglob("*.tja"):
tja_data = tja.read_bytes()
tja_text = nkf("-wd", tja_data).decode("utf-8")
wave_str = Tja(tja_text).common_headers["WAVE"].as_str()
wave = tja.parent / Path(wave_str)
if wave.is_file():
res = post("https://taikoapp.uk/upload", files={
"file_tja": tja_data,
"file_music": wave.read_bytes(),
})
res.raise_for_status()
print(tja, wave)
print(str(res.status_code) + ":", res.text)
if __name__ == "__main__":
app()