Module: Ronnie::Client::Playlists
- Included in:
- Ronnie::Client
- Defined in:
- lib/ronnie/client/playlists.rb
Instance Method Summary collapse
-
#add_tracks_to_playlist(tracks, playlist_id, options = {}) ⇒ Object
Add Tracks to Playlist.
-
#create_playlist(name, description, tracks, options = {}) ⇒ Hashie::Mash
Create a Playlist.
-
#delete_playlist(playlist_id, options = {}) ⇒ Boolean
Delete a playlist.
-
#disable_collaboration(playlist_id) ⇒ Object
Disable Collaboration.
-
#enable_public_collaboration(playlist_id) ⇒ Object
Enable Public Collaboration.
-
#enable_restricted_collaboration(playlist_id) ⇒ Object
Enable Restricted Collaboration.
-
#playlist(playlist_id, options = {}) ⇒ Object
Retrieve Playlist.
-
#playlists(user_id = nil, options = {}) ⇒ Object
Retrieve Playlists.
-
#remove_tracks_from_playlist(tracks, index, count, playlist_id, options = {}) ⇒ Object
Remove Tracks from Playlist.
-
#search_playlists(query, options = {}) ⇒ Object
Search Playlists.
-
#top_playlists(options = {}) ⇒ Object
retrieve the site-wide most popular playlists.
-
#update_playlist(playlist_id, name, description, options = {}) ⇒ Object
Update Playlist.
Instance Method Details
#add_tracks_to_playlist(tracks, playlist_id, options = {}) ⇒ Object
Add Tracks to Playlist
64 65 66 67 68 69 |
# File 'lib/ronnie/client/playlists.rb', line 64 def add_tracks_to_playlist(tracks, playlist_id, ={}) post('addToPlaylist', { tracks: tracks.join(', '), playlist: playlist_id }) end |
#create_playlist(name, description, tracks, options = {}) ⇒ Hashie::Mash
Create a Playlist
Requires authorized client.
135 136 137 138 139 140 141 142 143 |
# File 'lib/ronnie/client/playlists.rb', line 135 def create_playlist(name, description, tracks, ={}) = { name: name, description: description, tracks: tracks.join(', ') } post('createPlaylist', .merge!()) end |
#delete_playlist(playlist_id, options = {}) ⇒ Boolean
Delete a playlist.
Requires authorized client.
154 155 156 |
# File 'lib/ronnie/client/playlists.rb', line 154 def delete_playlist(playlist_id, ={}) post('deletePlaylist', { playlist: playlist_id }) end |
#disable_collaboration(playlist_id) ⇒ Object
Disable Collaboration
115 116 117 |
# File 'lib/ronnie/client/playlists.rb', line 115 def disable_collaboration(playlist_id) post('setPlaylistCollaborationMode', { playlist: playlist_id, mode: 0 }) end |
#enable_public_collaboration(playlist_id) ⇒ Object
Enable Public Collaboration
95 96 97 |
# File 'lib/ronnie/client/playlists.rb', line 95 def enable_public_collaboration(playlist_id) post('setPlaylistCollaborationMode', { playlist: playlist_id, mode: 1 }) end |
#enable_restricted_collaboration(playlist_id) ⇒ Object
Enable Restricted Collaboration
105 106 107 |
# File 'lib/ronnie/client/playlists.rb', line 105 def enable_restricted_collaboration(playlist_id) post('setPlaylistCollaborationMode', { playlist: playlist_id, mode: 2 }) end |
#playlist(playlist_id, options = {}) ⇒ Object
Retrieve Playlist
35 36 37 |
# File 'lib/ronnie/client/playlists.rb', line 35 def playlist(playlist_id, ={}) post('get', { keys: playlist_id }) end |
#playlists(user_id = nil, options = {}) ⇒ Object
Retrieve Playlists
12 13 14 15 16 17 18 |
# File 'lib/ronnie/client/playlists.rb', line 12 def playlists(user_id=nil, ={}) if user_id post('getPlaylists', { user: user_id }) else post('getPlaylists') end end |
#remove_tracks_from_playlist(tracks, index, count, playlist_id, options = {}) ⇒ Object
Remove Tracks from Playlist
80 81 82 83 84 85 86 87 |
# File 'lib/ronnie/client/playlists.rb', line 80 def remove_tracks_from_playlist(tracks, index, count, playlist_id, ={}) post('removeFromPlaylist', { index: index, count: count, tracks: tracks.join(', '), playlist: playlist_id }) end |
#search_playlists(query, options = {}) ⇒ Object
Search Playlists
25 26 27 |
# File 'lib/ronnie/client/playlists.rb', line 25 def search_playlists(query, ={}) post('search', { query: query, types: 'Playlist' }) end |
#top_playlists(options = {}) ⇒ Object
retrieve the site-wide most popular playlists.
162 163 164 |
# File 'lib/ronnie/client/playlists.rb', line 162 def top_playlists(={}) post('getTopCharts', { type: "Playlist" }) end |
#update_playlist(playlist_id, name, description, options = {}) ⇒ Object
Update Playlist
47 48 49 50 51 52 53 54 55 |
# File 'lib/ronnie/client/playlists.rb', line 47 def update_playlist(playlist_id, name, description, ={}) = { playlist: playlist_id, name: name, description: description, } post('setPlaylistFields', .merge!()) end |