Last active
October 5, 2021 03:52
-
-
Save kobalab/b7451446f2d3540184ab5cf4185f3405 to your computer and use it in GitHub Desktop.
天鳳名人戦の牌譜を一括変換するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
cd `echo $0|sed 's/\/[^\/]*$//'` | |
. etc/config.txt | |
[ ! $title ] && exit 1 | |
[ ! $dist ] && exit 2 | |
touch var/index.txt var/index.old | |
if [ $url ] | |
then | |
curl -sSL $url |\ | |
grep 'log=' | grep -v '&' |\ | |
sed 's/^.*log=//' | sed 's/".*$//' > var/index.new | |
[ -s var/index.new ] || exit 3 | |
mv var/index.new var/index.txt | |
fi | |
diff var/index.old var/index.txt > /dev/null && exit 4 | |
tenhou-log `paste -d : var/index.txt etc/title.txt | grep -v '^:'` \ | |
> var/$title.json | |
ex var/$title.json <<++ | |
%s/\\\\\\\\_/ /g | |
%s/\\\\\\\\\\//\\\\n/g | |
w! | |
++ | |
mv var/$title.json $dist | |
mv var/index.txt var/index.old | |
echo "$0: DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment