commit 70f3228dfc5c8701229890a43e9467675bd23614
parent 4ac7b10610fc8f2d6100f7c5c3aa7b4a73e6cd34
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Sat, 2 May 2020 08:07:15 -0700
Add option to remove content in parentheses.
Diffstat:
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Songs2Slides/config.py b/Songs2Slides/config.py
@@ -1,6 +1,7 @@
parsing = {
"title-slides": True,
"lines-per-slide": 4,
+ "remove-parentheses": False,
}
slide = {
diff --git a/Songs2Slides/models.py b/Songs2Slides/models.py
@@ -5,6 +5,7 @@ from pptx import Presentation
from pptx.dml.color import RGBColor
from pptx.enum.text import MSO_ANCHOR, PP_ALIGN
from pptx.util import Inches, Pt
+import re
import requests
@@ -44,6 +45,12 @@ def GetLyrics(title, artist):
def ParseLyrics(title, artist):
# Get lyrics
rawLyrics, title, artist = GetLyrics(title, artist)
+
+ # Remove content in parentheses
+ if (config.parsing["remove-parentheses"]):
+ rawLyrics = re.sub(r'\([^)]*\)', '', rawLyrics)
+
+ # Parse Lyrics
rawLines = rawLyrics.split("\n")
# Remove starting and ending newlines