Optmized print_meta_field function
This commit is contained in:
parent
86525440f4
commit
35f92513dd
3 changed files with 4 additions and 11 deletions
|
@ -19,15 +19,7 @@ print_future_meta() {
|
|||
local tagList=($(awk 'BEGIN{RS="\",*\n * \"";FS="\" : \""}{if($1!~"@"){print $1}}' ${MTAG} | awk '!seen[$0]++'))
|
||||
|
||||
for tag in ${tagList[@]}; do
|
||||
local COUNT=1
|
||||
while [[ ${COUNT} -le ${TRACKNUMBER} ]]; do
|
||||
local PRTVAR=$(print_meta_field ${MTAG} ${COUNT} ${tag})
|
||||
[[ ! -z ${PRTVAR} ]] && local CURVAR=${PRTVAR}
|
||||
local COUNT=$(( ${COUNT} + 1 ))
|
||||
done
|
||||
echo -n "${tag}=${CURVAR};"
|
||||
unset CURVAR
|
||||
unset PRTVAR
|
||||
echo -n "${tag}=$(print_meta_field ${MTAG} ${TRACKNUMBER} ${tag});"
|
||||
done
|
||||
echo -n "IMAGEID=$(sed 's|.tags||g' <<< $(basename "${MTAG}"))"
|
||||
}
|
||||
|
|
|
@ -16,5 +16,5 @@ print_meta_field() {
|
|||
local TRACK_NO="${2}"
|
||||
local FIELD="${3}"
|
||||
|
||||
awk -v track="${TRACK_NO}" 'BEGIN {RS="\"\n * }"}{if(NR==track){print $0}}' ${FILE} | awk -v field="${FIELD}" 'BEGIN{RS="\",*\n * \"";FS="\" : \""}{if($1==field){print $2}}'
|
||||
awk -v track=${TRACK_NO} 'BEGIN {RS="\n * }"}{if(NR<=track){print $0}}' ${FILE} | awk -v field="\"${FIELD}\"" 'BEGIN{RS="[,]?\n";FS=" : "}{if($1~field){print $2}}' | tail -n 1 | sed -e 's/^"//' -e 's/"$//'
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ print_present_meta() {
|
|||
local FILE="${1}"
|
||||
|
||||
if [[ -f ${FILE} ]]; then
|
||||
awk 'BEGIN{FS=": ";ORS=";"}{if($1 ~ /comment\[/){print $2}}' <<< $(metaflac --list --block-type=VORBIS_COMMENT "${FILE}") | sed 's|.$||'
|
||||
awk 'BEGIN{FS=": ";ORS=";"}{if($1 ~ /comment\[/){print $2}}' <<< $(metaflac --list --block-type=VORBIS_COMMENT "${FILE}") | sed 's|.$||'
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue