Module: Ronnie::Client::Playlists

Included in:
Ronnie::Client
Defined in:
lib/ronnie/client/playlists.rb

Instance Method Summary collapse

Instance Method Details

#add_tracks_to_playlist(tracks, playlist_id, options = {}) ⇒ Object

Add Tracks to Playlist

Examples:

Ronnie.add_tracks_to_playlist(['t15940486'], 'p1429320')

Parameters:

  • tracks (Array)
  • playlist_id (String)

See Also:



64
65
66
67
68
69
# File 'lib/ronnie/client/playlists.rb', line 64

def add_tracks_to_playlist(tracks, playlist_id, options={})
  post('addToPlaylist', {
    tracks:   tracks.join(', '),
    playlist: playlist_id
  })
end

#create_playlist(name, description, tracks, options = {}) ⇒ Hashie::Mash

Create a Playlist

Requires authorized client.

Examples:

Ronnie.create_playlist(
  'Your Ecclesiastical Adolescence',
  'Music performed by Winona Ryder as Lelaina Pierce.',
  't20680151'
)

Parameters:

  • name (String)

    playlist name.

  • description (String)

    playlist description.

  • tracks (Array)

    playlist contents.

Returns:

  • (Hashie::Mash)

See Also:



135
136
137
138
139
140
141
142
143
# File 'lib/ronnie/client/playlists.rb', line 135

def create_playlist(name, description, tracks, options={})
  required_options = {
    name: name,
    description: description,
    tracks: tracks.join(', ')
  }

  post('createPlaylist', required_options.merge!(options))
end

#delete_playlist(playlist_id, options = {}) ⇒ Boolean

Delete a playlist.

Requires authorized client.

Examples:

Ronnie.delete_playlist('p87188')

Parameters:

  • playlist_id (String)

Returns:

  • (Boolean)

See Also:



154
155
156
# File 'lib/ronnie/client/playlists.rb', line 154

def delete_playlist(playlist_id, options={})
  post('deletePlaylist', { playlist: playlist_id })
end

#disable_collaboration(playlist_id) ⇒ Object

Disable Collaboration

Examples:

Ronnie.disable_collaboration('p1429320')

Parameters:

  • playlist_id (String)

See Also:



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

Examples:

Ronnie.enable_public_collaboration('p1429320')

Parameters:

  • playlist_id (String)

See Also:



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

Examples:

Ronnie.enable_restricted_collaboration('p1429320')

Parameters:

  • playlist_id (String)

See Also:



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

Examples:

Ronnie.playlist('p87188')

Parameters:

  • playlist_id (String)

See Also:



35
36
37
# File 'lib/ronnie/client/playlists.rb', line 35

def playlist(playlist_id, options={})
  post('get', { keys: playlist_id })
end

#playlists(user_id = nil, options = {}) ⇒ Object

Retrieve Playlists

Examples:

Ronnie.playlists('s112675')
@client.playlist

Parameters:

  • playlist_id (String)

See Also:



12
13
14
15
16
17
18
# File 'lib/ronnie/client/playlists.rb', line 12

def playlists(user_id=nil, options={})
  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

Examples:

Ronnie.remove_tracks_from_playlist(['t15940486'], 'p1429320')

Parameters:

  • tracks (Array)
  • index (Integer)
  • count (Integer)
  • playlist_id (String)

See Also:



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, options={})
  post('removeFromPlaylist', {
    index: index,
    count: count,
    tracks: tracks.join(', '),
    playlist: playlist_id
  })
end

#search_playlists(query, options = {}) ⇒ Object

Search Playlists

Examples:

Ronnie.search_playlists('Allen Goodman')

Parameters:

  • query (String)


25
26
27
# File 'lib/ronnie/client/playlists.rb', line 25

def search_playlists(query, options={})
  post('search', { query: query, types: 'Playlist' })
end

#top_playlists(options = {}) ⇒ Object

retrieve the site-wide most popular playlists.

Examples:

Ronnie.top_playlists


162
163
164
# File 'lib/ronnie/client/playlists.rb', line 162

def top_playlists(options={})
  post('getTopCharts', { type: "Playlist" })
end

#update_playlist(playlist_id, name, description, options = {}) ⇒ Object

Update Playlist

Examples:

Ronnie.update_playlist('p87188', 'updated name', 'updated description')

Parameters:

  • playlist_id (String)
  • name (String)
  • description (String)

See Also:



47
48
49
50
51
52
53
54
55
# File 'lib/ronnie/client/playlists.rb', line 47

def update_playlist(playlist_id, name, description, options={})
  required_options = {
    playlist: playlist_id,
    name: name,
    description: description,
  }

  post('setPlaylistFields', required_options.merge!(options))
end