Class: Subfinder::Subtitle

Inherits:
Object
  • Object
show all
Defined in:
lib/subfinder/subtitle.rb

Overview

Find and match subtitles

Instance Method Summary collapse

Constructor Details

#initializeSubtitle

Returns a new instance of Subtitle.



6
7
8
9
# File 'lib/subfinder/subtitle.rb', line 6

def initialize
  @success = 0
  @failure = 0
end

Instance Method Details

#matchObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/subfinder/subtitle.rb', line 11

def match
  Parser::Files.list.each do |video_file|
    # only consider video file types listed in confi
    next unless Config.video_formats.include? File.extname(video_file)
    next if subtitle_exists? video_file

    if episode_number(video_file).nil?
      Logger.info 'Can not find the episode and season number for:'\
                  " #{File.basename(video_file)}".red
      @failure += 1
      next
    else
      find_subtitle_for video_file
    end
  end
  Logger.info "Subtitle added: #{@success}, "\
              " Not found: #{@failure}, "\
              "Total file proccessed: #{@failure + @success}".green
end