add bitrate information

This commit is contained in:
Vincent Riquer 2013-03-14 13:10:48 +01:00
parent 0aa8a04ab0
commit 64603d856f
2 changed files with 33 additions and 21 deletions

47
atom
View File

@ -18,6 +18,7 @@ declare -A \
destinationformat \ destinationformat \
destinationfrequency \ destinationfrequency \
destinationid \ destinationid \
destinationmaxbps \
destinationnormalize \ destinationnormalize \
destinationpath \ destinationpath \
destinationquality \ destinationquality \
@ -706,12 +707,13 @@ gettag() {
| sed -n "/^${1}=/I{s/^${1}=//I;p}" | sed -n "/^${1}=/I{s/^${1}=//I;p}"
} }
getInfosMP3_version='ID3-0.2' getInfosMP3_version='ID3-0.3'
tagreaders+=( "$getInfosMP3_version" ) tagreaders+=( "$getInfosMP3_version" )
getInfos::MP3() { getInfos::MP3() {
tagreader="$getInfosMP3_version" tagreader="$getInfosMP3_version"
infos=$( infos=$(
soxi -a "$sourcepath/$filename" 2>/dev/null soxi "$sourcepath/$filename" 2>/dev/null \
| sed 's/ *: /=/'
) )
album=$(gettag album) album=$(gettag album)
artist=$(gettag artist) artist=$(gettag artist)
@ -724,10 +726,15 @@ getInfos::MP3() {
then then
genre="${id3genres[$genre]}" genre="${id3genres[$genre]}"
fi fi
getRateChannelSoxi infos="${infos//: /=}"
channels=$(gettag channels)
rate=$(gettag 'sample rate')
bitrate=$(gettag 'bit rate')
bitrate=${bitrate%%.*}
bitrate=${bitrate%k}
} }
getInfosOgg_version='Ogg-O.1' getInfosOgg_version='Ogg-O.2'
tagreaders+=( "$getInfosOgg_version" ) tagreaders+=( "$getInfosOgg_version" )
getInfos::Ogg() { getInfos::Ogg() {
tagreader="$getInfosOgg_version" tagreader="$getInfosOgg_version"
@ -751,8 +758,10 @@ getInfos::Ogg() {
fi fi
year=$(gettag date) year=$(gettag date)
infos="${infos//: /=}" infos="${infos//: /=}"
rate=$(gettag rate) rate=$(gettag rate|head -n1)
channels=$(gettag channels) channels=$(gettag channels|head -n1)
bitrate=$(gettag 'nominal bitrate')
bitrate=${bitrate%%,*}
} }
getInfosFLAC_version='FLAC-0.1' getInfosFLAC_version='FLAC-0.1'
@ -1124,19 +1133,20 @@ do
if getTags if getTags
then then
Update tags \ Update tags \
album "$album" \ album "${album:-NULL}" \
albumartist "$albumartist" \ albumartist "${albumartist:-NULL}" \
artist "$artist" \ artist "${artist:-NULL}" \
composer "$composer" \ composer "${composer:-NULL}" \
disc "$disc" \ disc "${disc:-NULL}" \
genre "$genre" \ genre "${genre:-NULL}" \
performer "$performer" \ performer "${performer:-NULL}" \
title "$title" \ title "${title:-NULL}" \
track "$tracknum" \ track "${tracknum:-NULL}" \
year "$year" \ year "${year:-NULL}" \
last_change "$lastchange" \ last_change "$lastchange" \
rate "$rate" \ rate "${rate:-NULL}" \
channels "$channels" \ channels "${channels:-NULL}" \
bitrate "${bitrate:-NULL}" \
tagreader "$tagreader" \ tagreader "$tagreader" \
>/dev/null <<<"source_file = $sourcefileid" >/dev/null <<<"source_file = $sourcefileid"
unset genre \ unset genre \
@ -1150,6 +1160,7 @@ do
composer \ composer \
performer \ performer \
rate \ rate \
bitrate \
channels channels
fi fi
done done

View File

@ -52,6 +52,7 @@ CREATE TABLE tags (
performer TEXT, performer TEXT,
rate INTEGER, rate INTEGER,
channels INTEGER, channels INTEGER,
bitrate INTEGER,
last_change FLOAT, last_change FLOAT,
tagreader TEXT, tagreader TEXT,
FOREIGN KEY (source_file) REFERENCES source_files(id) FOREIGN KEY (source_file) REFERENCES source_files(id)