feat: discogs description and bugfixes

This commit is contained in:
2025-07-23 12:11:24 +02:00
parent dcba30bf94
commit b7f45c613c
4 changed files with 31 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ __mb_artist_cache_or_fetch() {
__api_mb_get_artist "$1" | cache_put_artist_mb "$1"
mbartist="$(cache_get_artist_mb "$1")"
fi
echo "$mbartist"
printf "%s" "$mbartist"
}
# Get MusicBrainz json for artist
@@ -29,7 +29,8 @@ mb_artist_wikidata() {
__api_wikidata_get_sitelinks "$wikidataid" | cache_put_artist_wikidata "$1"
wikidata=$(cache_get_artist_wikidata "$1")
fi
echo "$wikidata"
[ ! "$wikidata" ] || [ "$wikidata" != "null" ] || return
printf "%s" "$wikidata"
}
# Get Wikipedia (English) summary json for artist
@@ -45,12 +46,31 @@ mb_artist_enwikipedia() {
# For obvious reasons it is recommended to link to wikidata only. So, we
# take the second route.
wikidata=$(mb_artist_wikidata "$1" || true)
wikiid=$(echo "$wikidata" |
wikiid=$(printf "%s" "$wikidata" |
$JQ -r '.enwiki.url' |
awk -F "/" '{print $NF}')
[ ! "$wikiid" ] || [ "$wikiid" != "null" ] || return
[ ! "$wikiid" ] && return || [ "$wikiid" = "null" ] && return
__api_wikipedia_en_get_summary "$wikiid" | cache_put_artist_enwikipedia "$1"
enwiki="$(cache_get_artist_enwikipedia "$1")"
fi
[ ! "$enwiki" ] || [ "$enwiki" != "null" ] || return
[ ! "$enwiki" ] && return || [ "$enwiki" = "null" ] && return
printf "%s" "$enwiki"
}
# Get Discogs json for artist
# @argument $1: MusicBrainz Artist ID
mb_artist_discogs() {
discogs="$(cache_get_artist_discogs "$1" || true)"
if [ ! "$discogs" ] || [ "$discogs" = "null" ]; then
discogsid=$(mb_artist "$1" |
$JQ -r '.relations |
map(select(.type=="discogs")) |
.[0].url.resource' |
awk -F "/" '{print $NF}')
[ ! "$discogsid" ] && return || [ "$discogsid" = "null" ] && return
__api_discogs_get_artist "$discogsid" | cache_put_artist_discogs "$1"
discogs="$(cache_get_artist_discogs "$1" || true)"
fi
[ ! "$discogs" ] && return || [ "$discogs" = "null" ] && return
printf "%s" "$discogs"
}