Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions LyricsScraperNET/Providers/Genius/GeniusProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public sealed class GeniusProvider : ExternalProviderBase
// Format: "artist song". Example: "Parkway Drive Carrion".
private const string GeniusSearchQueryFormat = "{0} {1}";

// Lyrics header. Note: Should be skipped in result
private const string _lyricsHeaderNodesXPath = "//div[contains(@class, 'LyricsHeader')]";

private const string _referentFragmentNodesXPath = "//a[contains(@class, 'ReferentFragmentVariantdesktop') or contains(@class, 'ReferentFragmentdesktop') or contains(@class, 'ReferentFragment-desktop')]";
private const string _lyricsContainerNodesXPath = "//div[@data-lyrics-container]";

Expand Down Expand Up @@ -179,6 +182,12 @@ private string GetParsedLyricFromHtmlPageBody(string htmlPageBody, out bool inst
foreach (HtmlNode spanNode in spanNodes)
spanNode.Remove();

// Lyric's header node with additional information should be skipped.
var lyricsHeaderNodes = htmlDocument.DocumentNode.SelectNodes(_lyricsHeaderNodesXPath);
if (lyricsHeaderNodes != null)
foreach (HtmlNode headerNode in lyricsHeaderNodes)
headerNode.Remove();

var lyricNodes = htmlDocument.DocumentNode.SelectNodes(_lyricsContainerNodesXPath);
if (lyricNodes == null)
{
Expand Down
Loading
Loading