slidegen.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 parse_prompt_input, parse_metadata, parse_songtext, parse_argv
  27. class Slidegen:
  28. def __init__(
  29. self, song_template_form, start_slide_form, song_slide_form
  30. ) -> None:
  31. self.metadata: dict = {"": ""}
  32. self.songtext: dict = {"": ""}
  33. self.song_file_path: str = ""
  34. self.song_file_content: list = []
  35. self.output_dir: str = ""
  36. self.chosen_structure: list | str = ""
  37. self.generated_slides: list = []
  38. self.song_template_form = song_template_form
  39. self.start_slide_form = start_slide_form
  40. self.song_slide_form = song_slide_form
  41. parse_argv(self)
  42. def execute(self) -> None:
  43. self.parse_file()
  44. self.calculate_desired_structures()
  45. self.generate_slides()
  46. def parse_file(self):
  47. parse_metadata(self)
  48. parse_songtext(self)
  49. def calculate_desired_structures(self) -> None:
  50. self.chosen_structure = parse_prompt_input(self)
  51. def generate_slides(self) -> None:
  52. template_img: Image = generate_song_template(self)
  53. slide_count: int = count_number_of_slides_to_be_generated(self)
  54. zfill_length: int = len(str(slide_count))
  55. generate_start_slide(self, template_img, zfill_length)
  56. generate_song_slides(self, slide_count, template_img, zfill_length)
  57. def main() -> None:
  58. colorama.init()
  59. slidegen: Slidegen = Slidegen(
  60. ClassicSongTemplate, ClassicStartSlide, ClassicSongSlide
  61. )
  62. slidegen.execute()
  63. if __name__ == "__main__":
  64. main()