nico_util 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +25 -7
 - data/lib/nico_util/blog.rb +30 -0
 - data/lib/nico_util/book.rb +23 -0
 - data/lib/nico_util/channel.rb +24 -0
 - data/lib/nico_util/comic.rb +23 -0
 - data/lib/nico_util/news.rb +24 -0
 - data/lib/nico_util/version.rb +1 -1
 - data/lib/nico_util.rb +5 -0
 - metadata +8 -3
 - /data/{LICENSE.txt → LICENSE} +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0e665fdf4301e88392d2ce2ebc0f706dfb7c5d0d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b3b543e8b1f295695259f635a200f9f1df6b54e6
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7a593625e5bd9baf9482debbca739f9b3a801f1c8b60cf0cf416786d10e08c83c9e04ec4b6c7b05a7207711e9e501580b9f6f51d136c4c5680124ffef3526719
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9fb5c013df78295fad7ce0bf4cd1c899890a99b74a4b687f53d114d966d063a2133d0252391016d10f9d2d4f96dcf32f423eade07d4a460a63a072bbcb0e0125
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ Utility API for niconico (<http://www.nicovideo.jp>) 
     | 
|
| 
       9 
9 
     | 
    
         
             
            * Get comments of video
         
     | 
| 
       10 
10 
     | 
    
         
             
            * Get comments of live
         
     | 
| 
       11 
11 
     | 
    
         
             
            * Get comments of illust
         
     | 
| 
       12 
     | 
    
         
            -
            * Download  
     | 
| 
      
 12 
     | 
    
         
            +
            * Download an illust
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            ## Install
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
         @@ -31,27 +31,42 @@ $ gem install nico_util 
     | 
|
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
            ```ruby
         
     | 
| 
       33 
33 
     | 
    
         
             
            require 'nico_util'
         
     | 
| 
      
 34 
     | 
    
         
            +
            ```
         
     | 
| 
       34 
35 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
            ### Official Search API
         
     | 
| 
      
 37 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       36 
38 
     | 
    
         
             
            # See <http://search.nicovideo.jp/docs/api/search.html> for parameters.
         
     | 
| 
       37 
39 
     | 
    
         
             
            p NicoUtil::Video.search 'ボカロ'
         
     | 
| 
       38 
40 
     | 
    
         
             
            p NicoUtil::Illust.search '東方', 'filters[viewCounter][gte]': 10000, _limit: 3
         
     | 
| 
       39 
41 
     | 
    
         
             
            p NicoUtil::Live.search 'ゲーム'
         
     | 
| 
      
 42 
     | 
    
         
            +
            p NicoUtil::Blog.search '音楽'
         
     | 
| 
      
 43 
     | 
    
         
            +
            p NicoUtil::Book.search 'らき☆すた'
         
     | 
| 
      
 44 
     | 
    
         
            +
            p NicoUtil::Channel.search '歌ってみた'
         
     | 
| 
      
 45 
     | 
    
         
            +
            p NicoUtil::Comic.search 'ラブコメ'
         
     | 
| 
      
 46 
     | 
    
         
            +
            p NicoUtil::News.search 'アニメ'
         
     | 
| 
      
 47 
     | 
    
         
            +
            ```
         
     | 
| 
       40 
48 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
            ### Sign in
         
     | 
| 
      
 50 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       42 
51 
     | 
    
         
             
            # write your account of niconico
         
     | 
| 
       43 
52 
     | 
    
         
             
            email = 'niconico@example.com'
         
     | 
| 
       44 
53 
     | 
    
         
             
            pass = 'password'
         
     | 
| 
       45 
54 
     | 
    
         | 
| 
       46 
55 
     | 
    
         
             
            # login
         
     | 
| 
       47 
56 
     | 
    
         
             
            nico = NicoUtil::login email, pass
         
     | 
| 
      
 57 
     | 
    
         
            +
            ```
         
     | 
| 
       48 
58 
     | 
    
         | 
| 
      
 59 
     | 
    
         
            +
            ### Video
         
     | 
| 
      
 60 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       49 
61 
     | 
    
         
             
            # get comments of a video
         
     | 
| 
       50 
62 
     | 
    
         
             
            comments = nico.video('sm1097445').comments
         
     | 
| 
       51 
63 
     | 
    
         
             
            comments.each do |comment|
         
     | 
| 
       52 
64 
     | 
    
         
             
              p comment
         
     | 
| 
       53 
65 
     | 
    
         
             
            end
         
     | 
| 
      
 66 
     | 
    
         
            +
            ```
         
     | 
| 
       54 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
            ### Live
         
     | 
| 
      
 69 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       55 
70 
     | 
    
         
             
            # connect to a live and show data
         
     | 
| 
       56 
71 
     | 
    
         
             
            nico.live('lv242616226').connect do |status, data|
         
     | 
| 
       57 
72 
     | 
    
         
             
              case status
         
     | 
| 
         @@ -63,17 +78,20 @@ nico.live('lv242616226').connect do |status, data| 
     | 
|
| 
       63 
78 
     | 
    
         
             
                puts 'disconnect'
         
     | 
| 
       64 
79 
     | 
    
         
             
              end
         
     | 
| 
       65 
80 
     | 
    
         
             
            end
         
     | 
| 
      
 81 
     | 
    
         
            +
            ```
         
     | 
| 
       66 
82 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
            ### Illust
         
     | 
| 
      
 84 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 85 
     | 
    
         
            +
            # get an illust
         
     | 
| 
       68 
86 
     | 
    
         
             
            illust = nico.illust('im3768140')
         
     | 
| 
       69 
87 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
            # get comments of  
     | 
| 
      
 88 
     | 
    
         
            +
            # get comments of an illust
         
     | 
| 
       71 
89 
     | 
    
         
             
            p illust.comments
         
     | 
| 
       72 
90 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
            # get raw url of  
     | 
| 
      
 91 
     | 
    
         
            +
            # get raw url of an illust
         
     | 
| 
       74 
92 
     | 
    
         
             
            p illust.image_url
         
     | 
| 
       75 
93 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
            # download and save  
     | 
| 
      
 94 
     | 
    
         
            +
            # download and save an illust
         
     | 
| 
       77 
95 
     | 
    
         
             
            illust.save 'img.jpg'
         
     | 
| 
       78 
96 
     | 
    
         
             
            ```
         
     | 
| 
       79 
97 
     | 
    
         | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NicoUtil
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Niconico
         
     | 
| 
      
 3 
     | 
    
         
            +
                def blog blog_id
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Blog.new self, blog_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              class Blog
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize owner, blog_id
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @owner = owner
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @id = blog_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def url
         
     | 
| 
      
 15 
     | 
    
         
            +
                  return @url if @url
         
     | 
| 
      
 16 
     | 
    
         
            +
                  response = Net::HTTP.get_response(URI.parse("http://nico.ms/#{@id}"))
         
     | 
| 
      
 17 
     | 
    
         
            +
                  case response
         
     | 
| 
      
 18 
     | 
    
         
            +
                  when Net::HTTPRedirection
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @url = response['location']
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @url
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def self.search query, params={}
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #TODO: enable to search all blogs
         
     | 
| 
      
 26 
     | 
    
         
            +
                  Service.search 'channelarticle', query, params
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NicoUtil
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Niconico
         
     | 
| 
      
 3 
     | 
    
         
            +
                def book book_id
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Book.new self, book_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              class Book
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize owner, book_id
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @owner = owner
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @id = book_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def url
         
     | 
| 
      
 15 
     | 
    
         
            +
                  "http://seiga.nicovideo.jp/watch/#{@id}"
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.search query, params={}
         
     | 
| 
      
 19 
     | 
    
         
            +
                  Service.search 'book', query, params
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NicoUtil
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Niconico
         
     | 
| 
      
 3 
     | 
    
         
            +
                def channel channel_id
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Channel.new self, channel_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              class Channel
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize owner, channel_id
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @owner = owner
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @id = channel_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def url
         
     | 
| 
      
 15 
     | 
    
         
            +
                  "http://ch.nicovideo.jp/#{@id}"
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.search query, params={}
         
     | 
| 
      
 19 
     | 
    
         
            +
                  params[:_sort] = '-startTime' unless params.key? :_sort
         
     | 
| 
      
 20 
     | 
    
         
            +
                  Service.search 'channel', query, params
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NicoUtil
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Niconico
         
     | 
| 
      
 3 
     | 
    
         
            +
                def comic live_id
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Comic.new self, live_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              class Comic
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize owner, comic_id
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @owner = owner
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @id = comic_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def url
         
     | 
| 
      
 15 
     | 
    
         
            +
                  "http://seiga.nicovideo.jp/comic/#{@id}"
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.search query, params={}
         
     | 
| 
      
 19 
     | 
    
         
            +
                  Service.search 'manga', query, params
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NicoUtil
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Niconico
         
     | 
| 
      
 3 
     | 
    
         
            +
                def news news_id
         
     | 
| 
      
 4 
     | 
    
         
            +
                  News.new self, news_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              class News
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize owner, news_id
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @owner = owner
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @id = news_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def url
         
     | 
| 
      
 15 
     | 
    
         
            +
                  "http://news.nicovideo.jp/watch/#{@id}"
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.search query, params={}
         
     | 
| 
      
 19 
     | 
    
         
            +
                  params[:targets] = 'title,tags' unless params.key? :targets
         
     | 
| 
      
 20 
     | 
    
         
            +
                  Service.search 'news', query, params
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/nico_util/version.rb
    CHANGED
    
    
    
        data/lib/nico_util.rb
    CHANGED
    
    | 
         @@ -67,4 +67,9 @@ require_relative 'nico_util/service.rb' 
     | 
|
| 
       67 
67 
     | 
    
         
             
            require_relative 'nico_util/video.rb'
         
     | 
| 
       68 
68 
     | 
    
         
             
            require_relative 'nico_util/live.rb'
         
     | 
| 
       69 
69 
     | 
    
         
             
            require_relative 'nico_util/illust.rb'
         
     | 
| 
      
 70 
     | 
    
         
            +
            require_relative 'nico_util/comic.rb'
         
     | 
| 
      
 71 
     | 
    
         
            +
            require_relative 'nico_util/book.rb'
         
     | 
| 
      
 72 
     | 
    
         
            +
            require_relative 'nico_util/channel.rb'
         
     | 
| 
      
 73 
     | 
    
         
            +
            require_relative 'nico_util/blog.rb'
         
     | 
| 
      
 74 
     | 
    
         
            +
            require_relative 'nico_util/news.rb'
         
     | 
| 
       70 
75 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: nico_util
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tatsuya Tanaka (tattn)
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-11-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -63,14 +63,19 @@ files: 
     | 
|
| 
       63 
63 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       64 
64 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       65 
65 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       66 
     | 
    
         
            -
            - LICENSE 
     | 
| 
      
 66 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
       67 
67 
     | 
    
         
             
            - README.md
         
     | 
| 
       68 
68 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       69 
69 
     | 
    
         
             
            - bin/console
         
     | 
| 
       70 
70 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       71 
71 
     | 
    
         
             
            - lib/nico_util.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib/nico_util/blog.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/nico_util/book.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib/nico_util/channel.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/nico_util/comic.rb
         
     | 
| 
       72 
76 
     | 
    
         
             
            - lib/nico_util/illust.rb
         
     | 
| 
       73 
77 
     | 
    
         
             
            - lib/nico_util/live.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - lib/nico_util/news.rb
         
     | 
| 
       74 
79 
     | 
    
         
             
            - lib/nico_util/service.rb
         
     | 
| 
       75 
80 
     | 
    
         
             
            - lib/nico_util/version.rb
         
     | 
| 
       76 
81 
     | 
    
         
             
            - lib/nico_util/video.rb
         
     | 
    
        /data/{LICENSE.txt → LICENSE}
    RENAMED
    
    | 
         
            File without changes
         
     |