songs2slides

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

commit 3461f9f5d83efb75a94bdd35f36980c22556aa25
parent 50f2b9deb72cb46d068846b84e65fc021585579b
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Sat, 21 Mar 2020 11:10:51 -0700

Implement powerpoint creation.

Diffstat:
MSongs2Slides.py | 38++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/Songs2Slides.py b/Songs2Slides.py @@ -1,6 +1,9 @@ # Import dependencies from bs4 import BeautifulSoup import requests +from pptx import Presentation +from pptx.enum.text import PP_ALIGN +from pptx.util import Inches, Pt # Gets the lyrics @@ -27,4 +30,35 @@ def ParseLyrics(lyrics): else: lines[-1] = lines[-1] + "\n" + rawLines[i] BlockSize += 1 - return lines -\ No newline at end of file + return lines + + +# Create powerpoint +def CreatePptx(parsedLyrics, filepath): + # Create presentation + prs = Presentation() + blank_slide_layout = prs.slide_layouts[6] + + for lyric in parsedLyrics: + # Add slide + slide = prs.slides.add_slide(blank_slide_layout) + + # Add text box + left = Inches(0.5) + top = Inches(0.5) + width = Inches(9) + height = Inches(6) + txBox = slide.shapes.add_textbox(left, top, width, height) + tf = txBox.text_frame + tf.clear() + tf.word_wrap = True + + # Add pharagraph + p = tf.paragraphs[0] + p.text = lyric + p.font.size = Pt(40) + p.alignment = PP_ALIGN.CENTER + p.line_spacing = 1.25 + + # Save powerpoint + prs.save(filepath) +\ No newline at end of file