Sha256: 576f4f0f808d48ff0b4640553875013870da7cf70ff6c5412c119ec4f23323ff

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

class VideoInfo
  module Providers
    class YoutubePlaylist < Youtube

      alias_method :playlist_id, :video_id

      def self.usable?(url)
        url =~ /((youtube\.com)\/playlist)|((youtube\.com)\/embed\/videoseries)/
      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*)|youtube.com\/embed\/videoseries\?list=([a-zA-Z0-9-]*)/
      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.1 lib/video_info/providers/youtubeplaylist.rb