diff --git a/src/MenuLayer.cpp b/src/MenuLayer.cpp index f5b920f..6d9cc16 100644 --- a/src/MenuLayer.cpp +++ b/src/MenuLayer.cpp @@ -124,10 +124,10 @@ class $modify(MenuLayerMLHook, MenuLayer) { if (!useCustomSongs) toWriteToFile = toWriteToFile.append(fmt::format(" # Song: {} by {}", songName, songArtist)); auto test = utils::file::readString(m_fields->blacklistFile); if (test.isErr()) return log::info("error reading blacklist file!"); - auto result = geode::utils::file::writeString(m_fields->blacklistFile, fmt::format("{}\n{}", test.unwrap(), toWriteToFile)); + auto result = geode::utils::file::writeString(m_fields->blacklistFile, test.unwrap().append(fmt::format("\n{}", toWriteToFile))); if (result.isErr()) return log::info("error blacklisting song {}", currentSong); if (!useCustomSongs) Utils::makeNewCard(fmt::format("Blacklisted {} by {} ({})!", songName, songArtist, songID)); - else Utils::makeNewCard(fmt::format("Blacklisted {})!", currentSong)); + else Utils::makeNewCard(fmt::format("Blacklisted {})!", Utils::currentCustomSong())); m_fields->songManager.clearSongs(); Utils::populateVector(useCustomSongs); if (!Utils::getBool("playlistMode")) Utils::setNewSong(); diff --git a/src/Utils.cpp b/src/Utils.cpp index ab90047..ba4d6f1 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -226,17 +226,17 @@ void Utils::populateVector(bool customSongs) { blacklist.push_back(blacklistString); geode::log::info("{}", blacklistString); } - geode::log::info("Finished storing oldDNBMessages."); + geode::log::info("Finished storing blacklist. size: {}", blacklist.size()); } if (customSongs) { for (auto file : std::filesystem::directory_iterator(configDir)) { if (!std::filesystem::exists(file)) continue; - auto filePath = file.path(); + const auto& filePath = file.path(); auto filePathString = filePath.string(); - if (!Utils::isSupportedExtension(filePathString) || std::ranges::find(blacklist, filePathString) != blacklist.end()) continue; + if (!Utils::isSupportedExtension(filePathString) || std::ranges::find(blacklist, filePathString) != blacklist.end() || std::ranges::find(blacklist, filePath.filename().string()) != blacklist.end()) continue; geode::log::debug("Adding custom song: {}", filePath.filename().string()); SongManager::get().addSong(filePathString); @@ -321,4 +321,10 @@ int Utils::getSongID() { const auto songInfo = Utils::getSongInfoObject(); if (!songInfo) return -1; return songInfo->m_songID; +} + +std::string Utils::currentCustomSong() { + if (!Utils::getBool("useCustomSongs")) return Utils::getSongName(); + if (SongManager::get().isOriginalMenuLoop()) return ""; + return std::filesystem::path(SongManager::get().getCurrentSong()).filename().string(); } \ No newline at end of file diff --git a/src/Utils.hpp b/src/Utils.hpp index 7429466..959e980 100644 --- a/src/Utils.hpp +++ b/src/Utils.hpp @@ -20,4 +20,5 @@ class Utils { static std::string getSongName(); static std::string getSongArtist(); static int getSongID(); + static std::string currentCustomSong(); }; \ No newline at end of file