From b6a1877dab105ed9bbaaabd47b42a6c6498a14b9 Mon Sep 17 00:00:00 2001 From: Jennifer Wellnitz Date: Fri, 17 Jan 2025 15:23:18 -0500 Subject: [PATCH] derivative and caption naming --- app/services/spot/derivatives/audio_derivative_service.rb | 4 +++- app/services/spot/derivatives/video_derivative_service.rb | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/services/spot/derivatives/audio_derivative_service.rb b/app/services/spot/derivatives/audio_derivative_service.rb index 7bce94312..98735ae60 100644 --- a/app/services/spot/derivatives/audio_derivative_service.rb +++ b/app/services/spot/derivatives/audio_derivative_service.rb @@ -37,7 +37,9 @@ def create_derivatives(filename) # # @return [Boolean] def check_premade_derivatives(filename) - prefix = filename.to_s.split('/')[-1].split('.')[0] + "_derivative" + base_file = filename.to_s.split('/')[-1].split('.')[0] + project_name = base_file.split('_')[0] + prefix = project_name + "/" + base_file + "_derivative" object_list = s3_client.list_objects(bucket: s3_source, prefix: prefix).to_h[:contents] return false if object_list.nil? diff --git a/app/services/spot/derivatives/video_derivative_service.rb b/app/services/spot/derivatives/video_derivative_service.rb index de2c27bc7..3bba1a2ab 100644 --- a/app/services/spot/derivatives/video_derivative_service.rb +++ b/app/services/spot/derivatives/video_derivative_service.rb @@ -38,7 +38,9 @@ def create_derivatives(filename) # # @return [Boolean] def check_premade_derivatives(filename) - prefix = filename.to_s.split('/')[-1].split('.')[0] + "_derivative" + base_file = filename.to_s.split('/')[-1].split('.')[0] + project_name = base_file.split('_')[0] + prefix = project_name + "/" + base_file + "_derivative" object_list = s3_client.list_objects(bucket: s3_source, prefix: prefix).to_h[:contents] return false if object_list.nil? @@ -74,7 +76,9 @@ def rename_premade_derivative(derivative, index) # @param [String,Pathname] filename, the src path of the file # @return [void] def check_transcript(filename) - transcript_name = filename.to_s.split('/')[-1].split('.')[0] + ".vtt" + base_file = filename.to_s.split('/')[-1].split('.')[0] + project_name = base_file.split('_')[0] + transcript_name = project_name + "/" + base_file + "_caption.vtt" begin s3_client.head_object(bucket: s3_source, key: transcript_name) rescue Aws::S3::Errors::NotFound