Skip to content

Commit

Permalink
Added dropbox sharing link to output
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Sep 17, 2024
1 parent 6362c42 commit 60d347e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
29 changes: 26 additions & 3 deletions karaoke_prep/karaoke_finalise/karaoke_finalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.http import MediaFileUpload
import subprocess


class KaraokeFinalise:
Expand Down Expand Up @@ -556,13 +557,12 @@ def remux_and_encode_output_video_files(self, with_vocals_file, input_files, out
env_mov_input = f"-i {end_mov_file}"
ffmpeg_filter = '-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]"'


aac_codec = "libfdk_aac"

# Check if aac_at codec is available
codec_check_command = f'{self.ffmpeg_base_command} -codecs'
codec_check_command = f"{self.ffmpeg_base_command} -codecs"
result = os.popen(codec_check_command).read()
if 'aac_at' in result:
if "aac_at" in result:
aac_codec = "aac_at"

join_ffmpeg_command = f'{self.ffmpeg_base_command} -i {title_mov_file} -i {karaoke_mov_file} {env_mov_input} {ffmpeg_filter} -map "[outv]" -map "[outa]" -c:v libx264 -c:a {aac_codec} -q:a 14 {output_final_mp4_file}'
Expand Down Expand Up @@ -715,6 +715,24 @@ def post_discord_notification(self):
discord_message = f"New upload: {self.youtube_url}"
self.post_discord_message(discord_message, self.discord_webhook_url)

def get_dropbox_sharing_link(self):
self.logger.info(f"Getting Dropbox sharing link for new brand code directory...")

if self.dry_run:
self.logger.info(f"DRY RUN: Would get Dropbox sharing link for: {self.new_brand_code_dir_path}")
return "https://www.dropbox.com/sh/dryrun_link"

rclone_link_cmd = f"rclone link '{self.rclone_destination}/{os.path.basename(self.new_brand_code_dir_path)}'"

try:
result = subprocess.run(rclone_link_cmd, shell=True, check=True, capture_output=True, text=True)
dropbox_link = result.stdout.strip()
self.logger.info(f"Got Dropbox sharing link: {dropbox_link}")
return dropbox_link
except subprocess.CalledProcessError as e:
self.logger.error(f"Failed to get Dropbox sharing link: {e}")
return None

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

Expand Down Expand Up @@ -768,6 +786,10 @@ def process(self):

self.execute_optional_features(artist, title, base_name, input_files, output_files)

dropbox_sharing_link = None
if self.folder_organisation_enabled and self.public_share_rclone_enabled:
dropbox_sharing_link = self.get_dropbox_sharing_link()

result = {
"artist": artist,
"title": title,
Expand All @@ -777,6 +799,7 @@ def process(self):
"youtube_url": self.youtube_url,
"brand_code": self.brand_code,
"new_brand_code_dir_path": self.new_brand_code_dir_path,
"dropbox_sharing_link": dropbox_sharing_link,
}

if self.enable_cdg:
Expand Down
4 changes: 3 additions & 1 deletion karaoke_prep/utils/finalise_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ def main():
logger.info(f" Final TXT+MP3 ZIP: {track['final_karaoke_txt_zip']}")

logger.info(f" Final Video with Title: {track['final_video']}")
logger.info(f" YouTube URL: {track['youtube_url']}")
logger.info(f" Brand Code: {track['brand_code']}")
logger.info(f" New Brand Code Directory: {track['new_brand_code_dir_path']}")

logger.info(f" YouTube URL: {track['youtube_url']}")
logger.info(f" Dropbox Sharing Link: {track['dropbox_sharing_link']}")


if __name__ == "__main__":
main()
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.23.0"
version = "0.23.1"
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 <andrew@beveridge.uk>"]
license = "MIT"
Expand Down

0 comments on commit 60d347e

Please sign in to comment.