]> diplodocus.org Git - flac-archive/blobdiff - fa-rip
Support a -t track-count option to fa-rip and mkcue, so we can skip
[flac-archive] / fa-rip
diff --git a/fa-rip b/fa-rip
index c331648..4755822 100755 (executable)
--- a/fa-rip
+++ b/fa-rip
@@ -19,6 +19,24 @@ function get_cddev {
     return 1
 }
 
+trackcount=
+while getopts 'd:t:' ch; do
+    case ${ch} in
+        d)
+            CDDEV=${OPTARG}
+            export CDDEV
+            ;;
+        t)
+            trackcount=${OPTARG}
+            ;;
+        ?)
+            echo 'fa-rip [-t track-count]' >&2
+            exit 2
+            ;;
+    esac
+done
+shift $((${OPTIND} - 1))
+
 if [[ -z ${CDDEV} ]]; then
     if ! get_cddev; then
         echo 'CDDEV environment variable not set, defaults did not work' >&2
@@ -30,9 +48,12 @@ fi
 dir=$(mktemp -d flac-archive.XXXXXXXXXX)
 cd ${dir}
 
-mkcue ${CDDEV} > cue
-
-trackcount=$(grep -c 'TRACK.*AUDIO' cue)
+if [[ -z ${trackcount} ]]; then
+    mkcue ${CDDEV} > cue
+    trackcount=$(grep -c 'TRACK.*AUDIO' cue)
+else
+    mkcue -t ${trackcount} ${CDDEV} > cue
+fi
 
 fa-tags ${trackcount}