ssync.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python3
  2. # Copyright © 2024 Noah Vogt <noah@noahvogt.com>
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. import colorama
  14. from utils import clear_obs_slides_dir
  15. from slides import (
  16. SlideStyle,
  17. ClassicSongSlide,
  18. ClassicSongTemplate,
  19. ClassicStartSlide,
  20. )
  21. from input import (
  22. validate_ssync_config,
  23. slide_selection_iterator,
  24. parse_ssync_args_as_tuple,
  25. SsyncFlags,
  26. )
  27. from sync import sync_slide_repo, save_new_checkfile, syncing_needed
  28. def ssync(ssync_flags: SsyncFlags, slide_style: SlideStyle) -> None:
  29. validate_ssync_config()
  30. if syncing_needed(ssync_flags.offline_enabled):
  31. sync_slide_repo()
  32. save_new_checkfile()
  33. clear_obs_slides_dir()
  34. slide_selection_iterator(ssync_flags.disable_async_enabled, slide_style)
  35. def main() -> None:
  36. colorama.init()
  37. classic_slide_style = SlideStyle(
  38. ClassicSongTemplate, # pyright: ignore [reportGeneralTypeIssues]
  39. ClassicStartSlide, # pyright: ignore [reportGeneralTypeIssues]
  40. ClassicSongSlide, # pyright: ignore [reportGeneralTypeIssues]
  41. )
  42. ssync_flags = SsyncFlags(*parse_ssync_args_as_tuple())
  43. ssync(ssync_flags, classic_slide_style)
  44. if __name__ == "__main__":
  45. main()