Class: ArchiveMediaPage

Inherits:
BasePage show all
Defined in:
lib/etvnet_seek/core/archive_media_page.rb

Constant Summary

Constants inherited from Page

Page::BASE_URL

Instance Attribute Summary

Attributes inherited from Page

#document

Attributes inherited from ServiceCall

#url

Instance Method Summary collapse

Methods inherited from BasePage

#page_title, #title

Methods inherited from Page

#initialize

Methods inherited from ServiceCall

#get, #initialize, #post

Constructor Details

This class inherits a constructor from Page

Instance Method Details

#itemsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
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
# File 'lib/etvnet_seek/core/archive_media_page.rb', line 2

def items
  list = []

  document.css("b a.media_file").each do |item|
    link = item.attributes['href'].value
    new_link = list.select {|l| l.link == link}.empty?

    if new_link
      text = item.content.strip
      additional_info = additional_info(item, 1)

      text += additional_info unless additional_info.nil?

      tr = item.parent.parent.parent
      showtime = tr.css("td[1]").text.strip
      rating_image = tr.css("td[2] img").at(0) ? tr.css("td[2] img").at(0).attributes['src'].value.strip : ""
      rating = tr.css("td[3]").text.strip

      year = tr.css("td[6]") ? tr.css("td[6]").text.strip : ""
      duration = tr.css("td[7]").text.strip ? tr.css("td[7]").text.strip : ""
      channel = tr.css("td[8]") ? tr.css("td[8]").text.strip : ""

      if link =~ /action=browse_container/
        folder = true
        link = link[Page::BASE_URL.size..link.size]
      else
        folder = false
      end

      record = ArchiveMediaItem.new(text, link)
      record.folder = folder
      record.rating_image = rating_image
      record.rating = rating
      record.showtime = showtime
      record.duration = duration
      record.year = year
      record.channel = channel

      list << record
    end
  end

  list
end