Parent

Files

Nicovideo::VideoPage

Attributes

url[R]
video_id[R]

Public Class Methods

new(agent, video_id) click to toggle source
# 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", "csrf_token"]
end

Public Instance Methods

comments(num=500) click to toggle source
# File lib/nicovideo/videopage.rb, line 32
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
flv() click to toggle source
# File lib/nicovideo/videopage.rb, line 48
def flv() return video() end
id() click to toggle source
# File lib/nicovideo/videopage.rb, line 16
def id()   @video_id end
low?() click to toggle source
# File lib/nicovideo/videopage.rb, line 67
def low?
  @params ||= get_params
  return true if CGI.unescape(@params['url']) =~ /low$/
  return false
end
openlist(page=1) click to toggle source
# File lib/nicovideo/videopage.rb, line 63
def openlist(page=1)
  OpenList.new(@agent, @video_id)
end
title=(title) click to toggle source
# File lib/nicovideo/videopage.rb, line 59
def title=(title)
  @title = title
end
type() click to toggle source
# File lib/nicovideo/videopage.rb, line 18
def type
  @params ||= get_params
  pattern = %^http://.*\.nicovideo\.jp/smile\?(.*?)=.*$!
  CGI.unescape(@params['url']) =~ pattern
  case $1
  when 'm'
    return 'mp4'
  when 's'
    return 'swf'
  else
    return 'flv'
  end
end
video() click to toggle source
# File lib/nicovideo/videopage.rb, line 50
def video()
  begin
    @params ||= get_params
    video_url = CGI.unescape(@params['url'])
    video_flv = @agent.get_file(video_url)
    video_flv
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.