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
25# SPLIT: flac, wavpack, mac25# SPLIT: flac, wavpack, mac
26# CONVERT: flac/flake, faac, libmp4v2, id3lib/mutagen, lame, vorbis-tools26# CONVERT: flac/flake, faac, libmp4v2, id3lib/mutagen, lame, vorbis-tools
27# ART: ImageMagick27# ART: ImageMagick
28# CHARSET: iconv28# CHARSET: iconv, enca
29# GAIN: flac, aacgain, mp3gain, vorbisgain29# GAIN: flac, aacgain, mp3gain, vorbisgain
30 30
31# Exit codes:31# Exit codes:
@@ -51,6 +51,7 @@ DIR="." · 19 unmodified lines
51OUTPATTERN="@artist/{@year - }@album/@track - @title.@ext"51OUTPATTERN="@artist/{@year - }@album/@track - @title.@ext"
52COPYMASKS="Covers,covers,*.log,*.txt,*.jpg,*.cbr"52COPYMASKS="Covers,covers,*.log,*.txt,*.jpg,*.cbr"
53COPYFILES=153COPYFILES=1
54ENCA_ARGS=""
54 55
55# codecs default arguments56# codecs default arguments
56ENCARGS_flac="-8"57ENCARGS_flac="-8"
@@ -68,7 +69,7 @@ unset PIC INPATH CUE CHARSET · 11 unmodified lines
68FORCE=069FORCE=0
69 70
70# do not forget to update before commit71# do not forget to update before commit
71VERSION=10572VERSION=106
72 73
73HELP="\${cG}split2flac version: ${VERSION}74HELP="\${cG}split2flac version: ${VERSION}
74Splits 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.75Splits 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
84 \$cG-f \${cU}FORMAT\$cZ - use specific output format (current is \$cP\${FORMAT}\$cZ)85 \$cG-f \${cU}FORMAT\$cZ - use specific output format (current is \$cP\${FORMAT}\$cZ)
85 \$cG-e \${cU}'ARG1 ARG2'\$cZ \$cR*\$cZ - encoder arguments (current is \$cP'\${ENCARGS}'\$cZ)86 \$cG-e \${cU}'ARG1 ARG2'\$cZ \$cR*\$cZ - encoder arguments (current is \$cP'\${ENCARGS}'\$cZ)
86 \$cG-eh\$cZ - show help for current encoder and exit\$cZ87 \$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)
87 \$cG-c \${cU}FILE\$cZ \$cR*\$cZ - use file as a cover image (does not work with \${cU}DIR\$cZ)89 \$cG-c \${cU}FILE\$cZ \$cR*\$cZ - use file as a cover image (does not work with \${cU}DIR\$cZ)
88 \$cG-nc \${cR}*\$cZ - do not set any cover images90 \$cG-nc \${cR}*\$cZ - do not set any cover images
89 \$cG-C \${cU}MASKS\$cZ \$cR*\$cZ - specify wildcards for files to copy over (current is \$cP'\${COPYMASKS}'\$cZ)91 \$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
154 -f) FORMAT=$2; update_encargs; shift;;156 -f) FORMAT=$2; update_encargs; shift;;
155 -e) ENCARGS=$2; shift;;157 -e) ENCARGS=$2; shift;;
156 -eh) ENCHELP=1;;158 -eh) ENCHELP=1;;
159 -enca) ENCA_ARGS=$2; shift;;
157 -c) NOPIC=0; PIC=$2; shift;;160 -c) NOPIC=0; PIC=$2; shift;;
158 -nc) NOPIC=1;;161 -nc) NOPIC=1;;
159 -C) COPYMASKS=$2; COPYFILES=1; shift;;162 -C) COPYMASKS=$2; COPYFILES=1; shift;;
@@ -216,6 +219,7 @@ if [ ${SAVE} -eq 1 ]; then · 56 unmodified lines
216 echo "ENCARGS_mp3=\"${ENCARGS_mp3}\"" >> "${CONFIG}"219 echo "ENCARGS_mp3=\"${ENCARGS_mp3}\"" >> "${CONFIG}"
217 echo "ENCARGS_ogg=\"${ENCARGS_ogg}\"" >> "${CONFIG}"220 echo "ENCARGS_ogg=\"${ENCARGS_ogg}\"" >> "${CONFIG}"
218 echo "ENCARGS_wav=\"${ENCARGS_wav}\"" >> "${CONFIG}"221 echo "ENCARGS_wav=\"${ENCARGS_wav}\"" >> "${CONFIG}"
222 echo "ENCA_ARGS=\"${ENCA_ARGS}\"" >> "${CONFIG}"
219 $msg "${cP}Configuration saved$cZ\n"223 $msg "${cP}Configuration saved$cZ\n"
220fi224fi
221 225
@@ -322,6 +326,11 @@ split_file () { · 100 unmodified lines
322 326
323 CUESHEET=$(iconv -f "${CHARSET}" -t utf-8 "${CUE}" 2>/dev/null)327 CUESHEET=$(iconv -f "${CHARSET}" -t utf-8 "${CUE}" 2>/dev/null)
324 328
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
325 if [ $? -ne 0 ]; then334 if [ $? -ne 0 ]; then
326 [ "${CHARSET}" = "utf-8" ] \335 [ "${CHARSET}" = "utf-8" ] \
327 && emsg "Cue sheet is not utf-8\n" \336 && emsg "Cue sheet is not utf-8\n" \
@@ -345,14 +354,13 @@ split_file () { · 17 unmodified lines
345 fi354 fi
346 fi355 fi
347 356
348 if [ -n "${CHARSET}" -a "${CHARSET}" != "utf-8" ]; then357 # save converted cue sheet
349 CUE="${TMPCUE}"358 CUE="${TMPCUE}"
350 echo "${CUESHEET}" > "${CUE}"359 echo "${CUESHEET}" > "${CUE}"
351 360
352 if [ $? -ne 0 ]; then361 if [ $? -ne 0 ]; then
353 emsg "Unable to save converted cue sheet\n"362 emsg "Unable to save converted cue sheet\n"
354 return 1363 return 1
355 fi
356 fi364 fi
357 365
358 SDIR=$(dirname "${FILE}")366 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