Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #cueape 0.1
- #This script is intended to convert ape or flac + cue files to
- #ogg vorbis or mp3 files, setting the tags to the correct value,
- #obtained from the cue file.
- #REQUIREMENTS:
- # -Oggenc installed (it comes with vorbis-tools) if you want to encode into Ogg Vorbis.
- # -lame installed if you want to encode into mp3
- # -mac to decode ape files (Monkey's Audio)
- # -flac to decode flac files.
- #IF YOU FIND A BUG OR HAVE A SUGGESTION COMMENTO OR SIMPLY WANT TO CONTACT ME PLEASE MAIL ME TO
- #rafadev_*@gmail.com REMOVING THE "_*"
- #This is done to prevent spamming
- #Copyright (C) 2006 Rafael Ponieman - Buenos Aires, Argentina
- #This program is free software; you can redistribute it and/or
- #modify it under the terms of the GNU General Public License
- #as published by the Free Software Foundation; either version 2
- #of the License, or (at your option) any later version.
- #This program is distributed in the hope that it will be useful,
- #but WITHOUT ANY WARRANTY; without even the implied warranty of
- #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- #GNU General Public License for more details.
- #You should have received a copy of the GNU General Public License
- #along with this program; if not, write to the Free Software
- #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- #scripted by deX
- case "$1" in
- *.[aA][pP][eE] | *[fF][lL][aA][cC] )
- if [ ! -f "$1" ] ; then
- echo "Input file $1 doesn't exist"
- exit 1
- fi
- if [ ! -f "$2" ]; then
- echo "Cue input file $2 doesn't exist"
- exit 1
- fi ;;
- * )
- echo "Error: invalid input parameters"
- exit ;;
- esac
- #Testing parameters
- if [ "$3" != "-m" ] && [ "$3" != "-o" ] ; then
- echo -en "Invalid parameters\n"
- echo -en ""
- echo -en "Usage: cueape [input ape file] [input cue file] [parameters]\nParameters can be: -m for mp3 encoding or -o for ogg encoding.\n"
- exit 1
- fi
- #Need help with this one, coudn't solve it. I need to know how to check if a
- #program actually exists and is accesible
- #Checking for mac
- #[ -f $(which 'maca' >> /dev/null) ] || {
- # echo -en "You must have mac in your PATH.\nPlease install Monkey's Audio Codec\nYou can get it from http://sourceforge.net/projects/mac-port/\n"
- #}
- #Saving the position so as to return afterwards
- olddir="$(pwd)"
- #Going to target directory
- cd "$(dirname "$1")"
- #Checking for the output folder. If it's not there I create it
- [ ! -d "Output" ] && mkdir -p "Output"
- cp "$2" "Output/"
- #Decompress
- echo -en "\nCueape 0.1\n\n"
- echo -en "Starting conversion\n"
- #Checking filetype by extension and decompressing
- tmp="$(basename "$1")"
- tmp="${tmp##*.}"
- case "$tmp" in
- [fF][lL][aA][cC] )
- echo -en "Decompressing FLAC file\n\n"
- echo -en ""
- tm="$(basename "$1")"
- tm="${tm%.[fF][lL][aA][cC]}"
- out="$(flac "-d" "$1" -o "Output/${tm}.wav" )"
- ;;
- [aA][pP][eE] )
- echo -en "Decompressing APE file\n\n"
- echo -en ""
- tm="$(basename "$1")"
- tm="${tm%.[aA][pP][eE]}"
- out="$(mac "$1" "Output/${tm}.wav" "-d")"
- ;;
- * )
- echo "Error: line 99"
- esac
- cd "Output"
- echo -en "\nDecompression finished\n"
- echo -en "Starting reencoding\n\n"
- echo -en ""
- if [ "$3" = "-o" ] ; then
- #Calling oggenc. Saving output for future checking
- out="$(oggenc -q 6 -o "$tm.ogg" "$tm.wav")"
- echo -en "\nReencoding finished\n"
- echo -en "Splitting\n\n"
- echo -en ""
- out="$(mp3splt -c "$(basename "$2")" -o "@n+-+@t" "$tm.ogg")"
- else
- #Calling lame. Saving output for future checking
- out="$(lame --preset extreme "$tm.wav" "$tm.mp3")"
- echo -en "\nReencoding finished\n"
- echo -en "Splitting\n\n"
- echo -en ""
- #Using framemode becaus this settings are for VBR
- out="$(mp3splt -f -c "$(basename "$2")" -o "@n+-+@t" "$tm.mp3")"
- fi
- cd "$oldir"
- echo -en "\nProcessing finished successfully\n"
- echo -en ""
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment