fix: enable spotify source in lavalink, add User-Agent to booru API requests
This commit is contained in:
parent
18c36419dc
commit
28ce94b0ca
2 changed files with 7 additions and 2 deletions
|
|
@ -124,7 +124,11 @@ public class ImageService {
|
|||
}
|
||||
|
||||
private List<String> fetchBooruJson(String url, int limit) {
|
||||
Request request = new Request.Builder().url(url).get().build();
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.header("User-Agent", "LokiBot/1.0 (by loki)")
|
||||
.get()
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful() || response.body() == null) {
|
||||
|
|
@ -133,6 +137,7 @@ public class ImageService {
|
|||
}
|
||||
String body = response.body().string();
|
||||
if (body.isBlank() || !body.startsWith("[")) {
|
||||
logger.warn("Booru API returned non-JSON response (code {}): {}", response.code(), body.length() > 200 ? body.substring(0, 200) : body);
|
||||
return List.of();
|
||||
}
|
||||
JsonArray posts = JsonParser.parseString(body).getAsJsonArray();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue