|
@@ -23,7 +23,6 @@ from utils import (
|
|
error_msg,
|
|
error_msg,
|
|
expand_dir,
|
|
expand_dir,
|
|
)
|
|
)
|
|
-from slides import ClassicSongTemplate, ClassicStartSlide, ClassicSongSlide
|
|
|
|
from input import parse_metadata, generate_final_prompt
|
|
from input import parse_metadata, generate_final_prompt
|
|
|
|
|
|
import config as const
|
|
import config as const
|
|
@@ -37,34 +36,23 @@ def slide_selection_iterator(ssync):
|
|
"Choose song structure (leave blank for full song)"
|
|
"Choose song structure (leave blank for full song)"
|
|
+ " eg. [1,R,2,R] / [1-4]: "
|
|
+ " eg. [1,R,2,R] / [1-4]: "
|
|
)
|
|
)
|
|
- file_list_str = ""
|
|
|
|
rclone_local_dir = expand_dir(const.RCLONE_LOCAL_DIR)
|
|
rclone_local_dir = expand_dir(const.RCLONE_LOCAL_DIR)
|
|
- obs_slides_dir = expand_dir(const.OBS_SLIDES_DIR)
|
|
|
|
- try:
|
|
|
|
- for file in os.listdir(rclone_local_dir):
|
|
|
|
- file_list_str += file + "\n"
|
|
|
|
- except (FileNotFoundError, PermissionError, IOError) as error:
|
|
|
|
- error_msg(
|
|
|
|
- "Failed to access items in '{}'. Reason: {}".format(
|
|
|
|
- rclone_local_dir, error
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
- file_list_str = file_list_str[:-1]
|
|
|
|
- const.SSYNC_CHOSEN_FILE_NAMING = ".chosen-tempfile"
|
|
|
|
|
|
|
|
- index = 0
|
|
|
|
|
|
+ song_counter = 0
|
|
while True:
|
|
while True:
|
|
- index += 1
|
|
|
|
- input_song_prompt = "[{}{}] ".format(const.OBS_SUBDIR_NAMING, index)
|
|
|
|
- prompt_answer = str(input(input_song_prompt + iterator_prompt))
|
|
|
|
|
|
+ song_counter += 1
|
|
|
|
+ input_prompt_prefix = "[{}{}] ".format(
|
|
|
|
+ const.OBS_SUBDIR_NAMING, song_counter
|
|
|
|
+ )
|
|
|
|
+ prompt_answer = str(input(input_prompt_prefix + iterator_prompt))
|
|
if prompt_answer.lower() == "y":
|
|
if prompt_answer.lower() == "y":
|
|
create_min_obs_subdirs()
|
|
create_min_obs_subdirs()
|
|
break
|
|
break
|
|
|
|
|
|
- file_list_str = file_list_str.replace("\n", "\\n")
|
|
|
|
os.system(
|
|
os.system(
|
|
'printf "{}" | fzf > {}'.format(
|
|
'printf "{}" | fzf > {}'.format(
|
|
- file_list_str, const.SSYNC_CHOSEN_FILE_NAMING
|
|
|
|
|
|
+ get_file_list_inside(rclone_local_dir),
|
|
|
|
+ const.SSYNC_CHOSEN_FILE_NAMING,
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
|
|
@@ -74,18 +62,13 @@ def slide_selection_iterator(ssync):
|
|
log("no slides chosen, skipping...")
|
|
log("no slides chosen, skipping...")
|
|
else:
|
|
else:
|
|
src_dir = os.path.join(rclone_local_dir, chosen_song_file)
|
|
src_dir = os.path.join(rclone_local_dir, chosen_song_file)
|
|
- dest_dir = create_and_get_dest_dir(obs_slides_dir, index)
|
|
|
|
|
|
+ dest_dir = create_and_get_dest_dir(
|
|
|
|
+ expand_dir(const.OBS_SLIDES_DIR), song_counter
|
|
|
|
+ )
|
|
|
|
|
|
- dummy_slidegen_instance = slidegen.Slidegen(
|
|
|
|
- ClassicSongTemplate,
|
|
|
|
- ClassicStartSlide,
|
|
|
|
- ClassicSongSlide,
|
|
|
|
- src_dir,
|
|
|
|
- dest_dir,
|
|
|
|
- "",
|
|
|
|
|
|
+ full_song_structure = get_structure_for_prompt(
|
|
|
|
+ ssync.slide_style, src_dir, dest_dir
|
|
)
|
|
)
|
|
- parse_metadata(dummy_slidegen_instance)
|
|
|
|
- full_song_structure = dummy_slidegen_instance.metadata["structure"]
|
|
|
|
log(
|
|
log(
|
|
"full song structure of '{}':\n{}".format(
|
|
"full song structure of '{}':\n{}".format(
|
|
chosen_song_file,
|
|
chosen_song_file,
|
|
@@ -95,31 +78,68 @@ def slide_selection_iterator(ssync):
|
|
)
|
|
)
|
|
|
|
|
|
structure_prompt_answer = input(
|
|
structure_prompt_answer = input(
|
|
- input_song_prompt + structure_prompt
|
|
|
|
|
|
+ input_prompt_prefix + structure_prompt
|
|
).strip()
|
|
).strip()
|
|
- calculated_prompt = generate_final_prompt(
|
|
|
|
- structure_prompt_answer, full_song_structure
|
|
|
|
- )
|
|
|
|
|
|
|
|
log(
|
|
log(
|
|
"generating slides '{}' to '{}{}'...".format(
|
|
"generating slides '{}' to '{}{}'...".format(
|
|
- chosen_song_file, const.OBS_SUBDIR_NAMING, index
|
|
|
|
|
|
+ chosen_song_file, const.OBS_SUBDIR_NAMING, song_counter
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
|
|
- executing_slidegen_instance = slidegen.Slidegen(
|
|
|
|
- ClassicSongTemplate,
|
|
|
|
- ClassicStartSlide,
|
|
|
|
- ClassicSongSlide,
|
|
|
|
|
|
+ generate_slides_for_selected_song(
|
|
|
|
+ ssync.slide_style,
|
|
src_dir,
|
|
src_dir,
|
|
dest_dir,
|
|
dest_dir,
|
|
- calculated_prompt,
|
|
|
|
|
|
+ generate_final_prompt(
|
|
|
|
+ structure_prompt_answer, full_song_structure
|
|
|
|
+ ),
|
|
|
|
+ ssync,
|
|
)
|
|
)
|
|
- executing_slidegen_instance.execute(ssync.disable_async)
|
|
|
|
|
|
|
|
remove_chosenfile()
|
|
remove_chosenfile()
|
|
|
|
|
|
|
|
|
|
|
|
+def generate_slides_for_selected_song(
|
|
|
|
+ classic_slide_style, src_dir, dest_dir, calculated_prompt, ssync
|
|
|
|
+) -> None:
|
|
|
|
+ executing_slidegen_instance = slidegen.Slidegen(
|
|
|
|
+ classic_slide_style,
|
|
|
|
+ src_dir,
|
|
|
|
+ dest_dir,
|
|
|
|
+ calculated_prompt,
|
|
|
|
+ )
|
|
|
|
+ executing_slidegen_instance.execute(ssync.disable_async)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def get_structure_for_prompt(classic_slide_style, src_dir, dest_dir):
|
|
|
|
+ dummy_slidegen_instance = slidegen.Slidegen(
|
|
|
|
+ classic_slide_style,
|
|
|
|
+ src_dir,
|
|
|
|
+ dest_dir,
|
|
|
|
+ "",
|
|
|
|
+ )
|
|
|
|
+ parse_metadata(dummy_slidegen_instance)
|
|
|
|
+ full_song_structure = dummy_slidegen_instance.metadata["structure"]
|
|
|
|
+ return full_song_structure
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def get_file_list_inside(rclone_local_dir):
|
|
|
|
+ file_list_str = ""
|
|
|
|
+ try:
|
|
|
|
+ for file in os.listdir(rclone_local_dir):
|
|
|
|
+ file_list_str += file + "\n"
|
|
|
|
+ except (FileNotFoundError, PermissionError, IOError) as error:
|
|
|
|
+ error_msg(
|
|
|
|
+ "Failed to access items in '{}'. Reason: {}".format(
|
|
|
|
+ rclone_local_dir, error
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ file_list_str = file_list_str[:-1]
|
|
|
|
+ file_list_str = file_list_str.replace("\n", "\\n")
|
|
|
|
+ return file_list_str
|
|
|
|
+
|
|
|
|
+
|
|
def remove_chosenfile() -> None:
|
|
def remove_chosenfile() -> None:
|
|
try:
|
|
try:
|
|
if os.path.isfile(const.SSYNC_CHOSEN_FILE_NAMING):
|
|
if os.path.isfile(const.SSYNC_CHOSEN_FILE_NAMING):
|