mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-18 03:08:57 +01:00
added --all flag
This commit is contained in:
parent
f55148cf0e
commit
6b678457e3
60
AAXtoMP3
60
AAXtoMP3
@ -12,6 +12,7 @@ single=""
|
|||||||
|
|
||||||
authcode=".authcode";
|
authcode=".authcode";
|
||||||
auth="";
|
auth="";
|
||||||
|
allfromfolder="";
|
||||||
multi_thread="";
|
multi_thread="";
|
||||||
multi_thread_count=4;
|
multi_thread_count=4;
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ function print_manual(){
|
|||||||
echo " [--multithreading] : Enables Multitrheading. Uses 4 cores. Please use --threads=NUMBER if you dont have 4 cores."
|
echo " [--multithreading] : Enables Multitrheading. Uses 4 cores. Please use --threads=NUMBER if you dont have 4 cores."
|
||||||
echo " [--threads=NUMBER] : Sets the number of cores used. Enables Multithreading"
|
echo " [--threads=NUMBER] : Sets the number of cores used. Enables Multithreading"
|
||||||
echo " --authcode=XXXXXXXX: Your personal autcode. Everything after this parameter will be used as an inputfile!"
|
echo " --authcode=XXXXXXXX: Your personal autcode. Everything after this parameter will be used as an inputfile!"
|
||||||
|
echo " [--all] : Processes all .aax files from the current working directory. Ignores (FILES)."
|
||||||
echo " {FILES}: Files to convert, seperated by spaces."
|
echo " {FILES}: Files to convert, seperated by spaces."
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
@ -98,6 +100,13 @@ do
|
|||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$var" == '--all' ]]
|
||||||
|
then
|
||||||
|
allfromfolder='true'
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
case "$var" in
|
case "$var" in
|
||||||
-a=*|--auth=*)
|
-a=*|--auth=*)
|
||||||
auth=$(echo $var | cut -d '=' -f 2)
|
auth=$(echo $var | cut -d '=' -f 2)
|
||||||
@ -148,14 +157,36 @@ working_directory=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
|
|||||||
metadata_file="${working_directory}/metadata.txt"
|
metadata_file="${working_directory}/metadata.txt"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# find all aax-files and store them
|
||||||
|
FileArray=()
|
||||||
|
j=0;
|
||||||
|
for i in * ; do
|
||||||
|
case $i in *.aax)
|
||||||
|
j=$((j+1))
|
||||||
|
FileArray+=("$i")
|
||||||
|
echo "Found file: $i"
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
#If multithread is not set, use default processing.
|
#If multithread is not set, use default processing.
|
||||||
if [ -z "$multi_thread" ]; then
|
if [ -z "$multi_thread" ]; then
|
||||||
echo "Using a single thread!"
|
echo "Using a single thread!"
|
||||||
|
|
||||||
|
if [ -n "$allfromfolder" ]
|
||||||
|
then
|
||||||
|
for file in "${FileArray[@]}"
|
||||||
|
do
|
||||||
|
bash AAXtoMP3Worker "${flac}" "${aac}" "${opus}" "${single}" "--auth=${auth_code}" "$file"
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
for path
|
for path
|
||||||
do
|
do
|
||||||
#echo bash AAXtoMP3Worker "${flac}""${aac}""${opus}""${single}""--auth=${auth_code}" "${path}"
|
|
||||||
bash AAXtoMP3Worker "${flac}" "${aac}" "${opus}" "${single}" "--auth=${auth_code}" "${path}"
|
bash AAXtoMP3Worker "${flac}" "${aac}" "${opus}" "${single}" "--auth=${auth_code}" "${path}"
|
||||||
#echo "running away..."
|
|
||||||
done
|
done
|
||||||
exit 0;
|
exit 0;
|
||||||
fi;
|
fi;
|
||||||
@ -165,16 +196,27 @@ fi;
|
|||||||
#Count Tasks
|
#Count Tasks
|
||||||
i=0;
|
i=0;
|
||||||
PidArray=()
|
PidArray=()
|
||||||
|
|
||||||
|
if [ -n "$allfromfolder" ]
|
||||||
|
then
|
||||||
|
for file in "${FileArray[@]}"
|
||||||
|
do
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
else
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "$i tasks to do"
|
echo "$i tasks to do"
|
||||||
|
|
||||||
usedThreads=0;
|
usedThreads=0;
|
||||||
processes_left=1;
|
processes_left=1;
|
||||||
remainingTasks=$i;
|
remainingTasks=$i;
|
||||||
|
executedTasks=0;
|
||||||
|
|
||||||
if ! [ -d log ]
|
if ! [ -d log ]
|
||||||
then
|
then
|
||||||
@ -194,10 +236,20 @@ do
|
|||||||
if [ "$usedThreads" -lt "$multi_thread_count" -a "$remainingTasks" -gt "0" ]
|
if [ "$usedThreads" -lt "$multi_thread_count" -a "$remainingTasks" -gt "0" ]
|
||||||
then
|
then
|
||||||
#While Tread available, assign task
|
#While Tread available, assign task
|
||||||
|
|
||||||
|
if [ -n "$allfromfolder" ]
|
||||||
|
then
|
||||||
|
path="${FileArray[$executedTasks]}"
|
||||||
|
executedTasks=$((executedTasks+1))
|
||||||
|
else
|
||||||
path="$1";
|
path="$1";
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
echo bash AAXtoMP3Worker "$flac" "$aac" "$opus" "$single" "--auth=$auth_code" "$path"
|
echo bash AAXtoMP3Worker "$flac" "$aac" "$opus" "$single" "--auth=$auth_code" "$path"
|
||||||
nohup bash AAXtoMP3Worker "$flac" "$aac" "$opus" "$single" "--auth=$auth_code" "$path" &>> log/"$path".log &
|
nohup bash AAXtoMP3Worker "$flac" "$aac" "$opus" "$single" "--auth=$auth_code" "$path" &>> log/"$path".log &
|
||||||
shift
|
|
||||||
|
|
||||||
#echo "new task with id: $!"
|
#echo "new task with id: $!"
|
||||||
PidArray+=("$!")
|
PidArray+=("$!")
|
||||||
usedThreads=$((usedThreads+1))
|
usedThreads=$((usedThreads+1))
|
||||||
|
Loading…
Reference in New Issue
Block a user