-
Notifications
You must be signed in to change notification settings - Fork 0
/
slidegen.py
executable file
·88 lines (69 loc) · 2.65 KB
/
slidegen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
# Copyright © 2024 Noah Vogt <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import colorama
from wand.image import Image
from slides import (
ClassicSongTemplate,
ClassicStartSlide,
ClassicSongSlide,
SlideStyle,
generate_slides,
generate_song_template,
count_number_of_slides_to_be_generated,
)
from input import (
parse_prompt_input,
parse_metadata,
parse_songtext,
parse_slidegen_argv_as_tuple,
)
class Slidegen:
def __init__(
self,
slide_style: SlideStyle,
song_file_path: str,
output_dir: str,
chosen_structure: str | list[str],
) -> None:
self.metadata: dict = {"": ""}
self.songtext: dict = {"": ""}
self.song_file_path: str = song_file_path
self.song_file_content: list = []
self.output_dir: str = output_dir
self.chosen_structure = chosen_structure
self.slide_style: SlideStyle = slide_style
def execute(self, disable_async=False) -> None:
self.parse_file()
self.calculate_desired_structures()
self.generate_slides(disable_async)
def parse_file(self):
parse_metadata(self)
parse_songtext(self)
def calculate_desired_structures(self) -> None:
self.chosen_structure = parse_prompt_input(self)
def generate_slides(self, disable_async: bool) -> None:
template_img: Image = generate_song_template(self)
slide_count: int = count_number_of_slides_to_be_generated(self)
zfill_length: int = len(str(slide_count))
generate_slides(
self, slide_count, template_img, zfill_length, disable_async
)
if __name__ == "__main__":
colorama.init()
classic_slide_style = SlideStyle(
ClassicSongTemplate, # pyright: ignore [reportGeneralTypeIssues]
ClassicStartSlide, # pyright: ignore [reportGeneralTypeIssues]
ClassicSongSlide, # pyright: ignore [reportGeneralTypeIssues]
)
slidegen = Slidegen(classic_slide_style, *parse_slidegen_argv_as_tuple())
slidegen.execute()