Parcourir la source

add dependency + don't use utf8-sig when creating files for creating audio + more refined config requirements for creating audio

Noah Vogt il y a 1 an
Parent
commit
4b19fe8db7
7 fichiers modifiés avec 23 ajouts et 17 suppressions
  1. 1 0
      README.md
  2. 1 0
      input/__init__.py
  3. 11 3
      input/validate_config.py
  4. 3 3
      recording/cd.py
  5. 2 2
      recording/sermon.py
  6. 4 6
      set_cd_marker.py
  7. 1 3
      utils/path.py

+ 1 - 0
README.md

@@ -313,6 +313,7 @@ First, install a reasonably new version of
 
 - [git](https://git-scm.com/)
 - [ffmpeg](https://ffmpeg.org/)
+- [cdrtools](https://sourceforge.net/projects/cdrtools/files/)
 - [fzf](https://github.com/junegunn/fzf)
 - [imagemagick](https://imagemagick.org/script/download.php) (If you are a windows user, select the c/c++ developer headers. Also you may need vcredist for imagemagick to work.)
 - [python3](https://www.python.org/)

+ 1 - 0
input/__init__.py

@@ -29,6 +29,7 @@ from .validate_config import (
     validate_obs_song_scene_switcher_config,
     validate_cd_record_config,
     validate_sermon_upload_config,
+    validate_cd_burn_config,
 )
 from .slide_selection_iterator import slide_selection_iterator
 from .gui import (

+ 11 - 3
input/validate_config.py

@@ -43,10 +43,18 @@ def validate_obs_song_scene_switcher_config() -> None:
     general_config_validator(needed_constants)
 
 
-def validate_cd_record_config() -> None:
+def validate_cd_burn_config() -> None:
     needed_constants: dict = {
         "CD_RECORD_CACHEFILE": const.CD_RECORD_CACHEFILE,
         "CD_RECORD_OUTPUT_BASEDIR": const.CD_RECORD_OUTPUT_BASEDIR,
+    }
+    general_config_validator(needed_constants)
+
+
+def validate_cd_record_config() -> None:
+    validate_cd_burn_config()
+
+    needed_constants: dict = {
         "CD_RECORD_FFMPEG_INPUT_ARGS": const.CD_RECORD_FFMPEG_INPUT_ARGS,
         "CD_RECORD_MAX_SECONDS": const.CD_RECORD_MAX_SECONDS,
         "CD_RECORD_MIN_TRACK_MILIS": const.CD_RECORD_MIN_TRACK_MILIS,
@@ -55,9 +63,9 @@ def validate_cd_record_config() -> None:
 
 
 def validate_sermon_upload_config() -> None:
+    validate_cd_burn_config()
+
     needed_constants: dict = {
-        "CD_RECORD_CACHEFILE": const.CD_RECORD_CACHEFILE,
-        "CD_RECORD_OUTPUT_BASEDIR": const.CD_RECORD_OUTPUT_BASEDIR,
         "SERMON_UPLOAD_FTP_HOSTNAME": const.SERMON_UPLOAD_FTP_HOSTNAME,
         "SERMON_UPLOAD_FTP_USER": const.SERMON_UPLOAD_FTP_USER,
         "SERMON_UPLOAD_FTP_PASSWORD": const.SERMON_UPLOAD_FTP_PASSWORD,

+ 3 - 3
recording/cd.py

@@ -31,7 +31,7 @@ import config as const
 from input import (
     InfoMsgBox,
     RadioButtonDialog,
-    validate_cd_record_config,
+    validate_cd_burn_config,
     WaveAndSheetPreviewChooserGUI,
 )
 from utils import expand_dir, log, make_sure_file_exists
@@ -148,7 +148,7 @@ def burn_and_eject_cd(
 
 
 def burn_cds_of_day(yyyy_mm_dd: str) -> None:
-    validate_cd_record_config()
+    validate_cd_burn_config()
     make_sure_file_exists(const.CD_RECORD_CACHEFILE)
 
     try:
@@ -221,7 +221,7 @@ def mark_end_of_recording(cachefile_content: list) -> None:
 
     log("marking end of recording...")
     try:
-        with open(cachefile, mode="w+", encoding="utf-8-sig") as file_writer:
+        with open(cachefile, mode="w+", encoding="utf-8") as file_writer:
             file_writer.write(cachefile_content[0].strip() + "\n")
             file_writer.write("9001\n")
             file_writer.write(cachefile_content[2].strip() + "\n")

+ 2 - 2
recording/sermon.py

@@ -49,7 +49,7 @@ def get_full_wav_path(segment: SermonSegment) -> str:
         with open(
             segment.source_cue_sheet,
             mode="r",
-            encoding="utf-8-sig",
+            encoding="utf-8",
         ) as cue_sheet_reader:
             cue_sheet_content = cue_sheet_reader.readlines()
         first_line = cue_sheet_content[0].strip()
@@ -148,7 +148,7 @@ def get_possible_sermon_segments_of_day(yyyy_mm_dd: str) -> list[SermonSegment]:
             with open(
                 path.join(day_dir, sheet),
                 mode="r",
-                encoding="utf-8-sig",
+                encoding="utf-8",
             ) as sheet_reader:
                 sheet_content = sheet_reader.readlines()
             start_frame = 0

+ 4 - 6
set_cd_marker.py

@@ -75,9 +75,7 @@ def start_cd_recording() -> None:
         cachefile = expand_dir(const.CD_RECORD_CACHEFILE)
         log("updating active ffmpeg pid")
         try:
-            with open(
-                cachefile, mode="w+", encoding="utf-8-sig"
-            ) as file_writer:
+            with open(cachefile, mode="w+", encoding="utf-8") as file_writer:
                 file_writer.write(cachefile_content[0].strip() + "\n")
                 # reset marker to 1
                 file_writer.write("1\n")
@@ -142,7 +140,7 @@ def create_cachefile_for_marker(
 
     log("writing cd marker {} to cachefile...".format(marker))
     try:
-        with open(cachefile, mode="w+", encoding="utf-8-sig") as file_writer:
+        with open(cachefile, mode="w+", encoding="utf-8") as file_writer:
             file_writer.write(f"{yyyy_mm_dd}\n")
             file_writer.write(f"{marker}\n")
             if initial_run:
@@ -183,7 +181,7 @@ def update_cue_sheet(
             if not path.exists(cue_sheet_dir):
                 mkdir(cue_sheet_dir)
             with open(
-                cue_sheet_path, mode="w+", encoding="utf-8-sig"
+                cue_sheet_path, mode="w+", encoding="utf-8"
             ) as file_writer:
                 file_writer.write(f'FILE "{wave_path}" WAVE\n')
                 file_writer.write("  TRACK 01 AUDIO\n")
@@ -235,7 +233,7 @@ def update_cue_sheet(
         log("updating cue sheet...")
         try:
             with open(
-                cue_sheet_path, mode="a", encoding="utf-8-sig"
+                cue_sheet_path, mode="a", encoding="utf-8"
             ) as file_writer:
                 file_writer.write("  TRACK {:02d} AUDIO\n".format(marker))
                 file_writer.write(

+ 1 - 3
utils/path.py

@@ -27,9 +27,7 @@ def expand_dir(directory: str) -> str:
 def make_sure_file_exists(filename: str) -> None:
     if not path.isfile(filename):
         try:
-            with open(
-                filename, mode="w+", encoding="utf-8-sig"
-            ) as file_creator:
+            with open(filename, mode="w+", encoding="utf-8") as file_creator:
                 file_creator.write("")
         except (FileNotFoundError, PermissionError, IOError) as error:
             error_msg(