Class: Inspector

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Inspector

Returns a new instance of Inspector.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/inspector.rb', line 11

def initialize(path , options = {})
  @path = Pathname.new(path).realpath.to_s
  @langs = options[:lang] ? options[:lang].split(',') : ['fr','en']
  
  # Initialize Logger
  @log = Logger.new(options[:log_path] || "#{@path}/_autosub_.log" )
  @log.datetime_format = "%Y-%m-%d %H:%M:%S "
  log.info "Begin searching for '#{langs.join(',')}' subtitles..."
  
  $stdout.print "--- Searching for '#{langs.join(',')}' subtitles ---\n"
  @tv_shows = [] # {:name => ..., :path => ...}
  initialize_tv_shows
  $stdout.print "Found #{@tv_shows.size} TV Show(s) in #{@path}\n"
  
  @episodes = []
  initialize_episodes
  # keep only episodes who needs srt
  $stdout.print "Found #{@episodes.select { |e| e.need_srt?(@langs) }.size} episode(s) who need(s) srt\n"
  
  # Find new srt
  begin
    Podnapisi.new(self)
  rescue => e
    log.fatal "Problem with Podnapisi: #{e}"
  end
  begin
    TVSubtitle.new(self)
  rescue => e
    log.fatal "Problem with TVSubtitle: #{e}"
  end
  begin  
    SeriesSub.new(self)
  rescue => e
    log.fatal "Problem with SeriesSub: #{e}"
  end
end

Instance Attribute Details

#episodesObject

Returns the value of attribute episodes.



9
10
11
# File 'lib/inspector.rb', line 9

def episodes
  @episodes
end

#langsObject

Returns the value of attribute langs.



9
10
11
# File 'lib/inspector.rb', line 9

def langs
  @langs
end

#logObject

Returns the value of attribute log.



9
10
11
# File 'lib/inspector.rb', line 9

def log
  @log
end

#tv_showsObject

Returns the value of attribute tv_shows.



9
10
11
# File 'lib/inspector.rb', line 9

def tv_shows
  @tv_shows
end

Class Method Details

.growl(title, msg, icon, pri = 0) ⇒ Object



52
53
54
# File 'lib/inspector.rb', line 52

def self.growl(title, msg, icon, pri = 0)
  system("/usr/local/bin/growlnotify -w -n autosub --image #{File.dirname(__FILE__) + "/../asset/#{icon}"} -p #{pri} -m #{msg.inspect} #{title} &") 
end

Instance Method Details

#growl_episode(episode, lang) ⇒ Object



48
49
50
# File 'lib/inspector.rb', line 48

def growl_episode(episode, lang)
  Inspector.growl episode.episode_name_with_format, "#{lang_name(lang)} srt added", "srt.png"
end