Read configuration from file on ~/.ks-tools/

This commit is contained in:
q3aql 2022-01-02 12:17:53 +01:00
parent 27656677d3
commit 72c83f80e5
4 changed files with 132 additions and 4 deletions

View File

@ -13,6 +13,8 @@ M_DATE="030521"
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp3
# Basic parameters # Basic parameters
acodec="libmp3lame" acodec="libmp3lame"
@ -20,6 +22,36 @@ b_acodec="128k"
v_ext="mp3" v_ext="mp3"
default_lang_audio="spa" 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) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -122,7 +154,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert video/audio file(s) to MP3 (Audio) Format" echo "- Convert video/audio file(s) to MP3 (Audio) Format"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Audio codec: ${acodec}" echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}" echo " - Bitrate audio: ${b_acodec}"

View File

@ -18,6 +18,8 @@ formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aa
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp3
# Basic parameters # Basic parameters
acodec="libmp3lame" acodec="libmp3lame"
@ -27,6 +29,36 @@ track_init="1"
artist_init="Artist" artist_init="Artist"
default_lang_audio="spa" 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) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -129,7 +161,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert folder album to MP3 Audio Format" echo "- Convert folder album to MP3 Audio Format"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Audio codec: ${acodec}" echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}" echo " - Bitrate audio: ${b_acodec}"

View File

@ -13,6 +13,8 @@ M_DATE="030521"
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-oga
# Basic parameters # Basic parameters
acodec="libvorbis" acodec="libvorbis"
@ -20,6 +22,36 @@ b_acodec="130k"
v_ext="oga" v_ext="oga"
default_lang_audio="spa" 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) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -122,7 +154,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert video/audio file(s) to OGA (OGG Audio) Format" echo "- Convert video/audio file(s) to OGA (OGG Audio) Format"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Audio codec: ${acodec}" echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}" echo " - Bitrate audio: ${b_acodec}"

View File

@ -18,6 +18,8 @@ formatFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ogg oga mp3 mp2 aa
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-oga
# Basic parameters # Basic parameters
acodec="libvorbis" acodec="libvorbis"
@ -27,6 +29,36 @@ track_init="1"
artist_init="Artist" artist_init="Artist"
default_lang_audio="spa" 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) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -129,7 +161,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert folder album to OGA (OGG Audio) Format" echo "- Convert folder album to OGA (OGG Audio) Format"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Audio codec: ${acodec}" echo " - Audio codec: ${acodec}"
echo " - Bitrate audio: ${b_acodec}" echo " - Bitrate audio: ${b_acodec}"