Compare commits
2 Commits
ca2c7ae3c5
...
7afe0d8f34
| Author | SHA1 | Date | |
|---|---|---|---|
| 7afe0d8f34 | |||
| f7e22805f8 |
@@ -19,12 +19,13 @@
|
||||
# The input to this awk program is a sequence of lines containing the following fields:
|
||||
# Field 1: The MusicBrainz ID of the release this track belongs to
|
||||
# Field 2: MusicBrainz ID of this track
|
||||
# Field 3: Medium number of this track within the release
|
||||
# Field 4: Track number of this track within the medium
|
||||
# Field 5: Duration of this track in miliseconds
|
||||
# Field 6: Title of this track
|
||||
# Field 7: Artist of this track
|
||||
# Field 8: Path to decoratoin file of this release
|
||||
# Field 3: Number of media of theis release
|
||||
# Field 4: Medium number of this track within the release
|
||||
# Field 5: Track number of this track within the medium
|
||||
# Field 6: Duration of this track in miliseconds
|
||||
# Field 7: Title of this track
|
||||
# Field 8: Artist of this track
|
||||
# Field 9: Path to decoratoin file of this release
|
||||
#
|
||||
# The output is a sequence of tab-delimited lines containing the following fields:
|
||||
# Field 1: Sort value (to sort the track within the release)
|
||||
@@ -47,12 +48,13 @@ BEGIN {
|
||||
{
|
||||
parentid = $1
|
||||
id = $2
|
||||
med = $3
|
||||
nr = $4
|
||||
dur = $5
|
||||
title = $6
|
||||
artist = $7
|
||||
deco = local_recordings[id] ? $8 : ""
|
||||
medtot = $3
|
||||
med = $4
|
||||
nr = $5
|
||||
dur = $6
|
||||
title = $7
|
||||
artist = $8
|
||||
deco = local_recordings[id] ? $9 : ""
|
||||
gsub("&", "\\\\&", title)
|
||||
gsub("&", "\\\\&", artist)
|
||||
# Parse duration
|
||||
@@ -69,7 +71,10 @@ BEGIN {
|
||||
dur = "??:??"
|
||||
}
|
||||
line = format
|
||||
sub("<<med>>", med, line)
|
||||
if (medtot == 1)
|
||||
sub("<<med>>", "", line)
|
||||
else
|
||||
sub("<<med>>", med, line)
|
||||
sub("<<nr>>", nr, line)
|
||||
sub("<<title>>", title, line)
|
||||
sub("<<artist>>", artist, line)
|
||||
|
||||
@@ -373,6 +373,7 @@ case "${1:-}" in
|
||||
# This method reads the tags of the audio files in the specified directory.
|
||||
# If the audio files contain MusicBrainz tags, and they are consistent, then
|
||||
# a decoration file is written to that directory.
|
||||
[ ! "$FFPROBE" ] && err "This option requires ffprobe. Quitting the application now." && exit 1
|
||||
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
||||
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
||||
if ! decorate "$2"; then
|
||||
|
||||
@@ -99,20 +99,78 @@ list_releases() {
|
||||
#
|
||||
# argument $1: MusicBrainz release ID
|
||||
list_recordings() {
|
||||
info "list recordings.."
|
||||
deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)"
|
||||
info "deco=$deco"
|
||||
if [ "$deco" ]; then
|
||||
rectmp=$(mktemp)
|
||||
$JQ '.tracks | keys | join("\n")' "$deco" >"$rectmp"
|
||||
info "rectmp=$rectmp"
|
||||
info "$(cat "$rectmp")"
|
||||
fi
|
||||
mb_release "$1" |
|
||||
$JQ \
|
||||
--arg rid "$1" \
|
||||
--arg deco "$deco" \
|
||||
'.media[] |
|
||||
info "going to awk..."
|
||||
info "$(
|
||||
mb_release "$1" |
|
||||
$JQ \
|
||||
--arg rid "$1" \
|
||||
--arg deco "$deco" \
|
||||
'.media |
|
||||
length as $l |
|
||||
.[] |
|
||||
.position as $pos |
|
||||
.tracks[] | [
|
||||
$rid,
|
||||
.id,
|
||||
$l,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.recording.title,
|
||||
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$deco
|
||||
] |
|
||||
join("\t")'
|
||||
)"
|
||||
info "$(
|
||||
mb_release "$1" |
|
||||
$JQ \
|
||||
--arg rid "$1" \
|
||||
--arg deco "$deco" \
|
||||
'.media |
|
||||
length as $l |
|
||||
.[] |
|
||||
.position as $pos |
|
||||
.tracks[] | [
|
||||
$rid,
|
||||
.id,
|
||||
$l,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.recording.title,
|
||||
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$deco
|
||||
] |
|
||||
join("\t")' |
|
||||
awk \
|
||||
-F "\t" \
|
||||
-v file_local_recordings="${rectmp:-}" \
|
||||
-v format="$REC_FORMAT" \
|
||||
-v format_local="$FORMAT_LOCAL" \
|
||||
"$AWK_RECORDINGS"
|
||||
)"
|
||||
mb_release "$1" |
|
||||
$JQ \
|
||||
--arg rid "$1" \
|
||||
--arg deco "$deco" \
|
||||
'.media |
|
||||
length as $l |
|
||||
.[] |
|
||||
.position as $pos |
|
||||
.tracks[] | [
|
||||
$rid,
|
||||
.id,
|
||||
$l,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
|
||||
@@ -31,7 +31,7 @@ fi
|
||||
# The tags retrieved are the MusicBrainz release ID and the MusicBrainz track
|
||||
# ID
|
||||
__gettags() {
|
||||
ffprobe -v error -show_entries format_tags -print_format json "$1" |
|
||||
$FFPROBE -v error -show_entries format_tags -print_format json "$1" |
|
||||
$JQ '.format.tags | {
|
||||
trackid: (."MusicBrainz Release Track Id" // ."MUSICBRAINZ_RELEASETRACKID" // ."MusicBrainz/Release Track Id" // ""),
|
||||
releaseid: (."MusicBrainz Album Id" // ."MUSICBRAINZ_ALBUMID" // ."MusicBrainz/Album Id" // "")
|
||||
|
||||
@@ -60,7 +60,9 @@ __generate_playlist() {
|
||||
'$decofile[].tracks as $filenames |
|
||||
. |
|
||||
.id as $rid |
|
||||
.media[] |
|
||||
.media |
|
||||
length as $l |
|
||||
.[] |
|
||||
.position as $pos |
|
||||
.tracks |
|
||||
if ($tid == "") then . else map(select(.id == $tid)) end |
|
||||
@@ -68,6 +70,7 @@ __generate_playlist() {
|
||||
t: [
|
||||
$rid,
|
||||
.id,
|
||||
$l,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
|
||||
@@ -49,6 +49,9 @@ if [ ! "${TOOLS_LOADED:-}" ]; then
|
||||
fi
|
||||
export SOCAT
|
||||
|
||||
command -v "ffprobe" >/dev/null && FFPROBE="ffprobe" || FFPROBE=""
|
||||
export FFPROBE
|
||||
|
||||
command -v "xsel" >/dev/null && CLIP="xsel" || CLIP="true"
|
||||
export CLIP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user