Sanity checks
This commit is contained in:
parent
429cf3e523
commit
a0ce3925a8
1
README
1
README
@ -25,6 +25,7 @@ Optional:
|
|||||||
http://opus-codec.org/
|
http://opus-codec.org/
|
||||||
* opusinfo (Opus metadata)
|
* opusinfo (Opus metadata)
|
||||||
* opusenc (Opus encoding)
|
* opusenc (Opus encoding)
|
||||||
|
* opusdec (Opus decoding)
|
||||||
* LAME MP3 Encoder
|
* LAME MP3 Encoder
|
||||||
http://lame.sourceforge.net/
|
http://lame.sourceforge.net/
|
||||||
* lame (MP3 encoding)
|
* lame (MP3 encoding)
|
||||||
|
|||||||
136
atom
136
atom
@ -96,8 +96,6 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
#FIXME: check sanity
|
|
||||||
|
|
||||||
if [ ! -f "$cffile" ]
|
if [ ! -f "$cffile" ]
|
||||||
then
|
then
|
||||||
if [ ! -d ~/.atom ]
|
if [ ! -d ~/.atom ]
|
||||||
@ -120,6 +118,135 @@ set +H
|
|||||||
(( debug || cfgdump )) && printConfig
|
(( debug || cfgdump )) && printConfig
|
||||||
(( cfgdump )) && exit
|
(( 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
|
openDatabase
|
||||||
|
|
||||||
createDestinations
|
createDestinations
|
||||||
@ -312,6 +439,11 @@ do
|
|||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
performer=${rest%%::AtOM:SQL:Sep::*}
|
performer=${rest%%::AtOM:SQL:Sep::*}
|
||||||
unset rest
|
unset rest
|
||||||
|
case ${destinationformat["$destination"]} in
|
||||||
|
vorbis) (( disableoggenc )) && continue ;;
|
||||||
|
opus) (( disableopusenc )) && continue ;;
|
||||||
|
mp3) (( disablelame )) && continue ;;
|
||||||
|
esac
|
||||||
decodeFile
|
decodeFile
|
||||||
getDestDir
|
getDestDir
|
||||||
getDestFile
|
getDestFile
|
||||||
|
|||||||
@ -8,12 +8,15 @@ getConfigDestination() {
|
|||||||
case "$value" in
|
case "$value" in
|
||||||
'mp3')
|
'mp3')
|
||||||
destinationformat["$destination"]=mp3
|
destinationformat["$destination"]=mp3
|
||||||
|
lameneeded=1
|
||||||
;;
|
;;
|
||||||
'opus')
|
'opus')
|
||||||
destinationformat["$destination"]=opus
|
destinationformat["$destination"]=opus
|
||||||
|
opusencneeded=1
|
||||||
;;
|
;;
|
||||||
'vorbis')
|
'vorbis')
|
||||||
destinationformat["$destination"]=vorbis
|
destinationformat["$destination"]=vorbis
|
||||||
|
oggencneeded=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported destination format: $value" >2&
|
echo "Unsupported destination format: $value" >2&
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
openDatabase() {
|
openDatabase() {
|
||||||
if [ ! -d "$tempdir" ]
|
|
||||||
then
|
|
||||||
mkdir -p "$tempdir"
|
|
||||||
fi
|
|
||||||
rm -f "$tempdir"/sqlite.{in,out}
|
rm -f "$tempdir"/sqlite.{in,out}
|
||||||
mkfifo "$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" \
|
sqlite3 -bail "$database" \
|
||||||
< "$tempdir/sqlite.in" \
|
< "$tempdir/sqlite.in" \
|
||||||
> "$tempdir/sqlite.out" &
|
> "$tempdir/sqlite.out" &
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
decodeFile() {
|
decodeFile() {
|
||||||
case "$mimetype" in
|
case "$mimetype" in
|
||||||
'video/'*)
|
'video/'*)
|
||||||
|
(( disablevideo )) && continue
|
||||||
extractAudio
|
extractAudio
|
||||||
if (( ${destinationnormalize["$destination"]}))\
|
if (( ${destinationnormalize["$destination"]}))\
|
||||||
|| (
|
|| (
|
||||||
@ -30,6 +31,7 @@ decodeFile() {
|
|||||||
then
|
then
|
||||||
copied=1
|
copied=1
|
||||||
else
|
else
|
||||||
|
(( disableopusdec )) && continue
|
||||||
decodeOpusdec
|
decodeOpusdec
|
||||||
if (( ${destinationnormalize["$destination"]}))\
|
if (( ${destinationnormalize["$destination"]}))\
|
||||||
|| (
|
|| (
|
||||||
@ -60,6 +62,7 @@ decodeFile() {
|
|||||||
extendedtype=$(file -b "$sourcepath/$filename")
|
extendedtype=$(file -b "$sourcepath/$filename")
|
||||||
case "$extendedtype" in
|
case "$extendedtype" in
|
||||||
*'Musepack '*)
|
*'Musepack '*)
|
||||||
|
(( disablempcdec )) && continue
|
||||||
decodeMpcdec
|
decodeMpcdec
|
||||||
if (( ${destinationnormalize["$destination"]}))\
|
if (( ${destinationnormalize["$destination"]}))\
|
||||||
|| (
|
|| (
|
||||||
|
|||||||
@ -1,26 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
getTags_version='unknown-4'
|
getTags_version='unknown-4'
|
||||||
tagreaders+=( "$getTags_version" )
|
|
||||||
getTags() {
|
getTags() {
|
||||||
unset type
|
unset type
|
||||||
case "$mimetype" in
|
case "$mimetype" in
|
||||||
audio/mpeg)
|
audio/mpeg)
|
||||||
type=ffmpeg
|
type=ffmpeg
|
||||||
|
(( disableffprobe )) && unset type
|
||||||
;;
|
;;
|
||||||
'application/ogg opus')
|
'application/ogg opus')
|
||||||
type=Opus
|
type=Opus
|
||||||
|
(( disableopusinfo )) && unset type
|
||||||
;;
|
;;
|
||||||
application/ogg*)
|
application/ogg*)
|
||||||
type=Ogg
|
type=Ogg
|
||||||
|
(( disableogginfo )) && unset type
|
||||||
;;
|
;;
|
||||||
audio/x-flac)
|
audio/x-flac)
|
||||||
type=FLAC
|
type=FLAC
|
||||||
|
(( disableflac )) && unset type
|
||||||
;;
|
;;
|
||||||
video/*)
|
video/*)
|
||||||
type=ffmpeg
|
type=ffmpeg
|
||||||
|
(( disableffprobe )) && unset type
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
type=ffmpeg
|
type=ffmpeg
|
||||||
|
(( disableffprobe )) && unset type
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [ -n "$type" ]
|
if [ -n "$type" ]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user