Search and download MP3 from YouTube
- Google API Key
- Ruby (and 'yt' gem)
- Youtube-dl (and ffmpeg or avconv)
Usage: ruby yt-to-mp3.rb name
Examples:
ruby yt-to-mp3.rb welcome to the jungle guns n roses
ruby yt-to-mp3.rb out of time a man mano negra
Search and download MP3 from YouTube
Usage: ruby yt-to-mp3.rb name
Examples:
ruby yt-to-mp3.rb welcome to the jungle guns n roses
ruby yt-to-mp3.rb out of time a man mano negra
require 'yt' | |
# Edit! | |
DEVELOPER_KEY = '' | |
Yt.configure do |config| | |
config.api_key = DEVELOPER_KEY | |
end | |
# Get videos | |
videos = Yt::Collections::Videos.new | |
# S&D: Search and Download | |
id = videos.where(q: ARGV.join(' '), order: 'relevance').first.id | |
system("youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=#{id}") |