NicoUtil
Utility API for niconico (http://www.nicovideo.jp)
Features
- Use official search API easily
- Sign in to niconico
- Get comments of video
- Get comments of live
- Get comments of illust
- Download an illust
Install
Add the following line to Gemfile:
gem 'nico_util'
and run bundle install from your shell.
Or do the following:
$ gem install nico_util
Usage
require 'nico_util'Official Search API
# See <http://search.nicovideo.jp/docs/api/search.html> for parameters.
p NicoUtil::Video.search 'ボカロ'
p NicoUtil::Illust.search '東方', 'filters[viewCounter][gte]': 10000, _limit: 3
p NicoUtil::Live.search 'ゲーム'
p NicoUtil::Blog.search '音楽'
p NicoUtil::Book.search 'らき☆すた'
p NicoUtil::Channel.search '歌ってみた'
p NicoUtil::Comic.search 'ラブコメ'
p NicoUtil::News.search 'アニメ'Sign in
# write your account of niconico
email = 'niconico@example.com'
pass = 'password'
# login
nico = NicoUtil::login email, passVideo
# get comments of a video
comments = nico.video('sm1097445').comments
comments.each do |comment|
p comment
endLive
# connect to a live and show data
nico.live('lv242616226').connect do |status, data|
case status
when :comment
puts data
when :command
puts data
when :disconnect
puts 'disconnect'
end
endIllust
# get an illust
illust = nico.illust('im3768140')
# get comments of an illust
p illust.comments
# get raw url of an illust
p illust.image_url
# download and save an illust
illust.save '/path/to/image' # => /path/to/image.jpgContributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request :D
License
NicoUtil is released under the MIT license. See LICENSE for details.