rewrite flac2mp3 from python to shell

 

File modified: bin/flac2mp3.py bin/flac2mp3.sh

Change330 at Fri Aug 06 22:59:26 2010 +0200 by Ivan Kanis <ivan@tao>

diff -r 4cfc48086d40 -r 86bfdcdc9f03 bin/flac2mp3.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/flac2mp3.sh	Fri Aug 06 22:59:26 2010 +0200
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+check () {
+    if test $? -ne 0
+    then
+	printf "$1\n"
+	exit 1
+    fi
+}
+
+printf "artist: "
+read artist
+printf "album: "
+read album
+
+for file in *.flac
+do
+    file_mp3="`echo ${file} | sed s/flac$/mp3/`"
+    flac --silent -cd "${file}" | lame -h - "${file_mp3}" > /dev/null 2>&1
+    check "Fail to convert ${file} to ${file_mp3}"
+    track=`echo ${file} | cut -b 1-2`
+    title="`expr "${file}" : ".* - \(.*\).flac"`"
+    mp3info -t "${title}" -a "${artist}" -l "${album}" -n "${track}" \
+"${file_mp3}"
+    check "Fail to tag ${file_mp3}"
+    rm "${file}"
+    check "Fail to remove ${file}"
+done
+
+# Local Variables:
+# compile-command: "sh flac2mp3.sh"
+# End:
+
+# Copyright (C) 2010 Ivan Kanis
+# Author: Ivan Kanis
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


back