Sanity checks
This commit is contained in:
parent
429cf3e523
commit
a0ce3925a8
1
README
1
README
@ -25,6 +25,7 @@ Optional:
|
||||
http://opus-codec.org/
|
||||
* opusinfo (Opus metadata)
|
||||
* opusenc (Opus encoding)
|
||||
* opusdec (Opus decoding)
|
||||
* LAME MP3 Encoder
|
||||
http://lame.sourceforge.net/
|
||||
* lame (MP3 encoding)
|
||||
|
||||
136
atom
136
atom
@ -96,8 +96,6 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
#FIXME: check sanity
|
||||
|
||||
if [ ! -f "$cffile" ]
|
||||
then
|
||||
if [ ! -d ~/.atom ]
|
||||
@ -120,6 +118,135 @@ set +H
|
||||
(( debug || cfgdump )) && printConfig
|
||||
(( cfgdump )) && exit
|
||||
|
||||
# check sanity
|
||||
if [ ! -d "$tempdir" ] && ! mkdir -p "$tempdir"
|
||||
then
|
||||
echo "[FATAL] Could not create temp directory $tempdir" >&2
|
||||
(( sanityfail++ ))
|
||||
fi
|
||||
if [ ! -f "$database" ] && [ ! -d "${database%/*}" ] && ! mkdir -p "${database%/*}"
|
||||
then
|
||||
echo "[FATAL] Directory holding database file does not exist and could" \
|
||||
"not be created" >&2
|
||||
(( sanityfail++ ))
|
||||
fi
|
||||
if [ ! -d "$sourcepath" ]
|
||||
then
|
||||
echo "[FATAL] Source path $sourcepath does not exist or is not a directory" >&2
|
||||
(( sanityfail++ ))
|
||||
fi
|
||||
if ! which sed >/dev/null
|
||||
then
|
||||
echo "[FATAL] Required tool sed is not installed or not in PATH
|
||||
I never thought this would actually hit someone..." >&2
|
||||
(( sanityfail++ ))
|
||||
fi
|
||||
if ! which sox >/dev/null
|
||||
then
|
||||
echo "[FATAL] Required tool sox is not installed or not in PATH" >&2
|
||||
(( sanityfail++ ))
|
||||
fi
|
||||
if ! which ogginfo >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool ogginfo (from vorbis-tools) is not" \
|
||||
"installed or not in PATH
|
||||
Vorbis metadata disabled" >&2
|
||||
disableogginfo=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if (( oggencneeded )) && ! which oggenc >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool oggenc (from vorbis-tools) is not" \
|
||||
"installed or not in PATH
|
||||
Vorbis targets disabled" >&2
|
||||
disableoggenc=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if ! which opusinfo >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool opusinfo (from opus-tools) is not" \
|
||||
"installed or not in PATH
|
||||
Opus metadata disabled" >&2
|
||||
disableopusinfo=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if (( opusencneeded )) && ! which opusenc >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool opusenc (from opus-tools) is not" \
|
||||
"installed or not in PATH
|
||||
Opus targets disabled" >&2
|
||||
disableopusenc=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if ! which opusdec >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool opusdec (from opus-tools) is not" \
|
||||
"installed or not in PATH
|
||||
Opus support disabled" >&2
|
||||
disableopusdec=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if (( lameneeded )) && ! which lame >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool lame is not installed or not in PATH
|
||||
MP3 targets disabled" >&2
|
||||
disablelame=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if ! which metaflac >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool metaflac (from FLAC) is not installed" \
|
||||
"or not in PATH
|
||||
FLAC metadata disabled" >&2
|
||||
disableflac=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if ! which mpcdec >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool mpcdec (from Musepack) is not" \
|
||||
"installed or not in PATH
|
||||
Musepack support disabled" >&2
|
||||
disablempcdec=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if ! which ffprobe >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool ffprobe (from FFmpeg) is not installed or not in PATH
|
||||
Video metadata disabled
|
||||
MPEG metadata disabled
|
||||
MusePack metadata disabled
|
||||
Unknown format metadata disabled" >&2
|
||||
disableffprobe=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if ! which ffmpeg >/dev/null
|
||||
then
|
||||
echo "[WARNING] Tool ffmpeg is not installed or not in PATH
|
||||
Video support disabled" >&2
|
||||
disablevideo=1
|
||||
(( sanitywarn++ ))
|
||||
fi
|
||||
if (( sanityfail ))
|
||||
then
|
||||
echo "
|
||||
Sanity checks raised ${sanitywarn:-0} warnings, $sanityfail failures. Dying now." >&2
|
||||
exit $ESANITY
|
||||
elif (( sanitywarn ))
|
||||
then
|
||||
echo "
|
||||
Sanity checks raised $sanitywarn warnings... Hit Control-C to abort." >&2
|
||||
timeout=$(( sanitywarn * 10 ))
|
||||
echo -n "Starting in $(printf %3i $timeout)" \
|
||||
$'seconds...\b\b\b\b\b\b\b\b\b\b\b' >&2
|
||||
while (( timeout ))
|
||||
do
|
||||
echo -n $'\b\b\b'"$(printf %3i $timeout)" >&2
|
||||
sleep 1
|
||||
(( timeout-- ))
|
||||
done
|
||||
echo -en "\r\033[K"
|
||||
fi
|
||||
|
||||
openDatabase
|
||||
|
||||
createDestinations
|
||||
@ -312,6 +439,11 @@ do
|
||||
rest=${rest#*::AtOM:SQL:Sep::}
|
||||
performer=${rest%%::AtOM:SQL:Sep::*}
|
||||
unset rest
|
||||
case ${destinationformat["$destination"]} in
|
||||
vorbis) (( disableoggenc )) && continue ;;
|
||||
opus) (( disableopusenc )) && continue ;;
|
||||
mp3) (( disablelame )) && continue ;;
|
||||
esac
|
||||
decodeFile
|
||||
getDestDir
|
||||
getDestFile
|
||||
|
||||
@ -8,12 +8,15 @@ getConfigDestination() {
|
||||
case "$value" in
|
||||
'mp3')
|
||||
destinationformat["$destination"]=mp3
|
||||
lameneeded=1
|
||||
;;
|
||||
'opus')
|
||||
destinationformat["$destination"]=opus
|
||||
opusencneeded=1
|
||||
;;
|
||||
'vorbis')
|
||||
destinationformat["$destination"]=vorbis
|
||||
oggencneeded=1
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported destination format: $value" >2&
|
||||
|
||||
@ -1,18 +1,7 @@
|
||||
#!/bin/bash
|
||||
openDatabase() {
|
||||
if [ ! -d "$tempdir" ]
|
||||
then
|
||||
mkdir -p "$tempdir"
|
||||
fi
|
||||
rm -f "$tempdir"/sqlite.{in,out}
|
||||
mkfifo "$tempdir"/sqlite.{in,out}
|
||||
if [ ! -f "$database" ]
|
||||
then
|
||||
if [ ! -d "${database%/*}" ]
|
||||
then
|
||||
mkdir -p "${database%/*}"
|
||||
fi
|
||||
fi
|
||||
sqlite3 -bail "$database" \
|
||||
< "$tempdir/sqlite.in" \
|
||||
> "$tempdir/sqlite.out" &
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
decodeFile() {
|
||||
case "$mimetype" in
|
||||
'video/'*)
|
||||
(( disablevideo )) && continue
|
||||
extractAudio
|
||||
if (( ${destinationnormalize["$destination"]}))\
|
||||
|| (
|
||||
@ -30,6 +31,7 @@ decodeFile() {
|
||||
then
|
||||
copied=1
|
||||
else
|
||||
(( disableopusdec )) && continue
|
||||
decodeOpusdec
|
||||
if (( ${destinationnormalize["$destination"]}))\
|
||||
|| (
|
||||
@ -60,6 +62,7 @@ decodeFile() {
|
||||
extendedtype=$(file -b "$sourcepath/$filename")
|
||||
case "$extendedtype" in
|
||||
*'Musepack '*)
|
||||
(( disablempcdec )) && continue
|
||||
decodeMpcdec
|
||||
if (( ${destinationnormalize["$destination"]}))\
|
||||
|| (
|
||||
|
||||
@ -1,26 +1,31 @@
|
||||
#!/bin/bash
|
||||
getTags_version='unknown-4'
|
||||
tagreaders+=( "$getTags_version" )
|
||||
getTags() {
|
||||
unset type
|
||||
case "$mimetype" in
|
||||
audio/mpeg)
|
||||
type=ffmpeg
|
||||
(( disableffprobe )) && unset type
|
||||
;;
|
||||
'application/ogg opus')
|
||||
type=Opus
|
||||
(( disableopusinfo )) && unset type
|
||||
;;
|
||||
application/ogg*)
|
||||
type=Ogg
|
||||
(( disableogginfo )) && unset type
|
||||
;;
|
||||
audio/x-flac)
|
||||
type=FLAC
|
||||
(( disableflac )) && unset type
|
||||
;;
|
||||
video/*)
|
||||
type=ffmpeg
|
||||
(( disableffprobe )) && unset type
|
||||
;;
|
||||
*)
|
||||
type=ffmpeg
|
||||
(( disableffprobe )) && unset type
|
||||
;;
|
||||
esac
|
||||
if [ -n "$type" ]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user