MCPcopy Create free account
hub / github.com/egg82/fetcharr / setupWhisparr

Method setupWhisparr

App/src/main/java/me/egg82/fetcharr/Main.java:334–365  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

332 }
333
334 private static void setupWhisparr(int num) {
335 String url = ArrConfigVars.get(ArrConfigVars.URL, ArrType.WHISPARR, num);
336 String key = ArrConfigVars.get(ArrConfigVars.API_KEY, ArrType.WHISPARR, num);
337
338 if (url == null && key == null) {
339 return;
340 }
341 if (url == null) {
342 LOGGER.warn("Whisparr URL at {} missing", ArrConfigVars.URL.envName(ArrType.WHISPARR, num));
343 return;
344 }
345 if (key == null) {
346 LOGGER.warn("Whisparr API key at {} missing", ArrConfigVars.API_KEY.envName(ArrType.WHISPARR, num));
347 return;
348 }
349
350 url = url.strip().replaceAll("/+$", "");
351 key = key.strip();
352
353 WhisparrV3API arrApi = new WhisparrV3API(url, key, num);
354 if (!arrApi.valid()) {
355 LOGGER.warn("Could not authenticate to Whisparr instance configured at {} ({})", ArrConfigVars.URL.envName(ArrType.WHISPARR, num), url);
356 return;
357 }
358
359 FetcharrAPI api = FetcharrAPIProvider.instance();
360 if (api.updateManager().register(new WhisparrUpdater(api, arrApi, num))) {
361 LOGGER.info("Added WHISPARR_{} instance at {}", num, url);
362 } else {
363 LOGGER.info("Did not add WHISPARR_{} instance at {} - registration cancelled", num, url);
364 }
365 }
366
367 private static boolean isCacheWritable() {
368 JSONFile testFile = new JSONFile(new File(CacheConfigVars.getFile(CacheConfigVars.CACHE_DIR), "touch.json"));

Callers 1

mainMethod · 0.95

Calls 6

getMethod · 0.95
validMethod · 0.95
instanceMethod · 0.95
updateManagerMethod · 0.95
envNameMethod · 0.80
registerMethod · 0.65

Tested by

no test coverage detected