Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ replay_pid*
*/build/*
build
.vscode/*
.cursor/*

application.yml
playerconfigs/*
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

/**
Expand Down Expand Up @@ -41,7 +42,7 @@ default CachedPlayerScript getPlayerScript(@NotNull HttpInterface httpInterface)
try (CloseableHttpResponse response = httpInterface.execute(new HttpGet("https://www.youtube.com/embed/"))) {
HttpClientTools.assertSuccessWithContent(response, "fetch player script (embed)");

String responseText = EntityUtils.toString(response.getEntity());
String responseText = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
String scriptUrl = DataFormatTools.extractBetween(responseText, "\"jsUrl\":\"", "\"");

if (scriptUrl == null) {
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/java/dev/lavalink/youtube/clients/Web.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -70,7 +71,7 @@ protected void fetchClientConfig(@NotNull HttpInterface httpInterface) {
HttpClientTools.assertSuccessWithContent(response, "client config fetch");
lastConfigUpdate = System.currentTimeMillis();

String page = EntityUtils.toString(response.getEntity());
String page = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
Matcher m = CONFIG_REGEX.matcher(page);

if (!m.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected JsonBrowser loadJsonResponse(@NotNull HttpInterface httpInterface,
// from my testing, json is always returned so might not be necessary.
HttpClientTools.assertJsonContentType(response);

String json = EntityUtils.toString(response.getEntity());
String json = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
log.trace("Response from {} ({}) {}", request.getURI(), context, json);

return JsonBrowser.parse(json);
Expand Down Expand Up @@ -209,7 +209,7 @@ protected String fetchEncryptedHostFlags(@NotNull String videoId) {
request.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");

HttpResponse response = httpClient.execute(request);
String html = EntityUtils.toString(response.getEntity());
String html = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);

Pattern pattern = Pattern.compile("\"encryptedHostFlags\":\"([^\"]+)\"");
Matcher matcher = pattern.matcher(html);
Expand Down
3 changes: 2 additions & 1 deletion common/src/test/java/CipherManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.net.URISyntaxException;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -229,7 +230,7 @@ public void testScriptCaching() throws IOException {
*/
private String fetchCurrentPlayerScriptUrl(HttpInterface httpInterface) throws IOException {
try (CloseableHttpResponse response = httpInterface.execute(new HttpGet("https://www.youtube.com/embed/"))) {
String responseText = EntityUtils.toString(response.getEntity());
String responseText = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);

// Extract the jsUrl from the response
Pattern jsUrlPattern = Pattern.compile("\"jsUrl\":\"([^\"]+)\"");
Expand Down