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.



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
47
# File 'lib/inspector.rb', line 12

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
    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
  begin
    Podnapisi.new(self)
  rescue => e
    log.fatal "Problem with Podnapisi: #{e}"
  end
end

Instance Attribute Details

#episodesObject

Returns the value of attribute episodes.



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

def episodes
  @episodes
end

#langsObject

Returns the value of attribute langs.



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

def langs
  @langs
end

#logObject

Returns the value of attribute log.



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

def log
  @log
end

#tv_showsObject

Returns the value of attribute tv_shows.



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

def tv_shows
  @tv_shows
end

Class Method Details

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



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

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



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

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