Pārlūkot izejas kodu

select best match based on record type when multiple are returned

master
bux pirms 2 gadiem
vecāks
revīzija
b509f07851
1 mainītis faili ar 39 papildinājumiem un 1 dzēšanām
  1. +39
    -1
      out-deezer-cover.jq

+ 39
- 1
out-deezer-cover.jq Parādīt failu

@@ -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

Notiek ielāde…
Atcelt
Saglabāt