Class: Accessor
- Inherits:
-
Object
- Object
- Accessor
- Defined in:
- lib/etvnet_seek/accessor.rb
Instance Method Summary collapse
- #access(item, *params) ⇒ Object
-
#initialize(cookie_file_name, credentials_collector) ⇒ Accessor
constructor
A new instance of Accessor.
- #login(username, password) ⇒ Object
- #try_again? ⇒ Boolean
Constructor Details
#initialize(cookie_file_name, credentials_collector) ⇒ Accessor
Returns a new instance of Accessor.
7 8 9 10 11 12 13 |
# File 'lib/etvnet_seek/accessor.rb', line 7 def initialize , credentials_collector @cookie_helper = CookieHelper.new @credentials_collector = credentials_collector @access_page = AccessPage.new @login_page = LoginPage.new end |
Instance Method Details
#access(item, *params) ⇒ Object
15 16 17 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 |
# File 'lib/etvnet_seek/accessor.rb', line 15 def access item, *params @try_again = false = @cookie_helper. if .nil? username, password = *@credentials_collector.call(*params) @try_again = login(username, password) nil #access item else .gsub!("\"", "\"\"") result1 = .scan(/.*sessid=([\d|\w]*);.*/) result2 = .scan(/.*_lc=([\d|\w]*);.*/) = "sessid=#{result1[0][0]};_lc=#{result2[0][0]}" media_info = @access_page.request_media_info(item.link.scan(/.*\/(\d*)\//)[0][0], ) if media_info.session_expired? @cookie_helper. username, password = *@credentials_collector.call(*params) @try_again = login(username, password) nil #access item else LinkInfo.new(item, media_info) end end end |
#login(username, password) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/etvnet_seek/accessor.rb', line 56 def login username, password = @login_page.login(username, password) @cookie_helper. .nil? end |
#try_again? ⇒ Boolean
52 53 54 |
# File 'lib/etvnet_seek/accessor.rb', line 52 def try_again? @try_again end |