(以内容“Category:脚本 splitape最早是用来分割APE文件的,现在稍微经过扩展,各种文件都能分割。 割完了能转成FLAC或其他格式,并且...”创建新页面) |
|||
第6行: | 第6行: | ||
用到了[[shntool]]。 | 用到了[[shntool]]。 | ||
+ | |||
+ | == 关于TAK == | ||
+ | |||
+ | TAK这个格式很少出现,但是碰见了还是麻烦。最简单的处理方法是下载TAK for windows,扔到某个目录,然后写个脚本,链接成takc: | ||
+ | <source lang="bash"> | ||
+ | wine /home/henryhu/soft/tak/Applications/Takc.exe $* | ||
+ | </source> | ||
+ | shntool会自己找takc,所以这样就行了。 | ||
+ | |||
+ | == 关于编码 == | ||
+ | 看来真该用个自动编码检测器…… | ||
+ | |||
+ | == code == | ||
<source lang="bash"> | <source lang="bash"> | ||
第12行: | 第25行: | ||
if [ $# -le 1 ]; then | if [ $# -le 1 ]; then | ||
− | + | echo "This tool would split ape file to flac file(s) according to cue sheet." | |
− | + | echo "You may also specify other formats." | |
− | + | echo "usage: $0 <cue file name> <ape file name> [<output format>]" | |
− | + | exit 1 | |
fi | fi | ||
第26行: | 第39行: | ||
if [ "$PA" != "" -o "$PB" != "" -o "$PC" != "" ]; then | if [ "$PA" != "" -o "$PB" != "" -o "$PC" != "" ]; then | ||
− | + | echo "Found non-UTF8 CUE file." | |
− | + | echo "=== 1.GBK ===" | |
− | + | cat "$1" | iconv -f gbk | head | |
+ | echo "=== 2.CP932 ===" | ||
+ | cat "$1" | iconv -f cp932 | head | ||
+ | echo "Which one? 1=gbk 2=cp932" | ||
+ | read encoding_id | ||
+ | if [ "$encoding_id" = "1" ]; then | ||
+ | encoding=gbk | ||
+ | else | ||
+ | encoding=cp932 | ||
+ | fi | ||
+ | echo "Found $encoding CUE file, converting..." | ||
+ | cat "$1" | iconv -f $encoding > /tmp/splitape.cue.tmp | ||
+ | CUEFILE=/tmp/splitape.cue.tmp | ||
fi | fi | ||
if [ "$3" = "" ]; then | if [ "$3" = "" ]; then | ||
− | + | OUTPUT_FORMAT="flac" | |
elif [ "$3" = "mp3" ]; then | elif [ "$3" = "mp3" ]; then | ||
OUTPUT_FORMAT="cust ext=mp3 lame - %f" | OUTPUT_FORMAT="cust ext=mp3 lame - %f" | ||
else | else | ||
− | + | OUTPUT_FORMAT=$3 | |
fi | fi | ||
2015年12月8日 (二) 00:58的最新版本
splitape最早是用来分割APE文件的,现在稍微经过扩展,各种文件都能分割。
割完了能转成FLAC或其他格式,并且根据metadata进行命名,之后用easytag处理一下就能内嵌metadata了,例如id3v2或者flac的tag之类。
用到了shntool。
关于TAK
TAK这个格式很少出现,但是碰见了还是麻烦。最简单的处理方法是下载TAK for windows,扔到某个目录,然后写个脚本,链接成takc:
wine /home/henryhu/soft/tak/Applications/Takc.exe $*
shntool会自己找takc,所以这样就行了。
关于编码
看来真该用个自动编码检测器……
code
#!/bin/sh
if [ $# -le 1 ]; then
echo "This tool would split ape file to flac file(s) according to cue sheet."
echo "You may also specify other formats."
echo "usage: $0 <cue file name> <ape file name> [<output format>]"
exit 1
fi
CUEFILE="$1"
FILETYPE=`file "$1"`
PA=`echo $FILETYPE | grep "ISO-8859"`
PB=`echo $FILETYPE | grep "extended-ASCII"`
PC=`echo $FILETYPE | grep "Non-ISO"`
if [ "$PA" != "" -o "$PB" != "" -o "$PC" != "" ]; then
echo "Found non-UTF8 CUE file."
echo "=== 1.GBK ==="
cat "$1" | iconv -f gbk | head
echo "=== 2.CP932 ==="
cat "$1" | iconv -f cp932 | head
echo "Which one? 1=gbk 2=cp932"
read encoding_id
if [ "$encoding_id" = "1" ]; then
encoding=gbk
else
encoding=cp932
fi
echo "Found $encoding CUE file, converting..."
cat "$1" | iconv -f $encoding > /tmp/splitape.cue.tmp
CUEFILE=/tmp/splitape.cue.tmp
fi
if [ "$3" = "" ]; then
OUTPUT_FORMAT="flac"
elif [ "$3" = "mp3" ]; then
OUTPUT_FORMAT="cust ext=mp3 lame - %f"
else
OUTPUT_FORMAT=$3
fi
echo "CUE File: $1"
echo "APE File: $2"
shntool split -f "$CUEFILE" -t %n_%p_%a_%t -o "$OUTPUT_FORMAT" "$2"