Sha256: acb27ead1a3ec533dc26e34b82bdf1120fa782ac6e35c389b0fdcc9287f081d8

Contents?: true

Size: 444 Bytes

Versions: 1

Compression:

Stored size: 444 Bytes

Contents

require "youtube_id/version"

module YoutubeID
  FORMATS = [
    %r(https?://youtu\.be/(.+?)\b),
    %r(https?://www\.youtube\.com/watch\?v=(.*?)(&|#|$)),
    %r(https?://www\.youtube\.com/embed/(.*?)(\?|$)),
    %r(https?://www\.youtube\.com/v/(.*?)(#|\?|$)),
    %r(https?://www\.youtube\.com/user/.*?#\w/\w/\w/\w/(.+)\b)
  ]

  def self.from(video_url)
    video_url.strip!
    FORMATS.find { |format| video_url =~ format } and $1
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
youtube_id-0.0.1 lib/youtube_id.rb