improved speed, added local data lists, some cleaning
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user