Class: AccessPage

Inherits:
ServiceCall show all
Defined in:
lib/etvnet_seek/core/access_page.rb

Constant Summary collapse

ACCESS_URL =
Page::BASE_URL + "/watch/"

Instance Attribute Summary

Attributes inherited from ServiceCall

#url

Instance Method Summary collapse

Methods inherited from ServiceCall

#get, #post

Constructor Details

#initializeAccessPage

Returns a new instance of AccessPage.



10
11
12
# File 'lib/etvnet_seek/core/access_page.rb', line 10

def initialize
  super(ACCESS_URL)
end

Instance Method Details

#request_media_info(media_file, cookie) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/etvnet_seek/core/access_page.rb', line 14

def request_media_info media_file, cookie
  params = { 'bitrate' => '2', 'view' => 'submit'}

  if true
    params['high_quality'] = ""
  end

  headers = { 'Cookie' => cookie, 'X-Requested-With' =>	'XMLHttpRequest' }

  response = post(params, headers, url + "#{media_file}/")

  # MediaInfo.new Nokogiri::HTML(response.body).css("ref").at(0).attributes["href"].text

  json = JSON.parse(response.body)

  if response.kind_of? Net::HTTPOK
    MediaInfo.new json["url"]
  else
    raise "Problem getting url: #{response.class.name}: #{json['msg']} "
  end
end