toys/lowquality
Get file names by format and quality constraints
This commit is contained in:
parent
59dc0b1a54
commit
2d345047f7
130
toys/lowquality
Executable file
130
toys/lowquality
Executable file
@ -0,0 +1,130 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# config structures
|
||||||
|
declare -A \
|
||||||
|
destinationchannels \
|
||||||
|
destinationfat32compat \
|
||||||
|
destinationcopymime \
|
||||||
|
destinationformat \
|
||||||
|
destinationfrequency \
|
||||||
|
destinationid \
|
||||||
|
destinationloss \
|
||||||
|
destinationmaxbps \
|
||||||
|
destinationnormalize \
|
||||||
|
destinationpath \
|
||||||
|
destinationquality \
|
||||||
|
destinationrename \
|
||||||
|
destinationnoresample \
|
||||||
|
destinationrenamepath \
|
||||||
|
destinationskipmime \
|
||||||
|
|| {
|
||||||
|
echo "Check your Bash version. You need >= 4.0" >&2
|
||||||
|
exit $EBASHVERS
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -r \
|
||||||
|
DOCDIR=./doc \
|
||||||
|
LIBDIR=./lib \
|
||||||
|
SHAREDIR=./share
|
||||||
|
declare -r \
|
||||||
|
exampleconf=$DOCDIR/example.cfg \
|
||||||
|
schema=$SHAREDIR/schema.sql \
|
||||||
|
\
|
||||||
|
oldIFS="$IFS"
|
||||||
|
|
||||||
|
cffile="$HOME/.atom/atom.cfg"
|
||||||
|
LC_ALL=C
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
|
for function in "$LIBDIR"/*/*
|
||||||
|
do
|
||||||
|
source "$function"
|
||||||
|
done
|
||||||
|
|
||||||
|
while getopts 'fm:o:p:*:uD' opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
f) mimetypes+=("audio/x-flac")
|
||||||
|
bitrates+=("")
|
||||||
|
;;
|
||||||
|
m) mimetypes+=("audio/mpeg")
|
||||||
|
bitrates+=("$OPTARG")
|
||||||
|
;;
|
||||||
|
o) mimetypes+=("application/ogg vorbis")
|
||||||
|
bitrates+=("$OPTARG")
|
||||||
|
;;
|
||||||
|
p) mimetypes+=("application/ogg opus")
|
||||||
|
bitrates+=("$OPTARG")
|
||||||
|
;;
|
||||||
|
\*) mimetypes+=("*")
|
||||||
|
bitrates+=("$OPTARG")
|
||||||
|
;;
|
||||||
|
|
||||||
|
u) update=1 ;;
|
||||||
|
D) (( debug++ )) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
getConfig
|
||||||
|
|
||||||
|
openDatabase
|
||||||
|
|
||||||
|
if (( update ))
|
||||||
|
then
|
||||||
|
getFiles
|
||||||
|
updateMimes
|
||||||
|
updateTags
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '
|
||||||
|
SELECT
|
||||||
|
mime_type_actions.mime_text,
|
||||||
|
tags.bitrate,
|
||||||
|
source_files.filename
|
||||||
|
FROM source_files
|
||||||
|
INNER JOIN tags
|
||||||
|
ON source_files.id=tags.source_file
|
||||||
|
INNER JOIN mime_type_actions
|
||||||
|
ON mime_type_actions.id=source_files.mime_type
|
||||||
|
WHERE mime_type_actions.action=1
|
||||||
|
AND (
|
||||||
|
' >&3
|
||||||
|
|
||||||
|
for indice in ${!mimetypes[@]}
|
||||||
|
do
|
||||||
|
(( notfirst )) && echo OR >&3
|
||||||
|
case ${mimetypes[indice]} in
|
||||||
|
'audio/x-flac')
|
||||||
|
echo 'mime_type_actions.mime_text="audio/x-flac"'>&3
|
||||||
|
;;
|
||||||
|
'*')
|
||||||
|
echo '( (
|
||||||
|
NOT mime_type_actions.mime_text="audio/x-flac"
|
||||||
|
AND NOT mime_type_actions.mime_text="audio/mpeg"
|
||||||
|
AND NOT
|
||||||
|
mime_type_actions.mime_text="application/ogg vorbis"
|
||||||
|
AND NOT
|
||||||
|
mime_type_actions.mime_text="application/ogg opus"
|
||||||
|
) AND tags.bitrate < '${bitrates[indice]}' )' >&3
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo '(
|
||||||
|
mime_type_actions.mime_text="'"${mimetypes[indice]}"'"
|
||||||
|
AND tags.bitrate < '${bitrates[indice]}' )' >&3
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
notfirst=1
|
||||||
|
done
|
||||||
|
echo ') ORDER BY bitrate;' >&3
|
||||||
|
|
||||||
|
echo 'SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
|
|
||||||
|
read -u4 line
|
||||||
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
|
do
|
||||||
|
echo "${line//::AtOM:SQL:Sep::/$'\t'}"
|
||||||
|
read -u4 line
|
||||||
|
done
|
||||||
|
|
||||||
|
closeDatabase
|
||||||
Loading…
x
Reference in New Issue
Block a user