History

use enca to detect charset automatically. Fixes issue 23

Serge Zirukin committed 15 years ago

Commit bef52a21 parent c7f56421 file · +17 −9Browse files

Unified · Split

split2flac.sh+17−9
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 # SPLIT: flac, wavpack, mac
2626 # CONVERT: flac/flake, faac, libmp4v2, id3lib/mutagen, lame, vorbis-tools
2727 # ART: ImageMagick
28−# CHARSET: iconv
28+# CHARSET: iconv, enca
2929 # GAIN: flac, aacgain, mp3gain, vorbisgain
3030
3131 # Exit codes:
@@ -51,6 +51,7 @@ DIR="." · 19 unmodified lines
5151 OUTPATTERN="@artist/{@year - }@album/@track - @title.@ext"
5252 COPYMASKS="Covers,covers,*.log,*.txt,*.jpg,*.cbr"
5353 COPYFILES=1
54+ENCA_ARGS=""
5455
5556 # codecs default arguments
5657 ENCARGS_flac="-8"
@@ -68,7 +69,7 @@ unset PIC INPATH CUE CHARSET · 11 unmodified lines
6869 FORCE=0
6970
7071 # do not forget to update before commit
71−VERSION=105
72+VERSION=106
7273
7374 HELP="\${cG}split2flac version: ${VERSION}
7475 Splits one big \${cU}APE/FLAC/WV/WAV\$cZ\$cG audio image (or a collection) into \${cU}FLAC/M4A/MP3/OGG_VORBIS/WAV\$cZ\$cG tracks with tagging and renaming.
@@ -84,6 +85,7 @@ Usage: \${cZ}split2\${FORMAT}.sh [\${cU}OPTIONS\$cZ] \${cU}FILE\$cZ [\${cU}OPTIO · 9 unmodified lines
8485 \$cG-f \${cU}FORMAT\$cZ - use specific output format (current is \$cP\${FORMAT}\$cZ)
8586 \$cG-e \${cU}'ARG1 ARG2'\$cZ \$cR*\$cZ - encoder arguments (current is \$cP'\${ENCARGS}'\$cZ)
8687 \$cG-eh\$cZ - show help for current encoder and exit\$cZ
88+ \$cG-enca \${cU}'ARG1 ARG2'\$cZ \$cR*\$cZ - enca additional arguments (current is \$cP'\${ENCA_ARGS}'\$cZ)
8789 \$cG-c \${cU}FILE\$cZ \$cR*\$cZ - use file as a cover image (does not work with \${cU}DIR\$cZ)
8890 \$cG-nc \${cR}*\$cZ - do not set any cover images
8991 \$cG-C \${cU}MASKS\$cZ \$cR*\$cZ - specify wildcards for files to copy over (current is \$cP'\${COPYMASKS}'\$cZ)
@@ -154,6 +156,7 @@ while [ "$1" ]; do · 64 unmodified lines
154156 -f) FORMAT=$2; update_encargs; shift;;
155157 -e) ENCARGS=$2; shift;;
156158 -eh) ENCHELP=1;;
159+ -enca) ENCA_ARGS=$2; shift;;
157160 -c) NOPIC=0; PIC=$2; shift;;
158161 -nc) NOPIC=1;;
159162 -C) COPYMASKS=$2; COPYFILES=1; shift;;
@@ -216,6 +219,7 @@ if [ ${SAVE} -eq 1 ]; then · 56 unmodified lines
216219 echo "ENCARGS_mp3=\"${ENCARGS_mp3}\"" >> "${CONFIG}"
217220 echo "ENCARGS_ogg=\"${ENCARGS_ogg}\"" >> "${CONFIG}"
218221 echo "ENCARGS_wav=\"${ENCARGS_wav}\"" >> "${CONFIG}"
222+ echo "ENCA_ARGS=\"${ENCA_ARGS}\"" >> "${CONFIG}"
219223 $msg "${cP}Configuration saved$cZ\n"
220224 fi
221225
@@ -322,6 +326,11 @@ split_file () { · 100 unmodified lines
322326
323327 CUESHEET=$(iconv -f "${CHARSET}" -t utf-8 "${CUE}" 2>/dev/null)
324328
329+ # try to guess the charset using enca
330+ if [ $? -ne 0 ]; then
331+ CUESHEET=$(enconv ${ENCA_ARGS} -x utf8 < "${CUE}" 2>/dev/null)
332+ fi
333+
325334 if [ $? -ne 0 ]; then
326335 [ "${CHARSET}" = "utf-8" ] \
327336 && emsg "Cue sheet is not utf-8\n" \
@@ -345,14 +354,13 @@ split_file () { · 17 unmodified lines
345354 fi
346355 fi
347356
348− if [ -n "${CHARSET}" -a "${CHARSET}" != "utf-8" ]; then
349− CUE="${TMPCUE}"
350− echo "${CUESHEET}" > "${CUE}"
357+ # save converted cue sheet
358+ CUE="${TMPCUE}"
359+ echo "${CUESHEET}" > "${CUE}"
351360
352− if [ $? -ne 0 ]; then
353− emsg "Unable to save converted cue sheet\n"
354− return 1
355− fi
361+ if [ $? -ne 0 ]; then
362+ emsg "Unable to save converted cue sheet\n"
363+ return 1
356364 fi
357365
358366 SDIR=$(dirname "${FILE}")

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t