class DailyRep::Entities::Kinozal

Attributes

out_hash_clean[R]
to_notification[R]

Public Class Methods

create() click to toggle source
# File lib/dailyrep/entities/Kinozal.rb, line 8
def self.create
    result = []
    result = Configer.get_search_strs('kinozal').map { |str|
      new str
    }
end
new(movie, source=Configer.kinozal_source, filters=Configer.kinozal_filters) click to toggle source
Calls superclass method DailyRep::IBrowser::new
# File lib/dailyrep/entities/Kinozal.rb, line 15
def initialize  movie, source=Configer.kinozal_source, filters=Configer.kinozal_filters
  super
  @movie = movie
  @search_path = source+@movie.gsub(' ','+') + filters
  @scope = 'td.nam  a'
  @dirty_words = ['тизер', 'трейлер']
  @out_hash_clean = {}
end

Public Instance Methods

log_msg(phase) click to toggle source
Calls superclass method DailyRep::Trackable#log_msg
# File lib/dailyrep/entities/Kinozal.rb, line 24
def log_msg phase
  super @entity, @movie, phase
end
notify() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Kinozal.rb, line 61
def notify
  super do
    @to_notification.each { |key, val|
      note = "Kinozal
      Movie appears: #{val[0]}
      Quality: #{val.last}
      Link: #{key}"
      push_note note
    }
  end
end
process() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Kinozal.rb, line 28
def process
  super do
    out_set = get_source_http @search_path, @scope
    out_hash_dirty = {}
    out_set.each { |el|
      out_hash_dirty.merge!({ el['href'] => el.text.split(' / ')})
    }
    out_hash_dirty.each { |key, val|
      exclude = 0
      @dirty_words.each { |word|
        if val[0].mb_chars.downcase.include?(word) then
          exclude = 1
          break
        end
      }
      @out_hash_clean.merge!({key => val}) if exclude == 0
    }
  end
end
web_reload() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Kinozal.rb, line 74
def web_reload
  super do
    i = 0
    diff = @to_notification.map { |key, val|
      i = i+1
      ['-', i , {'http://kinozal.tv/'+ key => val.join(' : ')} ]
    }
    set_html_with_diff @entity, '#kinozal',  diff, true
  end
end
write_to_db() click to toggle source
Calls superclass method
# File lib/dailyrep/entities/Kinozal.rb, line 48
def write_to_db
  super do
    @to_notification = {}
    @out_hash_clean.each { |key, val|
      id = key.split('id=')[1]
      if !check_row_exists(@entity, @movie, id) then
        write_hist(@entity, @movie, id, 1)
        @to_notification.merge!({key => [val[0], val.last]})
      end
    }
  end
end