Sha256: 40e1c41283fb7d40f120f2ce561fa1722b542dfa68658f14bdc3569cfcbc0b7e

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'open-uri'
require 'multi_json'

module VideoInfo
  module Providers
    class Vimeo < Provider

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

      def provider
        'Vimeo'
      end

      def url
        video ? video['url'] : @url
      end

      %w[title description thumbnail_small thumbnail_medium thumbnail_large].each do |method|
        define_method(method) { video[method] }
      end

      %w[duration width height].each do |method|
        define_method(method) { video[method].to_i }
      end

      def keywords
        video['tags']
      end

      def embed_url
        "http://player.vimeo.com/video/#{video_id}"
      end

      def date
        Time.parse(video['upload_date'], Time.now.utc).utc
      end

      def view_count
        video['stats_number_of_plays'].to_i
      end

      def video
        @video && @video.first
      end

      private

      def _url_regex
        /.*\.com\/(?:(?:groups\/[^\/]+\/videos\/)|(?:video\/))?([0-9]+).*$/i
      end

      def _api_url
        "http://vimeo.com/api/v2/video/#{video_id}.json"
      end

      def _default_iframe_attributes
        {}
      end

      def _default_url_attributes
        { :title => 0,
          :byline => 0,
          :portrait => 0,
          :autoplay => 0 }
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
video_info-1.6.0 lib/video_info/providers/vimeo.rb