Sha256: 8ce47aac095d83f7dc4a0c4056f15ac4420396aeb52ec0bdf1caa8c356111d57

Contents?: true

Size: 441 Bytes

Versions: 2

Compression:

Stored size: 441 Bytes

Contents

require "youtube_id/version"

module YoutubeID
  FORMATS = [
    %r(https?://youtu\.be/(.+)),
    %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

2 entries across 2 versions & 1 rubygems

Version Path
youtube_id-0.0.3 lib/youtube_id.rb
youtube_id-0.0.2 lib/youtube_id.rb