songs2slides

A tool that automatically finds song lyrics and creates lyric slideshows
git clone https://git.ashermorgan.net/songs2slides/
Log | Files | Refs | README

commit 1020e70e356e4dfe9ca7ce77a30f5cd3cf60471e
parent e1accc79e8ae5fd51e1ce3258f3f780eafb3d387
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Fri, 24 Apr 2020 08:07:07 -0700

Improve title slide content.

Diffstat:
MSongs2Slides/models.py | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/Songs2Slides/models.py b/Songs2Slides/models.py @@ -26,19 +26,24 @@ def GetLyrics(title, artist): artist = "-".join(list(filter(lambda a: a != "", artist.split("-")))) title = "-".join(list(filter(lambda a: a != "", title.split("-")))) - # Get lyrics + # Get page page = requests.get("https://genius.com/{0}-{1}-lyrics".format(artist, title)) - lyrics = BeautifulSoup(page.text, "html.parser").find("div", class_="lyrics").get_text() + soup = BeautifulSoup(page.text, "html.parser") + + # Find lyrics and song information + lyrics = soup.find("div", class_="lyrics").get_text() + title = soup.find("h1", class_="header_with_cover_art-primary_info-title").get_text() + artist = soup.find("a", class_="header_with_cover_art-primary_info-primary_artist").get_text() # Return lyrics - return lyrics + return lyrics, title, artist # Parses the lyrics of a song into slides def ParseLyrics(title, artist): # Get lyrics - rawLyrics = GetLyrics(title, artist) + rawLyrics, title, artist = GetLyrics(title, artist) rawLines = rawLyrics.split("\n") # Remove starting and ending newlines