Sha256: 96a0486bbd8693f4c4ce2b0dd67087271d0f5f115f7eec093825643cb767a2ce
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require 'mime/types' require 'brightcove-api' module AssetHostCore module Loaders class Brightcove < Base SOURCE = "Brightcove" # Since brightcove videos don't have canoncial URL's, # we have to make-up a way to import them def self.build_from_url(url) return nil if AssetHostCore.config.brightcove_api_key.blank? url.match(/brightcove:(?<id>\d+)/) do |m| self.new(url: nil, id: m[:id]) end end #---------- # Brightcove videos don't have URL's def load brightcove = ::Brightcove::API.new(AssetHostCore.config.brightcove_api_key) # get our video info response = brightcove.get("find_video_by_id", { video_id: @id }).parsed_response native = AssetHostCore::BrightcoveVideo.create( :videoid => response['id'], :length => response['length'] ) asset = AssetHostCore::Asset.new( :title => response["name"], :caption => response["shortDescription"], :owner => "KPCC", :image_taken => DateTime.strptime(response["publishedDate"],"%Q"), :url => nil, :notes => "Imported from Brightcove: #{@id}", :image => image_file(response['videoStillURL']), :native => native ) asset.save! asset end #---------- private def image_file(url) @image_file ||= begin response = open(url) tempfile = Tempfile.new('ah-brightcove', encoding: "ascii-8bit") tempfile.write response.read tempfile end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asset_host_core-2.0.0.beta | lib/asset_host_core/loaders/brightcove.rb |