fix: enable spotify source in lavalink, add User-Agent to booru API requests

This commit is contained in:
loki5512344 2026-07-12 23:34:24 +02:00
parent 18c36419dc
commit 28ce94b0ca
Signed by: boba
GPG key ID: 253067914055423B
2 changed files with 7 additions and 2 deletions

View file

@ -14,7 +14,7 @@ plugins:
- "ytsearch:\"%ISRC%\"" - "ytsearch:\"%ISRC%\""
- "ytsearch:%QUERY%" - "ytsearch:%QUERY%"
sources: sources:
spotify: false spotify: true
applemusic: true applemusic: true
deezer: false deezer: false
yandexmusic: false yandexmusic: false

View file

@ -124,7 +124,11 @@ public class ImageService {
} }
private List<String> fetchBooruJson(String url, int limit) { 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()) { try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful() || response.body() == null) { if (!response.isSuccessful() || response.body() == null) {
@ -133,6 +137,7 @@ public class ImageService {
} }
String body = response.body().string(); String body = response.body().string();
if (body.isBlank() || !body.startsWith("[")) { 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(); return List.of();
} }
JsonArray posts = JsonParser.parseString(body).getAsJsonArray(); JsonArray posts = JsonParser.parseString(body).getAsJsonArray();