commit 002a691a7c82efcc438b8d1eb1a8b0971834fe49
parent c6093d5b59ebb8065a135e98c1c7f071133df8ef
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Wed, 8 Apr 2020 12:17:10 -0700
Remove unnecessary dashes in song and artist.
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Songs2Slides.py b/Songs2Slides.py
@@ -17,17 +17,17 @@ def GetLyrics(artist, song):
# Convert to lowercase
artist = artist.lower()
song = song.lower()
-
- # Remove extra whitespace
- artist = ' '.join(artist.split())
- song = ' '.join(song.split())
# Replace invalid characters
- old = [" ", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "=", "'", "?", "/", "|", "\\", ".", ",", "á", "é", "í", "ó", "ñ", "ú"]
- new = ["-", "", "", "", "s", "", "-", "and", "", "", "", "-", "-", "", "", "", "", "", "", "", "a", "e", "i", "o", "n", "u"]
+ old = [" ", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "=", "'", "?", "/", "|", "\\", ".", ",", "á", "é", "í", "ó", "ñ", "ú"]
+ new = ["-", "", "", "", "s", "", "-", "-and-", "", "", "", "-", "-", "", "", "", "", "", "", "", "a", "e", "i", "o", "n", "u"]
for i in range(0, len(old)):
artist = artist.replace(old[i], new[i])
song = song.replace(old[i], new[i])
+
+ # Remove unnecessary dashes
+ artist = '-'.join(list(filter(lambda a: a != '', artist.split("-"))))
+ song = '-'.join(list(filter(lambda a: a != '', song.split("-"))))
# Get lyrics
page = requests.get("https://genius.com/{0}-{1}-lyrics".format(artist, song))