Skip to content

Commit

Permalink
taking out the garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
FriskIsGit committed Jul 2, 2023
1 parent 165d8c6 commit c704652
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Shitcord/Modules/AudioModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ public async Task LyricsCommand(CommandContext ctx){
string firstPart = author[..author.IndexOf(' ')];
var onePartAuthorSongs = await retrieveSongs(songName + " " + firstPart);
songs.AddRange(onePartAuthorSongs);

foreach (var song in songs){
if (song.full_title == null){
continue;
Expand All @@ -900,10 +900,17 @@ public async Task LyricsCommand(CommandContext ctx){
}

defer:
if (trackAuthorExists){
FilterOutGeniusGarbage(songName + " " + author, songs);
}else{
FilterOutGeniusGarbage(songName, songs);
}


SongInfo? mostAccurate = trackAuthorExists ?
SelectMostAccurate(songName + " " + author, songs) :
SelectMostAccurate(songName, songs);

if (mostAccurate?.lyrics_url == null)
return;
Console.WriteLine(mostAccurate);
Expand Down Expand Up @@ -940,6 +947,19 @@ await ctx.Channel.SendPaginatedMessageAsync(ctx.Member, interactivity.GeneratePa
PaginationBehaviour.WrapAround, ButtonPaginationBehavior.DeleteMessage);
}

private static void FilterOutGeniusGarbage(string songName, List<SongInfo> songs){
for (int i = 0; i < songs.Count; i++){
SongInfo song = songs[i];
if (song.full_title == null){
continue;
}
float accuracy = StringMatching.Accuracy(songName, song.full_title);
if (accuracy < 0.15){
songs.RemoveAt(i--);
}
}
}

private static DiscordEmbed EmbedSong(SongInfo song){
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
string? title = song.full_title;
Expand Down

0 comments on commit c704652

Please sign in to comment.