Class: Kanye::ITunes

Inherits:
Object
  • Object
show all
Includes:
Appscript
Defined in:
lib/kanye/itunes.rb

Instance Method Summary collapse

Instance Method Details

#add_to_playlist(file, playlist_name) ⇒ Object



7
8
9
10
11
12
# File 'lib/kanye/itunes.rb', line 7

def add_to_playlist(file, playlist_name)
  list = playlist(playlist_name) || create_playlist(playlist_name)
  raise "Playlist could not be found or created" unless list
  track = itunes.add MacTypes::Alias.path(file)
  track.duplicate(:to => list) if track
end

#create_playlist(name) ⇒ Object



18
19
20
# File 'lib/kanye/itunes.rb', line 18

def create_playlist(name)
  itunes.make(:new => :user_playlist, :with_properties => {:name => name})
end

#playlist(name) ⇒ Object



14
15
16
# File 'lib/kanye/itunes.rb', line 14

def playlist(name)
  itunes.user_playlists[its.name.eq(name)].get.first
end