Parent

Methods

Files

Nicovideo::MyList

Constants

NICO_MYLIST

Attributes

myliset_id[R]

Public Class Methods

new(agent, mylist_id) click to toggle source
# File lib/nicovideo/mylist.rb, line 12
def initialize agent, mylist_id
  super(agent)
  @mylist_id = mylist_id
  @raw_url = BASE_URL + '/mylist/' + @mylist_id
  @url     = BASE_URL + '/mylist/' + @mylist_id + '?rss=2.0'

  params = ["title", "user", "description", "videos", "rss"]
  self.register_getter params
end

Public Instance Methods

add(video_id) click to toggle source
# File lib/nicovideo/mylist.rb, line 27
def add(video_id)
  video_page = VideoPage.new @agent, video_id

  begin
    add_result = @agent.post(video_page.url, {
        :mylist => "add",
        :mylistgroup_name => "",
        :csrf_token => video_page.csrf_token,
        :group_id => @mylist_id,
        :ajax => "1"})

    result_code = JSON.parse(add_result.body.sub(/^\(?(.*?)\)?$/, '\1'))

    if result_code["result"] == "success" then
      # added video isn't applied to rss immediately, so add video into list by hand.
      page = @page || get_page(@url)
      @videos << video_page
      return self
    end
    raise ArgError if result_code["result"] == "duperror"
    raise StandardError
  rescue WWW::Mechanize::ResponseCodeError => e
    rc = e.response_code
    puts_info rc
    if rc == "404" || rc == "410"
      @not_found = true
      raise NotFound
    elsif rc == "403"
      raise Forbidden
    else
      raise e
    end
  end
end
id() click to toggle source
# File lib/nicovideo/mylist.rb, line 24
def id()  @mylist_id end
url() click to toggle source
# File lib/nicovideo/mylist.rb, line 25
def url() @raw_url   end

[Validate]

Generated with the Darkfish Rdoc Generator 2.