Create a gist now

Instantly share code, notes, and snippets.

@katsuma /taifu
Created Dec 23, 2011

What would you like to do?
taifu will add youtube sound to your iTunes library silently
#!/usr/bin/env ruby
# usage:
# taifu
# taifu depends on and rb-appscript gem
require 'rubygems'
require 'appscript'
require 'fileutils'
include Appscript
VLC = "/Applications/"
youtube_url = ARGV.first ||
raise "no Youtube URL is given" unless youtube_url
youtube_url = youtube_url.split('&').first
wav = "#{DOWNLOAD}/taifu_#{"%Y%m%d%H%M%s")}.wav"
system "#{VLC} -I dummy #{youtube_url} --sout='#transcode{acodec=s16l,channels=2,samplerate=44100}:std{access=file,mux=wav,dst=#{wav}}' vlc://quit 2>/dev/null"
its = app ""
org_track = its.add(MacTypes::FileURL.path(File.expand_path("#{wav}")))
current_track = org_track.convert.first "TAIFU_NAME"
current_track.album.set "TAIFU_ALBUM"
current_track.artist.set "TAIFU_ARTIST"
FileUtils.rm_f wav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment