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.



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
48
49
50
51
52
53
# File 'lib/inspector.rb', line 13

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

Instance Attribute Details

#episodesObject

Returns the value of attribute episodes.



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

def episodes
  @episodes
end

#langsObject

Returns the value of attribute langs.



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

def langs
  @langs
end

#logObject

Returns the value of attribute log.



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

def log
  @log
end

#tv_showsObject

Returns the value of attribute tv_shows.



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

def tv_shows
  @tv_shows
end

Class Method Details

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



59
60
61
# File 'lib/inspector.rb', line 59

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



55
56
57
# File 'lib/inspector.rb', line 55

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