commit 402fdc8ec1c19af1182320b446f761cc3f829015
parent 5e6345fdf5803dbc7f5626decd183484451ff6a9
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Mon, 23 Mar 2020 12:07:03 -0700
Fix powerpoint file bugs.
Diffstat:
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/Songs2Slides.py b/Songs2Slides.py
@@ -5,6 +5,7 @@ from pptx import Presentation
from pptx.enum.text import PP_ALIGN
from pptx.util import Inches, Pt
import requests
+import sys
# Gets the lyrics
@@ -110,9 +111,23 @@ if (__name__ == "__main__"):
# Get filepath
filepath = input("Please enter a filepath to save your powerpoint to: ")
- # Create powerpoint
- CreatePptx(lyrics, filepath)
+ # Add extension
+ if (len(filepath) == 0):
+ filepath = "Untitled.pptx"
+ elif (len(filepath) < 4):
+ filepath += ".pptx"
+ elif (len(filepath) == 4 and filepath[-4:] != ".ppt"):
+ filepath += ".pptx"
+ elif (len(filepath) > 4 and filepath[-5:] != ".pptx" and filepath[-4:] != ".ppt"):
+ filepath += ".pptx"
+ # Create powerpoint
+ try:
+ CreatePptx(lyrics, filepath)
+ except:
+ print("We were unable to create the powerpoint.")
+ sys.exit()
+
# Open powerpoint
if (input("Do you want to view your powerpoint now? (y/n): ").lower() == "y"):
os.startfile(filepath)