identify sample-rate/channels

This commit is contained in:
Vincent Riquer 2013-03-06 22:57:26 +01:00
parent b148bf331f
commit a66528ac89
2 changed files with 54 additions and 5 deletions

57
atom
View File

@ -628,6 +628,27 @@ removeObsoleteFiles() {
EOWhere
}
getRateChannelSoxi() {
rate=$(soxi -r "$sourcepath/$filename" 2>/dev/null)
channels=$(soxi -c "$sourcepath/$filename" 2>/dev/null)
}
getRateChannelMPC() {
while read key value garbage
do
case $key in
'samplerate:')
rate=$value
;;
'channels:')
channels=$value
;;
esac
done < <(
mpcdec "$sourcepath/$filename"
)
}
gettag() {
tagval=$(
echo -e "$infos" \
@ -639,7 +660,7 @@ gettag() {
getInfos::MP3() {
infos=$(
soxi -a "$sourcepath/$filename"
soxi -a "$sourcepath/$filename" 2>/dev/null
)
album=$(gettag album)
artist=$(gettag artist)
@ -647,6 +668,7 @@ getInfos::MP3() {
title=$(gettag title)
tracknum=$(gettag tracknumber)
year=$(gettag year)
getRateChannelSoxi
[ -n "$album" \
-o -n "$artist" \
-o -n "$genre" \
@ -676,6 +698,9 @@ getInfos::Ogg() {
tracknum="$tracknum/$tracktotal"
fi
year=$(gettag date)
infos="${infos//: /=}"
rate=$(gettag rate)
channels=$(gettag channels)
[ -n "$album" \
-o -n "$albumartist" \
-o -n "$artist" \
@ -715,6 +740,15 @@ getInfos::FLAC() {
title=$(gettag title)
tracknum="$(gettag tracknumber)/$(gettag tracktotal)"
year=$(gettag date)
{
read rate
read channels
} < <(
metaflac \
--show-sample-rate \
--show-channels \
"$sourcepath/$filename"
)
[ -n "$album" \
-o -n "$albumartist" \
-o -n "$artist" \
@ -791,6 +825,12 @@ getInfos::APE() {
|| return 1
}
tryAPE() {
grep -q 'APETAGEX' \
"$sourcepath/$filename" \
&& type=APE
}
getTags() {
unset type
case "$mimetype" in
@ -809,10 +849,13 @@ getTags() {
*' ID3 '*)
type=MP3
;;
*' Musepack '*)
getRateChannelMPC
tryAPE
;;
*)
grep -q 'APETAGEX' \
"$sourcepath/$filename" \
&& type=APE
getRateChannelSoxi
tryAPE
;;
esac
;;
@ -1004,6 +1047,8 @@ do
track "$tracknum" \
year "$year" \
last_change "$lastchange" \
rate "$rate" \
channels "$channels" \
>/dev/null <<<"source_file = $sourcefileid"
unset genre \
albumartist \
@ -1014,7 +1059,9 @@ do
tracknum \
title \
composer \
performer
performer \
rate \
channels
fi
done
echo 'COMMIT;' >&3

View File

@ -50,6 +50,8 @@ CREATE TABLE tags (
title TEXT,
composer TEXT,
performer TEXT,
rate INTEGER,
channels INTEGER,
last_change INTEGER,
FOREIGN KEY (source_file) REFERENCES source_files(id)
ON DELETE CASCADE