From 08c5c293fa702a31e49846330b53d5cef7f16ded Mon Sep 17 00:00:00 2001 From: Sean Sattler Date: Sun, 8 Dec 2024 13:16:10 +0100 Subject: [PATCH] A try to fix bot scrobbling (I have no idea what I do here) --- src/FMBot.Bot/Models/MusicBot/BettyMusicBot.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/FMBot.Bot/Models/MusicBot/BettyMusicBot.cs b/src/FMBot.Bot/Models/MusicBot/BettyMusicBot.cs index 19fe1f4c..29bd48c5 100644 --- a/src/FMBot.Bot/Models/MusicBot/BettyMusicBot.cs +++ b/src/FMBot.Bot/Models/MusicBot/BettyMusicBot.cs @@ -31,22 +31,16 @@ public override string GetTrackQuery(IUserMessage msg) { var description = msg.Embeds.First().Description; - // Find the index of the newline character and truncate the string if it exists because this would display the next song which we dont need. - int newlineIndex = description.IndexOf('\n'); - if (newlineIndex != -1) - { - description = description.Substring(0, newlineIndex); - } - - // Find the start and end indices of the song info within **[ ]**. - int startIndex = description.IndexOf("**[", StringComparison.Ordinal) + 3; - int endIndex = description.IndexOf("](", StringComparison.Ordinal); + // Look for the start and end indices of the song info within **SONGTITLE - AUTHOR**. + int startIndex = description.IndexOf("Now Playing **", StringComparison.Ordinal) + "Now Playing **".Length; + int endIndex = description.IndexOf("**", startIndex, StringComparison.Ordinal); - if (startIndex < 0 || endIndex < 0 || endIndex <= startIndex) + if (startIndex < "Now Playing **".Length || endIndex < 0 || endIndex <= startIndex) { return string.Empty; } + // Extract the song info "SONGTITLE - AUTHOR". var songByArtist = description.Substring(startIndex, endIndex - startIndex); return songByArtist; }