Skip to content

Commit a41e76e

Browse files
committed
Fix genius lyrics loading
1 parent a8b7753 commit a41e76e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

application/src/main/java/me/duncte123/lyrics/GeniusClient.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class GeniusClient implements AutoCloseable {
2424
private static final ExecutorService executor = Executors.newSingleThreadExecutor();
2525
private final HttpClientProvider httpInterfaceManager;
2626
private final String apiKey;
27-
private static final String BROWSER_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0";
27+
private static final String BROWSER_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0";
2828
private static final String PRELOAD_START = "window.__PRELOADED_STATE__ = JSON.parse('";
2929
private static final String PRELOAD_END = "');";
3030

@@ -129,9 +129,7 @@ private String loadLyrics(String geniusUrl) throws IOException {
129129
.replace("\\'", "'")
130130
.replace("\\\\", "\\");
131131

132-
System.out.println(json);
133-
134-
final var lyrics = JsonBrowser.parse(json).get("songPage").get("lyricsData").get("body").text();
132+
final var lyrics = JsonBrowser.parse(json).get("songPage").get("lyricsData").get("body").get("html").text();
135133

136134
if (lyrics == null || lyrics.isEmpty()) {
137135
final var doc = Jsoup.parse(html);
@@ -149,7 +147,8 @@ private String loadLyrics(String geniusUrl) throws IOException {
149147
.trim();
150148
}
151149

152-
return lyrics
150+
return Jsoup.parse(lyrics)
151+
.wholeText()
153152
.replace("<br><br>", "\n")
154153
.replace("<br>", "\n")
155154
.replace("\n\n\n", "\n")

0 commit comments

Comments
 (0)