Skip to content

Instantly share code, notes, and snippets.

@eduardinni
eduardinni / youtubeID.rb
Last active July 31, 2022 12:39 — forked from takien/youtubeID.js
Get YouTube ID from various YouTube URL using Ruby
# Get YouTube ID from various YouTube URL
# Ruby port from JavaScript version: https://gist.github.com/takien/4077195/
def get_youtube_id(url)
id = ''
url = url.gsub(/(>|<)/i,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/)
if url[2] != nil
id = url[2].split(/[^0-9a-z_\-]/i)
id = id[0];
else