Class: Sportsflix::Providers::Arenavision::Client
- Inherits:
-
Object
- Object
- Sportsflix::Providers::Arenavision::Client
- Defined in:
- lib/sportsflix/providers/arenavision.rb
Constant Summary collapse
- BASE_URLS =
['http://arenavision.in', 'http://arenavision.biz', 'http://arenavision.us']
- BASE_URL =
BASE_URLS.sample
Instance Method Summary collapse
- #get_stream_uri(stream_nr, event) ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #list_streams ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/sportsflix/providers/arenavision.rb', line 11 def initialize() @verbose = [:verbose] @club_name = [:club] @server_only = ['server-only'] @http = Sportsflix::Utils::HTTP.new end |
Instance Method Details
#get_stream_uri(stream_nr, event) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/sportsflix/providers/arenavision.rb', line 57 def get_stream_uri(stream_nr, event) home = get_page_contents("#{BASE_URL}/") stream_link = home.css('a').select { |item| item.text.include?("#{event} #{stream_nr}") }.first.get('href') stream_raw = get_page_contents(stream_link) stream_raw.css('a').select { |item| !item.get('href').nil? && item.get('href').include?('acestream://') }.first.get('href') end |
#list_streams ⇒ Object
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 54 55 |
# File 'lib/sportsflix/providers/arenavision.rb', line 18 def list_streams home = get_page_contents("#{BASE_URL}/") schedule_path = home.css('a').select { |item| item.text.include?('EVENTS GUIDE') }.first.get('href') schedule_url = if schedule_path.start_with?("http") schedule_path else "#{BASE_URL}#{schedule_path}" end schedule = get_page_contents(schedule_url) streams = schedule.css('table tr') # Remove first element streams = streams.drop(1) # Remove last element streams.pop(2) # Remove weird empty lines with non-breaking spaces ?!? streams = streams.select do |item| item_text = item.css('td:nth-child(1)').text item_text = item_text.force_encoding('UTF-8') item_text = item_text.delete(' ').strip script_text = item.css('td:nth-child(1) script').text not item_text.empty? and script_text.empty? end streams.map do |item| { :date => clean_str(item.css('td:nth-child(1)').text), :hour => clean_str(item.css('td:nth-child(2)').text), :sport => clean_str(item.css('td:nth-child(3)').text), :competition => clean_str(item.css('td:nth-child(4)').text), :game => clean_str(item.css('td:nth-child(5)').text), :stream_nr => parse_stream_ids(clean_str(item.css('td:nth-child(6)').text)), :proxy => :acestream } end end |