Browse Source

select best match based on record type when multiple are returned

master
bux 2 years ago
parent
commit
b509f07851
1 changed files with 39 additions and 1 deletions
  1. +39
    -1
      out-deezer-cover.jq

+ 39
- 1
out-deezer-cover.jq View File

@@ -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…
Cancel
Save