Class: Nicovideo::VideoPage

Inherits:
Page
  • Object
show all
Defined in:
lib/nicovideo/videopage.rb

Constant Summary

Constants inherited from Page

Page::BASE_TITLE, Page::BASE_URL, Page::NV_DEBUG_LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Page

#exists?, #html

Constructor Details

#initialize(agent, video_id) ⇒ VideoPage

Returns a new instance of VideoPage.



6
7
8
9
10
11
12
# File 'lib/nicovideo/videopage.rb', line 6

def initialize agent, video_id
  super(agent)
  @video_id = video_id
  @params   = nil
  @url      = BASE_URL + '/watch/' + @video_id
  register_getter ["title", "tags", "published_at"]
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



14
15
16
# File 'lib/nicovideo/videopage.rb', line 14

def url
  @url
end

#video_idObject (readonly)

Returns the value of attribute video_id.



14
15
16
# File 'lib/nicovideo/videopage.rb', line 14

def video_id
  @video_id
end

Instance Method Details

#comments(num = 500) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nicovideo/videopage.rb', line 18

def comments(num=500)
  puts_info 'getting comment xml : id = ' + @video_id
  begin
    @params = get_params unless @params
    ms = @params['ms']
    raise ArgError unless ms
    
    thread_id = @params['thread_id']
    body = %!<thread res_from="-#{num}" version="20061206" thread="#{thread_id}" />!
    post_url = CGI.unescape(ms)
    comment_xml = @agent.post_data(post_url, body).body
    puts_debug comment_xml
    Comments.new(@video_id, comment_xml)
  end
end

#flvObject



34
# File 'lib/nicovideo/videopage.rb', line 34

def flv() return video() end

#idObject



16
# File 'lib/nicovideo/videopage.rb', line 16

def id()   @video_id end

#openlist(page = 1) ⇒ Object



49
50
51
# File 'lib/nicovideo/videopage.rb', line 49

def openlist(page=1)
  OpenList.new(@agent, @video_id)
end

#title=(title) ⇒ Object



45
46
47
# File 'lib/nicovideo/videopage.rb', line 45

def title=(title)
  @title = title
end

#videoObject



36
37
38
39
40
41
42
43
# File 'lib/nicovideo/videopage.rb', line 36

def video()
  begin
    @params ||= get_params
    video_url = CGI.unescape(@params['url'])
    video_flv = @agent.get_file(video_url)
    video_flv
  end
end