refactor: increase 10MB download & REMOVE AUTO NBS INSTRUMENT SUBTITLES COMPLETIONS IT BREAKS SO MUCH

This commit is contained in:
ChomeNS
2025-04-11 08:34:52 +07:00
parent 563df838c5
commit ee6811ccd2
3 changed files with 4 additions and 37 deletions

View File

@@ -4,8 +4,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import me.chayapak1.chomens_bot.util.LevenshteinUtilities;
import me.chayapak1.chomens_bot.util.StringUtilities;
import java.io.BufferedReader;
@@ -226,32 +224,11 @@ public class NBSConverter implements Converter {
if (file.endsWith(".ogg")) file = file.substring(0, file.length() - ".ogg".length());
if (!sounds.contains(name) && !sounds.contains(file) && !isTempoChanger) {
boolean replaced = false;
final String replacedName = StringUtilities.replaceAllWithMap(name.toLowerCase(), CUSTOM_INSTRUMENT_REPLACEMENTS);
final String replacedFile = StringUtilities.replaceAllWithMap(file.toLowerCase(), CUSTOM_INSTRUMENT_REPLACEMENTS);
if (!file.equals(replacedFile)) {
file = replacedFile;
replaced = true;
} else if (!name.equals(replacedName)) {
name = replacedName;
replaced = true;
}
if (!replaced) {
final List<String> outputTitles = LevenshteinUtilities.searchTitles(name, subtitles.values());
final String bestMatch = outputTitles.isEmpty() ? "" : outputTitles.getFirst();
for (final Map.Entry<String, String> entry : subtitles.entrySet()) {
if (!entry.getValue().equals(bestMatch)) continue;
name = entry.getKey().substring("subtitles.".length());
break;
}
}
if (!file.equals(replacedFile)) file = replacedFile;
else if (!name.equals(replacedName)) name = replacedName;
}
if (!sounds.contains(name) && sounds.contains(file)) name = file;
@@ -301,16 +278,6 @@ public class NBSConverter implements Converter {
return (long) (1000L * tick * 100 / tempo);
}
private static final Map<String, String> subtitles = new HashMap<>();
static {
for (final Map.Entry<String, String> entry : ComponentUtilities.LANGUAGE.entrySet()) {
if (!entry.getKey().startsWith("subtitles.")) continue;
subtitles.put(entry.getKey(), entry.getValue());
}
}
private static final List<String> sounds = loadJsonStringArray("sounds.json");
private static List<String> loadJsonStringArray (final String name) {

View File

@@ -98,7 +98,7 @@ public class SongLoaderThread extends Thread {
final String name;
try {
if (isUrl) {
bytes = DownloadUtilities.DownloadToByteArray(songUrl, 5 * 1024 * 1024);
bytes = DownloadUtilities.DownloadToByteArray(songUrl, 10 * 1024 * 1024);
final Path fileName = Paths.get(songUrl.toURI().getPath()).getFileName();
name = fileName == null ? "(root)" : fileName.toString();