Module: Nehm::PlaylistManager
- Defined in:
- lib/nehm/playlist_manager.rb
Overview
Playlist manager works with iTunes playlists
Class Method Summary collapse
- .default_playlist ⇒ Object
- .default_user_playlist ⇒ Object
-
.get_playlist(playlist_name) ⇒ Object
Checks path for existence and returns it if exists.
-
.music_master_library ⇒ Object
Music master library is main iTunes music library.
- .set_playlist ⇒ Object
Class Method Details
.default_playlist ⇒ Object
11 12 13 |
# File 'lib/nehm/playlist_manager.rb', line 11 def self.default_playlist default_user_playlist || music_master_library if OS.mac? end |
.default_user_playlist ⇒ Object
52 53 54 |
# File 'lib/nehm/playlist_manager.rb', line 52 def default_user_playlist Playlist.new(Cfg[:playlist]) unless Cfg[:playlist].nil? end |
.get_playlist(playlist_name) ⇒ Object
Checks path for existence and returns it if exists
18 19 20 21 22 23 24 |
# File 'lib/nehm/playlist_manager.rb', line 18 def self.get_playlist(playlist_name) if AppleScript.list_of_playlists.include? playlist_name Playlist.new(playlist_name) else UI.term 'Invalid playlist name. Please enter correct name' end end |
.music_master_library ⇒ Object
Music master library is main iTunes music library
59 60 61 |
# File 'lib/nehm/playlist_manager.rb', line 59 def music_master_library Playlist.new(AppleScript.music_master_library) end |
.set_playlist ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nehm/playlist_manager.rb', line 26 def self.set_playlist loop do playlist = UI.ask('Enter name of iTunes playlist to that you want ' \ 'add tracks (press Enter to set it to ' \ 'default iTunes Music library):') # If entered nothing, unset iTunes playlist if playlist == '' Cfg[:playlist] = nil UI.success 'Default iTunes playlist unset' break end if AppleScript.list_of_playlists.include? playlist Cfg[:playlist] = playlist UI.say "#{'Default iTunes playlist set up to'.green} #{playlist.magenta}" break else UI.error 'Invalid playlist name. Please enter correct name' end end end |