select best match based on record type when multiple are returned
This commit is contained in:
parent
8b16a2b03d
commit
b509f07851
@ -1,2 +1,40 @@
|
||||
#!/usr/bin/env -S jq -fMr
|
||||
select(.total == 1) | [._scene_release_name, .data[0].cover_xl ] | @tsv
|
||||
|
||||
def format_as_deezer_record_type($format):
|
||||
$format | ascii_upcase |
|
||||
if . == "SINGLE-WEB" then
|
||||
"single"
|
||||
elif . == "CDS" then
|
||||
"single"
|
||||
elif . == "CDM" then
|
||||
"single"
|
||||
elif . == "CDEP" then
|
||||
"ep"
|
||||
elif . == "EP-WEB" then
|
||||
"ep"
|
||||
elif . == "EP" then
|
||||
"ep"
|
||||
elif . == "WEB" then
|
||||
"album"
|
||||
elif . == "2CD" then
|
||||
"album"
|
||||
elif . == "CD" then
|
||||
"album"
|
||||
else
|
||||
null
|
||||
end;
|
||||
|
||||
if .total == 1 then
|
||||
[._scene_release_name, .data[0].cover_xl ]
|
||||
elif .total > 1 then
|
||||
._scene_release_name as $rls |
|
||||
format_as_deezer_record_type(._format) as $record_type |
|
||||
if $record_type != null then
|
||||
# alternate to empty if there is no matching record type
|
||||
.data | map(select(.record_type == $record_type))[0]//empty | [$rls, .cover_xl]
|
||||
else
|
||||
empty
|
||||
end
|
||||
else
|
||||
empty
|
||||
end | @tsv
|
||||
|
Loading…
Reference in New Issue
Block a user