Class: Subfinder::Subtitle

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

Instance Method Summary collapse

Constructor Details

#initializeSubtitle

Returns a new instance of Subtitle.



4
5
6
7
# File 'lib/subfinder/subtitle.rb', line 4

def initialize
  @success = 0
  @failure = 0
end

Instance Method Details

#matchObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/subfinder/subtitle.rb', line 9

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 "Sub added: #{@success}, Sub not found: #{@failure}, Total file proccessed: #{@failure + @success}".green
end