Class: FYT::Parser

Inherits:
Base
  • Object
show all
Defined in:
lib/fyt/parser.rb

Overview

reads and prepares a youtube feed for further processing

Instance Method Summary collapse

Methods inherited from Base

#logger

Constructor Details

#initialize(url, proxy_manager) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
# File 'lib/fyt/parser.rb', line 8

def initialize(url, proxy_manager)
  @url = url
  @proxy_manager = proxy_manager
end

Instance Method Details

#readObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fyt/parser.rb', line 13

def read
  proxy = @proxy_manager.get!

  open(@url, proxy: 'http://' + proxy.url) do |rss|
    return RSS::Parser.parse(rss, false)
  end
rescue
  @proxy_manager.remove(proxy)

  read if @proxy_manager.proxies.size > 0
end