Skip to content

Commit 74ba23f

Browse files
committed
Broken code.
1 parent ed91ba7 commit 74ba23f

File tree

2 files changed

+74
-24
lines changed

2 files changed

+74
-24
lines changed

ppt2video/convertor.py

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212

1313
def ppt2video(pptx, video, timing, duration,
14-
resolution, frames, quality, input_list):
14+
resolution, frames, quality, input_list, dict):
1515

1616
# Check if system requirements are met.
1717
if sys.platform == "win32":
1818
pass
1919
else:
20-
print("Sorry, this script can be run only on Windows.")
20+
print ("Sorry, this script can be run only on Windows.")
2121

22-
# Create fill pathes for the ppt and video files.
22+
# Create files pathes for the ppt and video files.
2323
ppt_path = os.path.abspath(pptx)
2424
video_path = os.path.abspath(video)
2525

@@ -30,26 +30,75 @@ def ppt2video(pptx, video, timing, duration,
3030
# Open presentation
3131
presentation = ppt.Presentations.Open(ppt_path, WithWindow=False)
3232

33-
slides_len = len(presentation.Slides)
34-
35-
while input_list:
36-
if len(input_list) == slides_len:
37-
n = 1 # To track the slide number to be created
38-
x = 0 # Index in the user input list
39-
while x < slides_len:
40-
# Create slide and insert it at n position with
41-
# input_list[x] text
42-
slide = presentation.Slides.Add(n, ppLayoutText)
43-
slide.Shapes.addShape(
44-
msoShapeRectangle, 150, 150, 250, 250). \
45-
TextFrame.TextRange.Text = input_list[x]
46-
n += 2
47-
x += 1
48-
break
49-
else:
50-
print("The length of input data should be equal to the \
51-
slides count")
52-
break
33+
# slides_len = len(presentation.Slides)
34+
35+
# powerpoint = win32com.client.Dispatch('PowerPoint.Application')
36+
# new_presentation = ppt.Presentations.Add(WithWindow=False)
37+
# list_slides = [e for e in presentation.Slides]
38+
# # for each in presentation.Slides:
39+
# for key, value in dict.items():
40+
# if presentation.Slides[int(key)] and value != "":
41+
# slide = new_presentation.Slides.Add(int(key)+1, ppLayoutText)
42+
# slide.Shapes.addShape(
43+
# msoShapeRectangle, 150, 150, 250, 250). \
44+
# TextFrame.TextRange.Text = value
45+
# # print(presentation.Slides[int(key)], key, value)
46+
# else:
47+
# print("NO value", presentation.Slides[int(key)], key, value)
48+
# if presentation.Slides[int(key)]:
49+
# slide = new_presentation.Slides.Add(int(key), ppLayoutText)
50+
# slide.Shapes.addShape(
51+
# msoShapeRectangle, 150, 150, 250, 250). \
52+
# TextFrame.TextRange.Text = value
53+
# for key, value in dict.items():
54+
# print("key for dict", key)
55+
56+
# Unpack the dict keys and values
57+
# for key, value in dict.items():
58+
# old_slides = [each for each in presentation.Slides]
59+
# if presentation.Slides[int(key)]:
60+
# slide = new_presentation.Slides.Add(int(key), ppLayoutText)
61+
# slide.Shapes.addShape(
62+
# msoShapeRectangle, 150, 150, 250, 250). \
63+
# TextFrame.TextRange.Text = value
64+
# new_presentation.Slides.Add(int(key), old_slides[int(key)+1])
65+
66+
# if old_slides[int(key)]:
67+
# slide = presentation.Slides.Add(int(key), ppLayoutText)
68+
# slide.Shapes.addShape(
69+
# msoShapeRectangle, 150, 150, 250, 250). \
70+
# TextFrame.TextRange.Text = value
71+
72+
73+
# for key, value in dict.items():
74+
# if value =="":
75+
# print("No value given", key)
76+
# n = key # slide number to be created,
77+
# x = value
78+
# slide = presentation.Slides.Add(n, ppLayoutText)
79+
# slide.Shapes.addShape(
80+
# msoShapeRectangle, 150, 150, 250, 250). \
81+
# TextFrame.TextRange.Text = x
82+
# slides_len = len(presentation.Slides)
83+
84+
# while input_list:
85+
# if len(input_list) == slides_len:
86+
# n = 1 # To track the slide number to be created
87+
# x = 0 # Index in the user input list
88+
# while x < slides_len:
89+
# # Create slide and insert it at n position with
90+
# # input_list[x] text
91+
# slide = presentation.Slides.Add(n, ppLayoutText)
92+
# slide.Shapes.addShape(
93+
# msoShapeRectangle, 150, 150, 250, 250). \
94+
# TextFrame.TextRange.Text = input_list[x]
95+
# n += 2
96+
# x += 1
97+
# break
98+
# else:
99+
# print("The length of input data should be equal to the \
100+
# slides count")
101+
# break
53102

54103
# Presentation.CreateVideo method (PowerPoint)
55104
# https://docs.microsoft.com/en-us/office/vba/api/powerpoint.presentation.createvideo
@@ -80,8 +129,9 @@ def ppt2video(pptx, video, timing, duration,
80129
# the first slide. You can leave it blank and no additional
81130
# slides will be inserted in the video.
82131
user_input_list = []
132+
input_dict = {"0":"0", "1":"1", "2":"2","3":"3","4":"4","5":"","6":"","7":"","8":"","9":""}
83133

84134
ppt2video(f"./{file_name}", f"./{video_name}.mp4",
85135
UseTimingsAndNarrations,
86136
DefaultSlideDuration, VertResolution,
87-
FramesPerSecond, Quality, user_input_list)
137+
FramesPerSecond, Quality, user_input_list, input_dict)

ppt2video/presentation_video.mp4

-1.41 MB
Binary file not shown.

0 commit comments

Comments
 (0)