Skip to content

Commit

Permalink
Added --keep-brand-code param
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Jan 17, 2025
1 parent 78f8880 commit dfdbd92
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
26 changes: 23 additions & 3 deletions karaoke_prep/karaoke_finalise/karaoke_finalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(
non_interactive=False,
email_template_file=None,
cdg_styles=None,
keep_brand_code=False,
):
self.logger = logging.getLogger(__name__)
self.logger.setLevel(log_level)
Expand Down Expand Up @@ -132,6 +133,8 @@ def __init__(
# Determine best available AAC codec
self.aac_codec = self.detect_best_aac_codec()

self.keep_brand_code = keep_brand_code

def check_input_files_exist(self, base_name, with_vocals_file, instrumental_audio_file):
self.logger.info(f"Checking required input files exist...")

Expand Down Expand Up @@ -882,6 +885,19 @@ def generate_organised_folder_sharing_link(self):
self.logger.error(f"Command output (stderr): {e.stderr}")
self.logger.error(f"Full exception: {e}")

def get_existing_brand_code(self):
"""Extract brand code from current directory name"""
current_dir = os.path.basename(os.getcwd())
if " - " not in current_dir:
raise Exception(f"Current directory '{current_dir}' does not match expected format 'BRAND-XXXX - Artist - Title'")

brand_code = current_dir.split(" - ")[0]
if not brand_code or "-" not in brand_code:
raise Exception(f"Could not extract valid brand code from directory name '{current_dir}'")

self.logger.info(f"Using existing brand code: {brand_code}")
return brand_code

def execute_optional_features(self, artist, title, base_name, input_files, output_files):
self.logger.info(f"Executing optional features...")

Expand All @@ -900,16 +916,20 @@ def execute_optional_features(self, artist, title, base_name, input_files, outpu
self.post_discord_notification()

if self.folder_organisation_enabled:
self.brand_code = self.get_next_brand_code()
if self.keep_brand_code:
self.brand_code = self.get_existing_brand_code()
self.new_brand_code_dir = os.path.basename(os.getcwd())
self.new_brand_code_dir_path = os.getcwd()
else:
self.brand_code = self.get_next_brand_code()
self.move_files_to_brand_code_folder(self.brand_code, artist, title, output_files)

if self.public_share_copy_enabled:
self.copy_final_files_to_public_share_dirs(self.brand_code, base_name, output_files)

if self.public_share_rclone_enabled:
self.sync_public_share_dir_to_rclone_destination()

self.move_files_to_brand_code_folder(self.brand_code, artist, title, output_files)

self.generate_organised_folder_sharing_link()

def authenticate_gmail(self):
Expand Down
7 changes: 7 additions & 0 deletions karaoke_prep/utils/finalise_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ def main():
help="Optional: Path to JSON file containing CDG style configuration. Required if --enable_cdg is used. Example: --style_params_json='/path/to/cdg_styles.json'",
)

parser.add_argument(
"--keep-brand-code",
action="store_true",
help="Optional: Use existing brand code from current directory instead of generating new one (default: disabled). Example: --keep-brand-code",
)

args = parser.parse_args()

log_level = getattr(logging, args.log_level.upper())
Expand Down Expand Up @@ -170,6 +176,7 @@ def main():
discord_webhook_url=args.discord_webhook_url,
email_template_file=args.email_template_file,
cdg_styles=cdg_styles,
keep_brand_code=args.keep_brand_code,
)

if args.test_email_template:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "karaoke-prep"
version = "0.35.5"
version = "0.36.0"
description = "Prepare for karaoke video creation, by downloading audio and lyrics for a specified song or playlist from youtube and separating audio stems. After syncing, finalise the video with a title screen!"
authors = ["Andrew Beveridge <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit dfdbd92

Please sign in to comment.