Compare commits
2 Commits
cecbc9d41b
...
b509f07851
Author | SHA1 | Date | |
---|---|---|---|
|
b509f07851 | ||
|
8b16a2b03d |
@ -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
|
||||
|
@ -22,6 +22,11 @@ set DAPI "https://api.deezer.com/search/album"
|
||||
set UA "search-deezer.fish/v0.0.3"
|
||||
|
||||
while read -l -d (printf '\t') ORG A T C B F E Y
|
||||
if test -z "$A"; or test -z "$T"
|
||||
echo "WARN: Skipping empty artist / title input"
|
||||
continue
|
||||
end
|
||||
|
||||
set _in_A "$A"; set _in_T "$T"; set _in_C "$C";
|
||||
set _in_B "$B"; set _in_F "$F"; set _in_E "$E"; set _in_Y "$Y"
|
||||
|
||||
@ -53,6 +58,15 @@ while read -l -d (printf '\t') ORG A T C B F E Y
|
||||
continue
|
||||
end
|
||||
|
||||
if test "$API_COUNT" = "null"
|
||||
begin
|
||||
echo "ERR: API result has no total count"
|
||||
echo $ORG
|
||||
end >&2
|
||||
rm "$API_OUT"
|
||||
continue
|
||||
end
|
||||
|
||||
if test $API_COUNT -eq 0
|
||||
echo '{}' | jq -SMc --arg rls "$ORG" --arg api_count "$API_COUNT" \
|
||||
--arg a "$_in_A" --arg t "$_in_T" --arg c "$_in_C" \
|
||||
|
Loading…
Reference in New Issue
Block a user