improved speed, added local data lists, some cleaning

This commit is contained in:
2025-09-10 22:50:41 +02:00
parent f35461cc50
commit 56b8c73297
9 changed files with 336 additions and 280 deletions

View File

@@ -1,7 +1,12 @@
MB_MAX_RETRIES=10
MB_BROWSE_STEPS=100
USER_AGENT="$APP_NAME/$APP_VERSION ($APP_WEBSITE)"
SLEEP_ON_ERROR=1
if [ ! "${API_LOADED:-}" ]; then
MB_MAX_RETRIES=10
MB_BROWSE_STEPS=100
USER_AGENT="$APP_NAME/$APP_VERSION ($APP_WEBSITE)"
SLEEP_ON_ERROR=1
export MB_MAX_RETRIES MB_BROWSE_STEPS USER_AGENT SLEEP_ON_ERROR
export API_LOADED=1
fi
__api_mb() {
tmpout=$(mktemp)
@@ -78,16 +83,18 @@ __api_mb() {
"https://musicbrainz.org/ws/2/release-group"
;;
esac
if ! $JQ -e '.error' "$tmpout" >/dev/null 2>/dev/stdout; then
errormsg=$($JQ -e '.error // ""' "$tmpout")
if [ "$errormsg" ]; then
err "Failed to fetch MusicBrainz data for $1 $2: $errormsg"
sleep "$SLEEP_ON_ERROR"
else
cat "$tmpout"
rm -f "$tmpout"
return 0
else
sleep "$SLEEP_ON_ERROR"
fi
done
rm -f "$tmpout"
err "Failed to fetch MusicBrainz data for $1 $2"
err "Failed to fetch MusicBrainz data for $1 $2 (not retrying anymore...)"
return 1
}