big changes: themed up, sorted up, some fixes and libs
This commit is contained in:
@@ -1,62 +1,62 @@
|
||||
# List recordings
|
||||
# List release groups
|
||||
#
|
||||
# parameter file_local_recordings: This is an optional parameter with the path
|
||||
# to a file with a MusicBrainz recording ID
|
||||
# per line.
|
||||
# parameter format: The format of a recording line including the
|
||||
# placeholders <<med>> for medium number,
|
||||
# <<nr> for for track number within a medium,
|
||||
# <<title>> for the title, <<artist>> for the
|
||||
# artist string, and <<duration>> for the
|
||||
# track duration.
|
||||
# parameter format_local: String to indicate that the track is locally
|
||||
# available
|
||||
# parameter format_current: String to indicate that the track is
|
||||
# "currently playing"
|
||||
# parameter current_id: MusicBrainz track ID of a track to be marked
|
||||
# as "currently playing"
|
||||
# flagfile Path to a file with a MusicBrainz track ID per line, tab-delimited
|
||||
# from the path to the decoration file (optional)
|
||||
#
|
||||
# theme parameters (see `src/sh/awk.sh` and `src/sh/theme.sh`)
|
||||
# format Format string
|
||||
# flag_local Flag for locally available music
|
||||
# flag_nolocal Flag for locally unavailable music
|
||||
# playing_yes Mark for currently playing track
|
||||
# playing_no Mark for currently not playing track
|
||||
# fmtmedia `printf` expression for media identifier
|
||||
# fmtnr `printf` expression for track number
|
||||
# fmttitle `printf` expression for title
|
||||
# fmtartist `printf` expression for artist
|
||||
# fmtduration `printf` expression track duration
|
||||
#
|
||||
# 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: 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
|
||||
# Field 1: The MusicBrainz ID of the release this track belongs to
|
||||
# Field 2: MusicBrainz ID of this track
|
||||
# Field 3: Number of media of this 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 milliseconds
|
||||
# Field 7: Title of this track
|
||||
# Field 8: Artist of this track
|
||||
# Field 9: Path to decoration file of this release
|
||||
# Field 10: Empty outside of playlists, else "yes" if the track is currently
|
||||
# being played, and something else otherwise.
|
||||
#
|
||||
# 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 2: The string `format_local` if the track is locally available
|
||||
# Field 3: The string `format_current` if the track has MusicBrainz ID `current_id`
|
||||
# Field 4: The track line to be displayed according to `format`
|
||||
# Field 5: The MusicBrainz ID of the release this track belongs to
|
||||
# Field 6: The MusicBrainz ID of this track ":" separated from the path to the
|
||||
# decoration file of this release
|
||||
# The output of this script is a sequence of tab-delimited lines. The first
|
||||
# `REC_FMT_CNT` fields are those that will be displayed to the user. The
|
||||
# following fields are
|
||||
# - Constant 0 (we will not sort)
|
||||
# - MusicBrainz release ID if specified, else the constant "0"
|
||||
# - MusicBrainz track ID
|
||||
# - Path to decoration file if some music of that release is locally available
|
||||
|
||||
@include "lib/awk/lib.awk"
|
||||
|
||||
BEGIN {
|
||||
OFS="\t"
|
||||
local_recordings[0] = 0
|
||||
delete local_recordings[0]
|
||||
if (file_local_recordings) {
|
||||
while ((getline < file_local_recordings) == 1)
|
||||
local_recordings[$1] = 1
|
||||
close(file_local_recordings)
|
||||
flagged[0] = 0
|
||||
delete flagged[0]
|
||||
if (flagfile) {
|
||||
while ((getline < flagfile) == 1)
|
||||
flagged[$1] = 1
|
||||
close(flagfile)
|
||||
}
|
||||
}
|
||||
{
|
||||
parentid = $1
|
||||
id = $2
|
||||
medtot = $3
|
||||
med = $4
|
||||
nr = $5
|
||||
# Read data
|
||||
line = format
|
||||
releaseid = $1
|
||||
mbid = $2
|
||||
medtot = $3 + 0
|
||||
med = ($4 && medtot >= 2) ? sprintf(fmtmedia, escape($4)) : ""
|
||||
nr = $5 ? sprintf(fmtnr, escape($5)) : ""
|
||||
dur = $6
|
||||
title = $7
|
||||
artist = $8
|
||||
deco = local_recordings[id] ? $9 : ""
|
||||
gsub("&", "\\\\&", title)
|
||||
gsub("&", "\\\\&", artist)
|
||||
# Parse duration
|
||||
if (dur) {
|
||||
dur = int(dur / 1000)
|
||||
@@ -70,17 +70,27 @@ BEGIN {
|
||||
} else {
|
||||
dur = "??:??"
|
||||
}
|
||||
line = format
|
||||
if (medtot == 1)
|
||||
sub("<<med>>", "", line)
|
||||
dur = sprintf(fmtduration, dur)
|
||||
title = $7 ? sprintf(fmttitle, escape($7)) : ""
|
||||
artist = $8 ? sprintf(fmtartist, escape($8)) : ""
|
||||
if (flagged[mbid] && $9)
|
||||
flagged[mbid] = $9
|
||||
current = $10
|
||||
# Transform data and fill placeholders
|
||||
if (flagged[mbid])
|
||||
gsub("<<flag>>", flag_local, line)
|
||||
else
|
||||
sub("<<med>>", med, line)
|
||||
sub("<<nr>>", nr, line)
|
||||
sub("<<title>>", title, line)
|
||||
sub("<<artist>>", artist, line)
|
||||
sub("<<duration>>", dur, line)
|
||||
l = local_recordings[id] ? format_local : ""
|
||||
c = id == current_id ? format_current : ""
|
||||
sortk = med" "nr
|
||||
print sortk, l, c, line, parentid, id ":" deco
|
||||
gsub("<<flag>>", flag_nolocal, line)
|
||||
gsub("<<media>>", med, line)
|
||||
gsub("<<nr>>", nr, line)
|
||||
gsub("<<title>>", title, line)
|
||||
gsub("<<artist>>", artist, line)
|
||||
gsub("<<duration>>", dur, line)
|
||||
if (current) {
|
||||
if (current == "yes")
|
||||
gsub("<<playing>>", playing_yes, line)
|
||||
else
|
||||
gsub("<<playing>>", playing_no, line)
|
||||
}
|
||||
print line, "0", releaseid ? releaseid : "0", mbid, flagged[mbid] ? flagged[mbid] : (current ? $9 : "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user