Sha256: 9423d49fdd13e634afffae9dad599fb871176850231e02722505e8685d0561bb

Contents?: true

Size: 823 Bytes

Versions: 94

Compression:

Stored size: 823 Bytes

Contents

module Onebox
  module Engine
    class YoukuOnebox
      include Engine
      include HTML

      matches_regexp(/^(https?:\/\/)?([\da-z\.-]+)(youku.com\/)(.)+\/?$/)

      # Try to get the video ID. Works for URLs of the form:
      # * http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html
      # * http://v.youku.com/v_show/id_XMTQ5MjgyMjMyOA==.html?from=y1.3-tech-index3-232-10183.89969-89963.3-1
      def video_id
        match = uri.path.match(/\/v_show\/id_([a-zA-Z0-9_=\-]+)(\.html)?.*/)
        match && match[1]
      rescue
        nil
      end

      def to_html
        "<embed width='570' height='360' src='https://players.youku.com/player.php/sid/#{video_id}/v.swf' type='application/x-shockwave-flash'></embed>"
      end

      private

      def uri
        @_uri ||= URI(@url)
      end

    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
onebox-1.8.89 lib/onebox/engine/youku_onebox.rb
onebox-1.8.88 lib/onebox/engine/youku_onebox.rb
onebox-1.8.87 lib/onebox/engine/youku_onebox.rb
onebox-1.8.86 lib/onebox/engine/youku_onebox.rb
onebox-1.8.85 lib/onebox/engine/youku_onebox.rb
onebox-1.8.84 lib/onebox/engine/youku_onebox.rb
onebox-1.8.83 lib/onebox/engine/youku_onebox.rb
onebox-1.8.82 lib/onebox/engine/youku_onebox.rb
onebox-1.8.81 lib/onebox/engine/youku_onebox.rb
onebox-1.8.80 lib/onebox/engine/youku_onebox.rb
onebox-1.8.79 lib/onebox/engine/youku_onebox.rb
onebox-1.8.78 lib/onebox/engine/youku_onebox.rb
onebox-1.8.77 lib/onebox/engine/youku_onebox.rb
onebox-1.8.76 lib/onebox/engine/youku_onebox.rb
onebox-1.8.75 lib/onebox/engine/youku_onebox.rb
onebox-1.8.74 lib/onebox/engine/youku_onebox.rb
onebox-1.8.73 lib/onebox/engine/youku_onebox.rb
onebox-1.8.72 lib/onebox/engine/youku_onebox.rb
onebox-1.8.71 lib/onebox/engine/youku_onebox.rb
onebox-1.8.70 lib/onebox/engine/youku_onebox.rb