2018-03-26 23:34:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-03-28 16:48:49 +00:00
|
|
|
# doc print_meta_flac {
|
2018-03-26 23:34:44 +00:00
|
|
|
#
|
|
|
|
# DESCRIPTION
|
2018-03-28 16:48:49 +00:00
|
|
|
# print_meta_flac - Prints metadata of remote flac in FIELD=VALUE; format.
|
2018-03-26 23:34:44 +00:00
|
|
|
#
|
|
|
|
# USAGE
|
2018-03-29 14:56:30 +00:00
|
|
|
# print_meta_flac </path/to/flac> [<field_1> <field_2> <...>]
|
2018-03-26 23:34:44 +00:00
|
|
|
#
|
|
|
|
# }
|
|
|
|
|
2018-03-28 16:48:49 +00:00
|
|
|
print_meta_flac() {
|
2018-03-29 14:56:30 +00:00
|
|
|
local FILE="${1}"; shift
|
|
|
|
local tagList=(${@})
|
|
|
|
[[ ! -f ${FILE} ]] && return 1
|
2018-03-28 13:52:57 +00:00
|
|
|
|
2018-04-06 22:40:19 +00:00
|
|
|
local METADATA=$(awk 'BEGIN{FS="]: ";ORS=";"}{if($1 ~ /comment\[/){print $2}}' <<< $(metaflac --list --block-type=VORBIS_COMMENT "${FILE}"))
|
2018-03-29 14:56:30 +00:00
|
|
|
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|.$||'
|
2018-03-28 13:52:57 +00:00
|
|
|
fi
|
2018-03-29 14:56:30 +00:00
|
|
|
|
2018-03-28 13:52:57 +00:00
|
|
|
}
|