Compare commits

..

2 Commits

Author SHA1 Message Date
4015d37657 Merge remote-tracking branch 'origin/master'
Some checks failed
build / build (push) Has been cancelled
2025-08-05 00:43:19 +02:00
5886d164b4 Core.java
- Added a safe handle for if Core#logWriter is not initialized to prevent craching

GetLyrics.java
- Slowly modifying the http headers to avoid package due to catching this as a Scrapper
- Added so we skip extra calls if the song is cached
2025-08-05 00:38:58 +02:00
2 changed files with 8 additions and 2 deletions

View File

@@ -462,6 +462,10 @@ public class Core {
*/ */
public static void writeLog(String message) public static void writeLog(String message)
{ {
if(logWriter == null) {
System.err.println("!! Log writer is not initialized !!");
return;
}
try { try {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd%EEEE HH:mm:ss'#'SSS"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd%EEEE HH:mm:ss'#'SSS");

View File

@@ -49,7 +49,7 @@ public class GetLyrics extends GeniusEndpointTool {
if(lyricsStr != null) if(lyricsStr != null)
{ {
// If we have a cached response, return it return new OllamaToolRespnce(this.name(), lyricsStr.trim());
} }
JSONObject obj = geniusToolsInstance.getGeniusEndpoint("/songs/" + args[0].value(), null); JSONObject obj = geniusToolsInstance.getGeniusEndpoint("/songs/" + args[0].value(), null);
@@ -57,7 +57,9 @@ public class GetLyrics extends GeniusEndpointTool {
String lyrics_path = obj.getJSONObject("response").getJSONObject("song").getString("url"); String lyrics_path = obj.getJSONObject("response").getJSONObject("song").getString("url");
try { try {
Document doc = Jsoup.connect(lyrics_path) Document doc = Jsoup.connect(lyrics_path)
.userAgent("Mozilla/5.0") .userAgent("insomnia/11.1.0") // TODO: replace with somthing else then insomnia! since we in no way support what ever Insomnia's User-Agent says we do
.header("host", "genius.com")
.header("accept", "*/*")
.get(); .get();
writeLog("Fetching lyrics from: " + lyrics_path); writeLog("Fetching lyrics from: " + lyrics_path);