~voidraven/mp3me

f7777f4a7dc4978f36e6bcfde40d33fa1f3b14f6 — lotus 1 year, 3 months ago 1d069f9
fixed bug with extra dots in filenames, fixed spaces in filename bug, version bump, removed old comments
1 files changed, 13 insertions(+), 11 deletions(-)

M mp3me.sh
M mp3me.sh => mp3me.sh +13 -11
@@ 9,7 9,7 @@
#
# Dependencies: ffmpeg, gnu parallel
#
VERSION="0.2"
VERSION="0.3"

# default bitrate and jobs
BITRATE=320000


@@ 21,25 21,28 @@ SHIFT=0
# check if the file provided is a has a valid music extension
# cuts off extension and compares it
fun_is_music () {
    L_FILE_EXT=$(echo $1 | cut -d"." -f 2 | awk '{print tolower($0)}')
    L_FILE=$1
    L_FILE_EXT=$(echo "${L_FILE##*.}")
    if [ $L_FILE_EXT = "flac" ] || [ $L_FILE_EXT = "aac" ] || [ $L_FILE_EXT = "ogg" ] || [ $L_FILE_EXT = "wav" ] || [ $L_FILE_EXT = "m4a" ] ; then
	unset L_FILE L_FILE_EXT
	return 0    
    fi
    unset L_FILE L_FILE_EXT
    return 1
}


# echoes out all the valid music files in a directory
fun_echo_files () {
    SAVEIFS=$IFS
    IFS=$'\n'
    for FILE in $(ls $1) ; do
	#echo "we see: '$FILE'"
	if fun_is_music $FILE ; then
	    echo $FILE
    L_LWD=$(pwd)
    cd "$1"
    for FILE in * ; do
	if fun_is_music "$FILE" ; then
	    echo "$FILE"
	fi
    done
    IFS=$SAVEIFS
    cd $L_LWD
    unset L_LWD
}




@@ 66,7 69,7 @@ fun_check_jobs () {

# call this function to start the script
fun_run () {
    fun_echo_files $1 | parallel -j $JOBS ffmpeg -hide_banner -nostats -loglevel fatal -i "'$1'"/{} -b:a $BITRATE "'$1'"/{.}.mp3
    fun_echo_files "$1" | parallel -j $JOBS ffmpeg -hide_banner -nostats -loglevel fatal -i "'$1'"/{} -b:a $BITRATE "'$1'"/{.}.mp3
}




@@ 125,7 128,6 @@ shift $SHIFT

DIR=$@
if [ -d "$DIR" ] ; then
    #echo $DIR
    fun_run "$DIR"
else
   echo "directory not found: $DIR"