mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-18 03:08:57 +01:00
Updated grep detection with README changes and better colon support
This commit is contained in:
parent
c500062c96
commit
1017f9a6e7
15
AAXtoMP3
15
AAXtoMP3
@ -5,7 +5,14 @@ set -o errexit -o noclobber -o nounset -o pipefail
|
||||
codec=libmp3lame
|
||||
extension=mp3
|
||||
mode=chaptered
|
||||
grep=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep")
|
||||
GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep")
|
||||
|
||||
if ! [[ $(type -P "$GREP") ]]; then
|
||||
echo "$GREP (GNU grep) is not in your PATH"
|
||||
echo "Without it, this script will break."
|
||||
echo "On macOS, you may want to try: brew install grep"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo "Usage: bash AAXtoMP3.sh [--flac] [--single] AUTHCODE {FILES}"
|
||||
@ -49,11 +56,11 @@ save_metadata() {
|
||||
get_metadata_value() {
|
||||
local key
|
||||
key="$1"
|
||||
normalize_whitespace "$(grep --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2 | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')"
|
||||
normalize_whitespace "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')"
|
||||
}
|
||||
|
||||
get_bitrate() {
|
||||
get_metadata_value bitrate | grep --only-matching '[0-9]\+'
|
||||
get_metadata_value bitrate | $GREP --only-matching '[0-9]\+'
|
||||
}
|
||||
|
||||
normalize_whitespace() {
|
||||
@ -61,7 +68,7 @@ normalize_whitespace() {
|
||||
}
|
||||
|
||||
chapter_padding() {
|
||||
chaptercount=$(grep -Pc "title\s+:\sChapter\s\d+" $metadata_file)
|
||||
chaptercount=$($GREP -Pc "title\s+:\sChapter\s\d+" $metadata_file)
|
||||
if [[ $chaptercount -gt 9 && $chaptercount -lt 100 ]]
|
||||
then
|
||||
chapter=$(sed -e 's/Chapter \([[:digit:]]\)$/Chapter 0\1/' <<<$chapter)
|
||||
|
@ -24,7 +24,7 @@ can obtain this string from a tool like [audible-activator](https://github.com/i
|
||||
|
||||
## OSX
|
||||
Thanks to thibaudcolas, this script has been tested on OSX 10.11.6 El Capitan. YMMV, but it should work for
|
||||
conversions in OSX.
|
||||
conversions in OSX. It is recommended that you install GNU grep using 'brew install grep' for chapter padding to work.
|
||||
|
||||
## AUR
|
||||
Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur.archlinux.org/packages/aaxtomp3-git/). Note that you will still need to extract your activation bytes before use.
|
||||
|
Loading…
Reference in New Issue
Block a user