songs2slides

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

commit a3b9ae357b9a7de1b459846bda35be84e4db06e1
parent 402fdc8ec1c19af1182320b446f761cc3f829015
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Tue, 31 Mar 2020 10:18:10 -0700

Implement option to review parsed lyrics.

Diffstat:
MSongs2Slides.py | 32+++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/Songs2Slides.py b/Songs2Slides.py @@ -5,7 +5,9 @@ from pptx import Presentation from pptx.enum.text import PP_ALIGN from pptx.util import Inches, Pt import requests +import subprocess import sys +import tempfile # Gets the lyrics @@ -37,7 +39,7 @@ def GetLyrics(artist, song): def ParseLyrics(lyrics): rawLines = lyrics.split("\n") lines = [] - BlockSize = 0 + BlockSize = 4 for i in range(0, len(rawLines)): if (rawLines[i] == "" or rawLines[i][0] == "["): BlockSize = 4 @@ -108,6 +110,34 @@ if (__name__ == "__main__"): break song += 1 + # Review lyrics + if (input("Would you like to review the parsed lyrics first? (y/n): ").lower() == "y"): + try: + # Create temp file + temp = tempfile.NamedTemporaryFile(mode='w+t', suffix=".txt", delete=False) + for line in lyrics: + temp.writelines(line) + temp.writelines("\n\n") + temp.close() + + # Open temp file and wait + subprocess.Popen(["notepad", temp.name]).wait() + + # Read file + file = open(temp.name,mode='r') + rawLines = file.read() + file.close() + + # Parse lyrics + lyrics = [] + for song in rawLines.split("\n\n\n"): + lyrics += ParseLyrics(song) + lyrics += [""] + finally: + # Delete temp file + os.remove(temp.name) + + # Get filepath filepath = input("Please enter a filepath to save your powerpoint to: ")