Sha256: 47c6859cbe2600df019f42ccca6f6ef920065e42573987e9337d56ded9411256

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

require "nicoquery/api/mylist_rss"
require "nicoquery/object_mapper/mylist_rss"
require "nicoquery/object/movie"


module NicoQuery
  module Object
    class Mylist
      attr_accessor :movies

      [
        'title',
        'mylist_id',
        'url',
        'link',
        'description',
        'publish_date',
        'last_build_date',
        'creator',
      ].each do |field_name|
        define_method(field_name) { @hash.meta.send field_name }
      end

      def initialize(mylist_id)
        @movies = []
        @mylist_id = mylist_id
        @source = NicoQuery::Api::MylistRSS.new mylist_id
        @hash = NicoQuery::ObjectMapper::MylistRSS.new @source.get

        return if @hash.items.nil?
        @hash.items.map do |item|
          movie = NicoQuery::Object::Movie.new item.video_id.presence || item.thread_id
          movie.set_mylist_rss_source item
          @movies.push movie
        end
      end

      def available?
        [!forbidden?].all?
      end

      def forbidden?
        @source.forbidden
      end
    end
  end
end


# <title>マイリスト to_test‐ニコニコ動画</title>
# <link>http://www.nicovideo.jp/mylist/38369702</link>
# <atom:link rel="self" type="application/rss+xml" href="http://www.nicovideo.jp/mylist/38369702?rss=2.0"/>
# <description></description>
# <pubDate>Sat, 17 Aug 2013 22:51:40 +0900</pubDate>
# <lastBuildDate>Sat, 17 Aug 2013 22:51:40 +0900</lastBuildDate>
# <generator>ニコニコ動画</generator>
# <dc:creator>うえおに</dc:creator>
# <language>ja-jp</language>
# <copyright>(c) niwango, inc. All rights reserved.</copyright>
# <docs>http://blogs.law.harvard.edu/tech/rss</docs>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nicoquery-0.1.6.1 lib/nicoquery/object/mylist.rb
nicoquery-0.1.6 lib/nicoquery/object/mylist.rb