commit 50f2b9deb72cb46d068846b84e65fc021585579b
parent 67211ce4c2aabb2e87daf24b0fb0a80ecb1a4c6a
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Sat, 21 Mar 2020 10:30:29 -0700
Implement basic lyric parsing.
Diffstat:
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/Songs2Slides.py b/Songs2Slides.py
@@ -10,4 +10,21 @@ def getLyrics(artist, song):
page = requests.get("https://genius.com/{0}-{1}-lyrics".format(artist, song))
html = BeautifulSoup(page.text, 'html.parser')
lyrics = html.find('div', class_='lyrics').get_text()
- return lyrics
-\ No newline at end of file
+ return lyrics
+
+
+# Parses the lyrics into blocks
+def ParseLyrics(lyrics):
+ rawLines = lyrics.split("\n")
+ lines = []
+ BlockSize = 0
+ for i in range(0, len(rawLines)):
+ if (rawLines[i] == "" or rawLines[i][0] == "["):
+ BlockSize = 4
+ elif (BlockSize == 4):
+ lines.append(rawLines[i])
+ BlockSize = 1
+ else:
+ lines[-1] = lines[-1] + "\n" + rawLines[i]
+ BlockSize += 1
+ return lines
+\ No newline at end of file