Class: Appydave::Tools::SubtitleProcessor::Join
- Inherits:
-
Object
- Object
- Appydave::Tools::SubtitleProcessor::Join
- Defined in:
- lib/appydave/tools/subtitle_processor/join.rb
Overview
Join multiple SRT files into one
-
Supports folder, wildcards, sorting via FileResolver
Defined Under Namespace
Classes: FileResolver, Logger, SRTMerger, SRTParser, SRTWriter
Instance Method Summary collapse
-
#initialize(folder: './', files: '*.srt', sort: 'inferred', buffer: 100, output: 'merged.srt', log_level: :info) ⇒ Join
constructor
rubocop:disable Metrics/ParameterLists.
- #join ⇒ Object
Constructor Details
#initialize(folder: './', files: '*.srt', sort: 'inferred', buffer: 100, output: 'merged.srt', log_level: :info) ⇒ Join
rubocop:disable Metrics/ParameterLists
269 270 271 272 273 274 275 276 277 278 |
# File 'lib/appydave/tools/subtitle_processor/join.rb', line 269 def initialize(folder: './', files: '*.srt', sort: 'inferred', buffer: 100, output: 'merged.srt', log_level: :info) # rubocop:enable Metrics/ParameterLists @folder = folder @files = files @sort = sort @buffer = buffer @output = output @logger = Logger.new(log_level) end |
Instance Method Details
#join ⇒ Object
280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/appydave/tools/subtitle_processor/join.rb', line 280 def join @logger.log(:info, "Starting join operation in folder: #{@folder} with files: #{@files}") resolved_files = resolve_files @logger.log(:info, "Resolved files: #{resolved_files.join(', ')}") subtitle_groups = parse_files(resolved_files) @logger.log(:detail, "Parsed subtitles: #{subtitle_groups.map(&:size)} from files.") merged_subtitles = merge_subtitles(subtitle_groups) @logger.log(:info, "Merged #{subtitle_groups.flatten.size} subtitles into #{merged_subtitles.size} blocks.") write_output(merged_subtitles) @logger.log(:info, "Output written to #{@output}") end |