Sha256: 3f75642260e6aa41285f84af69e9567e78f50ef58800c4bf1cf9f2e5f4317c8b

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

class VideoInfo
  module Providers
    class YoutubePlaylist < Youtube

      alias_method :playlist_id, :video_id

      def self.usable?(url)
        url =~ /(youtube\.com)\/playlist/
      end

      def videos
        _playlist_video_ids.map do |entry_id|
          VideoInfo.new("http://www.youtube.com/watch?v=#{entry_id}")
        end
      end

      def embed_url
        "www.youtube.com/embed/videoseries?list=#{playlist_id}"
      end

      def description
        _playlist_entry['subtitle']['$t']
      end

      %w[date keywords duration view_count].each do |method|
        define_method(method) { nil }
      end

      private

      def _playlist_entry
        data['feed']
      end

      def _video_entry
        _playlist_entry
      end

      def _url_regex
        /youtube.com\/playlist\?p=(\S*)/
      end

      def _api_path
        "/feeds/api/playlists/#{playlist_id}?v=2&alt=json"
      end

      def _playlist_video_ids
        _playlist_entry['entry'].map do |entry|
          entry['media$group']['yt$videoid']['$t']
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
video_info-2.2.0 lib/video_info/providers/youtubeplaylist.rb