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