[print_meta_flac] can now accept arguments that define which tags should be printed
This commit is contained in:
parent
a22a2d1575
commit
50b8612081
1 changed files with 13 additions and 4 deletions
|
@ -6,14 +6,23 @@
|
||||||
# print_meta_flac - Prints metadata of remote flac in FIELD=VALUE; format.
|
# print_meta_flac - Prints metadata of remote flac in FIELD=VALUE; format.
|
||||||
#
|
#
|
||||||
# USAGE
|
# USAGE
|
||||||
# print_meta_flac </path/to/flac>
|
# print_meta_flac </path/to/flac> [<field_1> <field_2> <...>]
|
||||||
#
|
#
|
||||||
# }
|
# }
|
||||||
|
|
||||||
print_meta_flac() {
|
print_meta_flac() {
|
||||||
local FILE="${1}"
|
local FILE="${1}"; shift
|
||||||
|
local tagList=(${@})
|
||||||
|
[[ ! -f ${FILE} ]] && return 1
|
||||||
|
|
||||||
if [[ -f ${FILE} ]]; then
|
local METADATA=$(awk 'BEGIN{FS=": ";ORS=";"}{if($1 ~ /comment\[/){print $2}}' <<< $(metaflac --list --block-type=VORBIS_COMMENT "${FILE}"))
|
||||||
awk 'BEGIN{FS=": ";ORS=";"}{if($1 ~ /comment\[/){print $2}}' <<< $(metaflac --list --block-type=VORBIS_COMMENT "${FILE}") | sed 's|.$||'
|
if [[ -z "${tagList[@]}" ]]; then
|
||||||
|
echo -n ${METADATA} | sed 's|.$||'
|
||||||
|
else
|
||||||
|
for tag in ${tagList[@]}; do
|
||||||
|
local SEL_METADATA="${SEL_METADATA}$(awk -v tag=${tag} 'BEGIN{FS="=";RS=";";ORS=";"}{if($1==tag){print $0}}' <<< ${METADATA})"
|
||||||
|
done
|
||||||
|
echo -n "${SEL_METADATA}" | sed 's|.$||'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue