From 5cccdcb5532631dc55b31bd06b9207eed6a22c81 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 19 Jul 2025 10:13:12 +0200 Subject: [PATCH] change libs with default execute interface --- albentohandy | 51 +++++++++++++---------------------- libs/flac.sh | 7 +++++ libs/mp3.sh | 7 +++++ libs/opus.sh | 7 +++++ libs/{voribs.sh => vorbis.sh} | 7 +++++ 5 files changed, 47 insertions(+), 32 deletions(-) rename libs/{voribs.sh => vorbis.sh} (96%) diff --git a/albentohandy b/albentohandy index 1c43c71..ea43af1 100755 --- a/albentohandy +++ b/albentohandy @@ -103,6 +103,21 @@ check_programms() || return $? } +execute_program() +{ + local lib="$1" + local workdir="$2" + + [ -f "$LIBS/$lib" ] \ + || errlog "file $LIBS/$lib does not exists" \ + || return $? + + mkdir -p "$workdir" + make_symlinks_to_work "albumlist" "$workdir" "$MUSICPATH" || return $? + source "$LIBS/$lib" || return $? + execute "$workdir" || return $? +} + convert_process() { local format="$1" @@ -112,39 +127,11 @@ convert_process() || errlog "file albumlist does not exists" \ || return $? - mkdir -p $workdir - make_symlinks_to_work "albumlist" "$workdir" $MUSICPATH \ - || return $? - case "$format" in - "mp3") - [ -f "$LIBS/mp3.sh" ] \ - || errlog "file $LIBS/mp3.sh does not exists" \ - || return $? - source "$LIBS/mp3.sh" || return $? - convert_flac_to_mp3 "$workdir" || return $? - ;; - "flac") - [ -f "$LIBS/flac.sh" ] \ - || errlog "file $LIBS/mp3.sh does not exists" \ - || return $? - source "$LIBS/flac.sh" || return $? - picture_to_flac "$workdir" - ;; - "opus") - [ -f "$LIBS/opus.sh" ] \ - || errlog "file $LIBS/mp3.sh does not exists" \ - || return $? - source "$LIBS/opus.sh" || return $? - convert_flac_to_opus "$workdir" - ;; - *) - [ -f "$LIBS/voribs.sh" ] \ - || errlog "file $LIBS/mp3.sh does not exists" \ - || return $? - source "$LIBS/voribs.sh" || return $? - convert_flac_to_ogg "$workdir" || return $? - ;; + "mp3") execute_program "mp3.sh" "$workdir" || return $? ;; + "flac") execute_program "flac.sh" "$workdir" || return $? ;; + "opus") execute_program "opus.sh" "$workdir" || return $? ;; + *) execute_program "vorbis.sh" "$workdir" || return $? ;; esac cleanup_cover "$workdir" diff --git a/libs/flac.sh b/libs/flac.sh index 8772bb1..a39019d 100644 --- a/libs/flac.sh +++ b/libs/flac.sh @@ -18,4 +18,11 @@ check_flac_programs() || return $? } +execute() +{ + local workdir="$1" + + picture_to_flac "$workdir" || return $? +} + check_flac_programs diff --git a/libs/mp3.sh b/libs/mp3.sh index f8f0d4f..b419465 100644 --- a/libs/mp3.sh +++ b/libs/mp3.sh @@ -102,4 +102,11 @@ check_mp3_programs() || return $? } +execute() +{ + local workdir="$1" + + convert_flac_to_mp3 "$workdir" || return $? +} + check_mp3_programs diff --git a/libs/opus.sh b/libs/opus.sh index 81a954b..19a2a91 100644 --- a/libs/opus.sh +++ b/libs/opus.sh @@ -32,4 +32,11 @@ check_opus_programs() || return $? } +execute() +{ + local workdir="$1" + + convert_flac_to_opus "$workdir" || return $? +} + check_opus_programs diff --git a/libs/voribs.sh b/libs/vorbis.sh similarity index 96% rename from libs/voribs.sh rename to libs/vorbis.sh index 673cf8d..98af34c 100644 --- a/libs/voribs.sh +++ b/libs/vorbis.sh @@ -109,4 +109,11 @@ check_vorbis_programs() || return $? } +execute() +{ + local workdir="$1" + + convert_flac_to_ogg "$workdir" || return $? +} + check_vorbis_programs -- 2.47.3