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
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