From 72c83f80e54fc8d074342921f579484eefac2e60 Mon Sep 17 00:00:00 2001 From: q3aql Date: Sun, 2 Jan 2022 12:17:53 +0100 Subject: [PATCH] Read configuration from file on ~/.ks-tools/ --- src/ks-mp3 | 34 +++++++++++++++++++++++++++++++++- src/ks-mp3-album | 34 +++++++++++++++++++++++++++++++++- src/ks-oga | 34 +++++++++++++++++++++++++++++++++- src/ks-oga-album | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 132 insertions(+), 4 deletions(-) diff --git a/src/ks-mp3 b/src/ks-mp3 index 91b1d1a..02fd27b 100755 --- a/src/ks-mp3 +++ b/src/ks-mp3 @@ -13,6 +13,8 @@ M_DATE="030521" dirTemp="/tmp" listTemp="ks-tools.list" ksToolsTempFolder="/tmp/ks-tools" +configFolder=${HOME}/.ks-tools +configFile=${configFolder}/ks-mp3 # Basic parameters acodec="libmp3lame" @@ -20,6 +22,36 @@ b_acodec="128k" v_ext="mp3" default_lang_audio="spa" +# Create inicial config file +mkdir -p ${configFolder} +if [ -f ${configFile} ] ; then + exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1) + exist_b_acodec=$(cat ${configFile} | grep "b_acodec=") + exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=") + exist_v_ext=$(cat ${configFile} | grep "v_ext=") + if [ -z ${exist_acodec} ] ; then + echo "acodec=${acodec}" >> ${configFile} + fi + if [ -z ${exist_b_acodec} ] ; then + echo "b_acodec=${b_acodec}" >> ${configFile} + fi + if [ -z ${exist_default_lang_audio} ] ; then + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + fi + if [ -z ${exist_v_ext} ] ; then + echo "v_ext=${v_ext}" >> ${configFile} + fi + source ${configFile} +else + echo "#!/bin/bash" > ${configFile} + echo "" >> ${configFile} + echo "acodec=${acodec}" >> ${configFile} + echo "b_acodec=${b_acodec}" >> ${configFile} + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + echo "v_ext=${v_ext}" >> ${configFile} + source ${configFile} +fi + # Check cygwin alias (for Windows) if [ -f "/usr/bin/cygwin-alias.sh" ] ; then shopt -s expand_aliases @@ -122,7 +154,7 @@ if [ -z "${1}" ] ; then echo "" echo "- Convert video/audio file(s) to MP3 (Audio) Format" echo "" - echo "+ Config:" + echo "+ Config: ${configFile}" echo "" echo " - Audio codec: ${acodec}" echo " - Bitrate audio: ${b_acodec}" diff --git a/src/ks-mp3-album b/src/ks-mp3-album index 0066979..8800b1a 100755 --- a/src/ks-mp3-album +++ b/src/ks-mp3-album @@ -18,6 +18,8 @@ formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aa dirTemp="/tmp" listTemp="ks-tools.list" ksToolsTempFolder="/tmp/ks-tools" +configFolder=${HOME}/.ks-tools +configFile=${configFolder}/ks-mp3 # Basic parameters acodec="libmp3lame" @@ -27,6 +29,36 @@ track_init="1" artist_init="Artist" default_lang_audio="spa" +# Create inicial config file +mkdir -p ${configFolder} +if [ -f ${configFile} ] ; then + exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1) + exist_b_acodec=$(cat ${configFile} | grep "b_acodec=") + exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=") + exist_v_ext=$(cat ${configFile} | grep "v_ext=") + if [ -z ${exist_acodec} ] ; then + echo "acodec=${acodec}" >> ${configFile} + fi + if [ -z ${exist_b_acodec} ] ; then + echo "b_acodec=${b_acodec}" >> ${configFile} + fi + if [ -z ${exist_default_lang_audio} ] ; then + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + fi + if [ -z ${exist_v_ext} ] ; then + echo "v_ext=${v_ext}" >> ${configFile} + fi + source ${configFile} +else + echo "#!/bin/bash" > ${configFile} + echo "" >> ${configFile} + echo "acodec=${acodec}" >> ${configFile} + echo "b_acodec=${b_acodec}" >> ${configFile} + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + echo "v_ext=${v_ext}" >> ${configFile} + source ${configFile} +fi + # Check cygwin alias (for Windows) if [ -f "/usr/bin/cygwin-alias.sh" ] ; then shopt -s expand_aliases @@ -129,7 +161,7 @@ if [ -z "${1}" ] ; then echo "" echo "- Convert folder album to MP3 Audio Format" echo "" - echo "+ Config:" + echo "+ Config: ${configFile}" echo "" echo " - Audio codec: ${acodec}" echo " - Bitrate audio: ${b_acodec}" diff --git a/src/ks-oga b/src/ks-oga index c8c0a3a..3dbee58 100755 --- a/src/ks-oga +++ b/src/ks-oga @@ -13,6 +13,8 @@ M_DATE="030521" dirTemp="/tmp" listTemp="ks-tools.list" ksToolsTempFolder="/tmp/ks-tools" +configFolder=${HOME}/.ks-tools +configFile=${configFolder}/ks-oga # Basic parameters acodec="libvorbis" @@ -20,6 +22,36 @@ b_acodec="130k" v_ext="oga" default_lang_audio="spa" +# Create inicial config file +mkdir -p ${configFolder} +if [ -f ${configFile} ] ; then + exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1) + exist_b_acodec=$(cat ${configFile} | grep "b_acodec=") + exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=") + exist_v_ext=$(cat ${configFile} | grep "v_ext=") + if [ -z ${exist_acodec} ] ; then + echo "acodec=${acodec}" >> ${configFile} + fi + if [ -z ${exist_b_acodec} ] ; then + echo "b_acodec=${b_acodec}" >> ${configFile} + fi + if [ -z ${exist_default_lang_audio} ] ; then + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + fi + if [ -z ${exist_v_ext} ] ; then + echo "v_ext=${v_ext}" >> ${configFile} + fi + source ${configFile} +else + echo "#!/bin/bash" > ${configFile} + echo "" >> ${configFile} + echo "acodec=${acodec}" >> ${configFile} + echo "b_acodec=${b_acodec}" >> ${configFile} + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + echo "v_ext=${v_ext}" >> ${configFile} + source ${configFile} +fi + # Check cygwin alias (for Windows) if [ -f "/usr/bin/cygwin-alias.sh" ] ; then shopt -s expand_aliases @@ -122,7 +154,7 @@ if [ -z "${1}" ] ; then echo "" echo "- Convert video/audio file(s) to OGA (OGG Audio) Format" echo "" - echo "+ Config:" + echo "+ Config: ${configFile}" echo "" echo " - Audio codec: ${acodec}" echo " - Bitrate audio: ${b_acodec}" diff --git a/src/ks-oga-album b/src/ks-oga-album index b6ae3d8..a4ee3fe 100755 --- a/src/ks-oga-album +++ b/src/ks-oga-album @@ -18,6 +18,8 @@ formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aa dirTemp="/tmp" listTemp="ks-tools.list" ksToolsTempFolder="/tmp/ks-tools" +configFolder=${HOME}/.ks-tools +configFile=${configFolder}/ks-oga # Basic parameters acodec="libvorbis" @@ -27,6 +29,36 @@ track_init="1" artist_init="Artist" default_lang_audio="spa" +# Create inicial config file +mkdir -p ${configFolder} +if [ -f ${configFile} ] ; then + exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1) + exist_b_acodec=$(cat ${configFile} | grep "b_acodec=") + exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=") + exist_v_ext=$(cat ${configFile} | grep "v_ext=") + if [ -z ${exist_acodec} ] ; then + echo "acodec=${acodec}" >> ${configFile} + fi + if [ -z ${exist_b_acodec} ] ; then + echo "b_acodec=${b_acodec}" >> ${configFile} + fi + if [ -z ${exist_default_lang_audio} ] ; then + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + fi + if [ -z ${exist_v_ext} ] ; then + echo "v_ext=${v_ext}" >> ${configFile} + fi + source ${configFile} +else + echo "#!/bin/bash" > ${configFile} + echo "" >> ${configFile} + echo "acodec=${acodec}" >> ${configFile} + echo "b_acodec=${b_acodec}" >> ${configFile} + echo "default_lang_audio=${default_lang_audio}" >> ${configFile} + echo "v_ext=${v_ext}" >> ${configFile} + source ${configFile} +fi + # Check cygwin alias (for Windows) if [ -f "/usr/bin/cygwin-alias.sh" ] ; then shopt -s expand_aliases @@ -129,7 +161,7 @@ if [ -z "${1}" ] ; then echo "" echo "- Convert folder album to OGA (OGG Audio) Format" echo "" - echo "+ Config:" + echo "+ Config: ${configFile}" echo "" echo " - Audio codec: ${acodec}" echo " - Bitrate audio: ${b_acodec}"