From 53bdd97c27d060483a1d3613e1fdb27882fbb5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giovanni=20Cutr=C3=AC?= <89142084+giovanni-cutri@users.noreply.github.com> Date: Tue, 23 May 2023 08:50:05 +0200 Subject: [PATCH 1/2] Fix code to get artist's name --- R/lyrics.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/lyrics.R b/R/lyrics.R index 7fc1eea..0581466 100644 --- a/R/lyrics.R +++ b/R/lyrics.R @@ -10,7 +10,7 @@ get_lyrics <- function(session) { html_text(trim = TRUE) artist <- session %>% - html_nodes(xpath = '//a[contains(@class, "SongHeaderdesktop__Artist")]') %>% + html_nodes(xpath = '//a[contains(@class, "HeaderArtistAndTracklistdesktop__")]') %>% html_text(trim = TRUE) # ensure line breaks are preserved correctly From 355ce47d651758975d98303456d17cc5dd6b92a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giovanni=20Cutr=C3=AC?= <89142084+giovanni-cutri@users.noreply.github.com> Date: Fri, 10 May 2024 18:41:44 +0200 Subject: [PATCH 2/2] Update lyrics.R --- R/lyrics.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/lyrics.R b/R/lyrics.R index 0581466..a3ea211 100644 --- a/R/lyrics.R +++ b/R/lyrics.R @@ -10,8 +10,9 @@ get_lyrics <- function(session) { html_text(trim = TRUE) artist <- session %>% - html_nodes(xpath = '//a[contains(@class, "HeaderArtistAndTracklistdesktop__")]') %>% + html_nodes(xpath = '//span[contains(@Class, "PortalTooltip__Container")]') %>% html_text(trim = TRUE) + artist <- artist[1] # ensure line breaks are preserved correctly xml_find_all(lyrics, ".//br") %>% xml_add_sibling("p", "\n")