Sha256: e1529fc85c301b9267a725b4869a03da9acddc0d9826797abfcb19c0f55e09a1

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module Twitchus
  class Worker
    def initialize(config_file)
      @config = Twitchus::Config.new
      @config.load(config_file)
      @checker = Twitchus::Checker.new(@config)
    end

    def run
      @storage = Twitchus::Storage.new(@config.host, @config.port, @config.key)
      # Since this can run periodically, clean the list first
      @storage.clear

      online_streams = @checker.fetch_all(@config.streams)
      online_streams.each do |data|
        channel = data["channel"]
        data = {
          title:   channel["status"],
          name:    channel["name"],
          image:   channel["banner"],
          preview: data["preview"]
        }

        @storage.push data.to_json
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitchus-0.1.1 lib/twitchus/worker.rb
twitchus-0.1.0 lib/twitchus/worker.rb