Unified · Split
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | # SPLIT: flac, wavpack, mac |
| 26 | 26 | # CONVERT: flac/flake, faac, libmp4v2, id3lib/mutagen, lame, vorbis-tools |
| 27 | 27 | # ART: ImageMagick |
| 28 | −# CHARSET: iconv | |
| 28 | +# CHARSET: iconv, enca | |
| 29 | 29 | # GAIN: flac, aacgain, mp3gain, vorbisgain |
| 30 | 30 | |
| 31 | 31 | # Exit codes: |
| @@ -51,6 +51,7 @@ DIR="." · 19 unmodified lines | ||
| 51 | 51 | OUTPATTERN="@artist/{@year - }@album/@track - @title.@ext" |
| 52 | 52 | COPYMASKS="Covers,covers,*.log,*.txt,*.jpg,*.cbr" |
| 53 | 53 | COPYFILES=1 |
| 54 | +ENCA_ARGS="" | |
| 54 | 55 | |
| 55 | 56 | # codecs default arguments |
| 56 | 57 | ENCARGS_flac="-8" |
| @@ -68,7 +69,7 @@ unset PIC INPATH CUE CHARSET · 11 unmodified lines | ||
| 68 | 69 | FORCE=0 |
| 69 | 70 | |
| 70 | 71 | # do not forget to update before commit |
| 71 | −VERSION=105 | |
| 72 | +VERSION=106 | |
| 72 | 73 | |
| 73 | 74 | HELP="\${cG}split2flac version: ${VERSION} |
| 74 | 75 | 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 | ||
| 84 | 85 | \$cG-f \${cU}FORMAT\$cZ - use specific output format (current is \$cP\${FORMAT}\$cZ) |
| 85 | 86 | \$cG-e \${cU}'ARG1 ARG2'\$cZ \$cR*\$cZ - encoder arguments (current is \$cP'\${ENCARGS}'\$cZ) |
| 86 | 87 | \$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 | 89 | \$cG-c \${cU}FILE\$cZ \$cR*\$cZ - use file as a cover image (does not work with \${cU}DIR\$cZ) |
| 88 | 90 | \$cG-nc \${cR}*\$cZ - do not set any cover images |
| 89 | 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 | 156 | -f) FORMAT=$2; update_encargs; shift;; |
| 155 | 157 | -e) ENCARGS=$2; shift;; |
| 156 | 158 | -eh) ENCHELP=1;; |
| 159 | + -enca) ENCA_ARGS=$2; shift;; | |
| 157 | 160 | -c) NOPIC=0; PIC=$2; shift;; |
| 158 | 161 | -nc) NOPIC=1;; |
| 159 | 162 | -C) COPYMASKS=$2; COPYFILES=1; shift;; |
| @@ -216,6 +219,7 @@ if [ ${SAVE} -eq 1 ]; then · 56 unmodified lines | ||
| 216 | 219 | echo "ENCARGS_mp3=\"${ENCARGS_mp3}\"" >> "${CONFIG}" |
| 217 | 220 | echo "ENCARGS_ogg=\"${ENCARGS_ogg}\"" >> "${CONFIG}" |
| 218 | 221 | echo "ENCARGS_wav=\"${ENCARGS_wav}\"" >> "${CONFIG}" |
| 222 | + echo "ENCA_ARGS=\"${ENCA_ARGS}\"" >> "${CONFIG}" | |
| 219 | 223 | $msg "${cP}Configuration saved$cZ\n" |
| 220 | 224 | fi |
| 221 | 225 | |
| @@ -322,6 +326,11 @@ split_file () { · 100 unmodified lines | ||
| 322 | 326 | |
| 323 | 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 | 334 | if [ $? -ne 0 ]; then |
| 326 | 335 | [ "${CHARSET}" = "utf-8" ] \ |
| 327 | 336 | && emsg "Cue sheet is not utf-8\n" \ |
| @@ -345,14 +354,13 @@ split_file () { · 17 unmodified lines | ||
| 345 | 354 | fi |
| 346 | 355 | fi |
| 347 | 356 | |
| 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}" | |
| 351 | 360 | |
| 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 | |
| 356 | 364 | fi |
| 357 | 365 | |
| 358 | 366 | SDIR=$(dirname "${FILE}") |