Skip to content

Instantly share code, notes, and snippets.

@kobalab
Last active October 5, 2021 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobalab/b7451446f2d3540184ab5cf4185f3405 to your computer and use it in GitHub Desktop.
Save kobalab/b7451446f2d3540184ab5cf4185f3405 to your computer and use it in GitHub Desktop.
天鳳名人戦の牌譜を一括変換するスクリプト
#!/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