Sha256: 0f539f9f3cbc9b356694270c330f194a3be0a844198bcb23f24a20b4462624e8

Contents?: true

Size: 888 Bytes

Versions: 21

Compression:

Stored size: 888 Bytes

Contents

module Onebox
  module Engine
    class SoundCloudOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https?:\/\/.*soundcloud\.com/)
      always_https

      def to_html
        oembed_data = get_oembed_data[:html]
        oembed_data.gsub!('visual=true', 'visual=false') || oembed_data
      end

      def placeholder_html
        "<img src='#{get_oembed_data[:thumbnail_url]}'>"
      end

      private

      def set?
        url =~ /\/sets\//
      end

      def get_oembed_data
        if set?
          Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("https://soundcloud.com/oembed.json?url=#{url}").body))
        else
          Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("https://soundcloud.com/oembed.json?url=#{url}&maxheight=166").body))
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
onebox-1.5.50 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.49 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.48 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.47 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.45 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.44 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.43 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.42 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.41 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.40 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.39 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.38 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.37 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.36 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.35 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.34 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.33 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.32 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.31 lib/onebox/engine/soundcloud_onebox.rb
onebox-1.5.30 lib/onebox/engine/soundcloud_onebox.rb