slidegen.py 2.6 KB

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