ronnie 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +163 -0
- data/Rakefile +23 -0
- data/lib/faraday/response/raise_dio_error.rb +46 -0
- data/lib/ronnie/authentication.rb +33 -0
- data/lib/ronnie/client/albums.rb +50 -0
- data/lib/ronnie/client/artists.rb +23 -0
- data/lib/ronnie/client/collections/albums.rb +9 -0
- data/lib/ronnie/client/collections/artists.rb +9 -0
- data/lib/ronnie/client/collections.rb +85 -0
- data/lib/ronnie/client/playlists.rb +159 -0
- data/lib/ronnie/client/tracks.rb +32 -0
- data/lib/ronnie/client/users.rb +93 -0
- data/lib/ronnie/client.rb +39 -0
- data/lib/ronnie/configuration.rb +71 -0
- data/lib/ronnie/connection.rb +24 -0
- data/lib/ronnie/error.rb +34 -0
- data/lib/ronnie/request.rb +17 -0
- data/lib/ronnie/version.rb +3 -0
- data/lib/ronnie.rb +27 -0
- data/ronnie.gemspec +35 -0
- data/spec/faraday/response_spec.rb +0 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_playlists_to_collection/Add_Playlists_to_Collection/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_track_to_playlist/Add_Track_to_Playlist/.yml +61 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_tracks_to_collection/Add_Tracks_to_Collection/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_tracks_to_playlist/Add_Tracks_to_Playlist/.yml +61 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_album/Retrieve_Album/.yml +64 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_create_playlist/Create_a_Playlist/.yml +61 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_delete_playlist/Delete_a_Playlist/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_disable_collaboration/Disable_Collaboration/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_enable_public_collaboration/Enable_Public_Collaboration/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_enable_restricted_collaboration/Enable_Restricted_Collaboration/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_albums_by_artist/Find_Albums_by_Artist/.yml +260 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_albums_by_label/Find_Albums_by_Label/.yml +245 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_albums_by_upc/Find_Albums_by_UPC/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_artists_by_label/Find_Artists_by_Label/.yml +96 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_tracks_by_artist/Find_Tracks_by_Artist/.yml +156 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_tracks_by_isrc/Find_Tracks_by_ISRC/.yml +145 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_user/Find_User_by_E-mail_Address/.yml +58 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_follow/Follow_a_User/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_followers/Retrieve_Followers_of_Authorized_User/.yml +144 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_followers/Retrieve_Followers_of_a_User/.yml +58 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_following/Retrieve_Users_Following_Another_User/.yml +69 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_following/Retrieve_Users_Following_Authorized_User/.yml +144 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_follows_/Authorized_User_is_Following_a_User/.yml +144 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlist/Retrieve_Playlist/.yml +61 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlists/Retrieve_Playlists_by_Authorized_User/.yml +282 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlists/Retrieve_Playlists_by_User/.yml +67 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlists/Retrieve_Playlists_by_a_User/.yml +67 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_remove_playlists_from_collection/Remove_Playlists_from_Collection/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_remove_tracks_from_collection/Remove_Tracks_from_Collection/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_remove_tracks_from_playlist/Remove_Tracks_from_Playlist/.yml +61 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_albums/Search_Albums/.yml +95 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_artists/Search_Artists/.yml +66 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_playlists/Search_Playlists/.yml +110 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_tracks/Search_Tracks/.yml +65 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_users/Search_Users/.yml +64 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_sync_playlists/Sync_Playlists/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_sync_tracks/Sync_Tracks/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_unfollow/Unfollow_a_User/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_unsync_playlists/Unsync_Playlists/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_unsync_tracks/Unsync_Tracks/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_update_playlist/Update_Playlist/.yml +55 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_user/Retrieve_Authorized_User/.yml +58 -0
- data/spec/fixtures/cassettes/Ronnie_Client_Users/_user/Retrieve_User/.yml +58 -0
- data/spec/ronnie/client/albums_spec.rb +52 -0
- data/spec/ronnie/client/artists_spec.rb +28 -0
- data/spec/ronnie/client/collections_spec.rb +76 -0
- data/spec/ronnie/client/playlists_spec.rb +120 -0
- data/spec/ronnie/client/tracks_spec.rb +38 -0
- data/spec/ronnie/client/users_spec.rb +94 -0
- data/spec/ronnie/client_spec.rb +23 -0
- data/spec/ronnie_spec.rb +20 -0
- data/spec/spec_helper.rb +19 -0
- metadata +401 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Allen Goodman
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# ronnie [](http://travis-ci.org/2a6U37Nn/ronnie) [](https://codeclimate.com/github/2a6U37Nn/ronnie)
|
|
2
|
+
|
|
3
|
+
Library for accessing the Rdio API from Ruby. Chirp, chirp!
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
gem 'ronnie', '~> 7.6.0'
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
require 'ronnie'
|
|
12
|
+
|
|
13
|
+
### OAuth
|
|
14
|
+
|
|
15
|
+
**Note**—the following constants are examples. You’ll need to [register your application](http://developer.rdio.com) with Rdio to retrieve a unique `CONSUMER_KEY` and `CONSUMER_SECRET`. If you’d like to request authorized resources, you’ll need to create a `OAUTH_TOKEN` and `OAUTH_TOKEN_SECRET`.
|
|
16
|
+
|
|
17
|
+
#### Authentication
|
|
18
|
+
|
|
19
|
+
CONSUMER_KEY = 'q32tvp74n5hazpbr93tbjkem'
|
|
20
|
+
CONSUMER_SECRET = 'nXcryfbVDP'
|
|
21
|
+
|
|
22
|
+
client = Ronnie::Client.new consumer_key: CONSUMER_KEY,
|
|
23
|
+
consumer_secret: CONSUMER_SECRET
|
|
24
|
+
|
|
25
|
+
#### Authorization
|
|
26
|
+
|
|
27
|
+
OAUTH_TOKEN = 'zd565qbzvwadxtd4fr3bpcda3ym42shwcxsbyu4t49gv6xxjhp7tjvre4xwr8gue'
|
|
28
|
+
OAUTH_TOKEN_SECRET = 'baA2KgCSAW3D'
|
|
29
|
+
|
|
30
|
+
client.token = OAUTH_TOKEN
|
|
31
|
+
client.token_secret = OAUTH_TOKEN_SECRET
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
### Albums
|
|
36
|
+
|
|
37
|
+
#### Retrieve Album
|
|
38
|
+
|
|
39
|
+
client.album('a610550')
|
|
40
|
+
|
|
41
|
+
#### Find Albums by Artist
|
|
42
|
+
|
|
43
|
+
client.find_albums_by_artist('r235282')
|
|
44
|
+
|
|
45
|
+
#### Find Albums by Label
|
|
46
|
+
|
|
47
|
+
client.find_albums_by_label('')
|
|
48
|
+
|
|
49
|
+
#### Find Albums by UPC
|
|
50
|
+
|
|
51
|
+
client.find_albums_by_upc('652637001228')
|
|
52
|
+
|
|
53
|
+
#### Search Albums
|
|
54
|
+
|
|
55
|
+
client.search_albums('Clear Moon')
|
|
56
|
+
|
|
57
|
+
### Artists
|
|
58
|
+
|
|
59
|
+
#### Find Artists by Label
|
|
60
|
+
|
|
61
|
+
client.find_artists_by_label('l2270')
|
|
62
|
+
|
|
63
|
+
#### Search Artists
|
|
64
|
+
|
|
65
|
+
client.search_artists('Mount Eerie')
|
|
66
|
+
|
|
67
|
+
### Playlists
|
|
68
|
+
|
|
69
|
+
#### Retrieve Playlists by User
|
|
70
|
+
|
|
71
|
+
client.playlists('s112675')
|
|
72
|
+
|
|
73
|
+
#### Retrieve Playlists by Authorized User
|
|
74
|
+
|
|
75
|
+
client.playlists
|
|
76
|
+
|
|
77
|
+
#### Search Playlists
|
|
78
|
+
|
|
79
|
+
client.search_playlists('AirR&B&B')
|
|
80
|
+
|
|
81
|
+
#### Retrieve Playlist
|
|
82
|
+
|
|
83
|
+
client.playlist('p87188')
|
|
84
|
+
|
|
85
|
+
#### Create a Playlist
|
|
86
|
+
|
|
87
|
+
client.create_playlist(
|
|
88
|
+
'Your Ecclesiastical Adolescence',
|
|
89
|
+
'Music performed by Winona Ryder as Lelaina Pierce.',
|
|
90
|
+
['t20680151', 't20680150']
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
##### Required Arguments
|
|
94
|
+
|
|
95
|
+
* **Name** (String): playlist name.
|
|
96
|
+
* **Description** (String): playlist description.
|
|
97
|
+
* **Tracks** (Array): playlist contents.
|
|
98
|
+
|
|
99
|
+
#### Delete a Playlist
|
|
100
|
+
|
|
101
|
+
client.delete_playlist('p87188')
|
|
102
|
+
|
|
103
|
+
### Tracks
|
|
104
|
+
|
|
105
|
+
#### Find Tracks by Artist
|
|
106
|
+
|
|
107
|
+
client.find_tracks_by_artist('r235282')
|
|
108
|
+
|
|
109
|
+
#### Find Tracks by ISRC
|
|
110
|
+
|
|
111
|
+
client.find_tracks_by_isrc('GBAYE0200771')
|
|
112
|
+
|
|
113
|
+
#### Search Tracks
|
|
114
|
+
|
|
115
|
+
client.search_tracks('Through The Trees pt. 2')
|
|
116
|
+
|
|
117
|
+
### Users
|
|
118
|
+
|
|
119
|
+
#### Retrieve User
|
|
120
|
+
|
|
121
|
+
client.user('s112675')
|
|
122
|
+
|
|
123
|
+
#### Retrieve Authorized User
|
|
124
|
+
|
|
125
|
+
client.user
|
|
126
|
+
|
|
127
|
+
#### Find User by E-mail Address
|
|
128
|
+
|
|
129
|
+
client.find_user('allen.goodman@me.com')
|
|
130
|
+
|
|
131
|
+
#### Search Users
|
|
132
|
+
|
|
133
|
+
client.search_users('Allen Goodman')
|
|
134
|
+
|
|
135
|
+
#### Retrieve Followers of a User
|
|
136
|
+
|
|
137
|
+
client.followers('s112675')
|
|
138
|
+
|
|
139
|
+
#### Retrieve Followers of Authorized User
|
|
140
|
+
|
|
141
|
+
client.followers
|
|
142
|
+
|
|
143
|
+
#### Retrieve Users Following Another User
|
|
144
|
+
|
|
145
|
+
client.following('s112675')
|
|
146
|
+
|
|
147
|
+
#### Retrieve Users Following Authorized User
|
|
148
|
+
|
|
149
|
+
client.following
|
|
150
|
+
|
|
151
|
+
#### Follow a User
|
|
152
|
+
|
|
153
|
+
client.follow('s112675')
|
|
154
|
+
|
|
155
|
+
#### Unfollow a User
|
|
156
|
+
|
|
157
|
+
client.unfollow('s112675')
|
|
158
|
+
|
|
159
|
+
## Tests
|
|
160
|
+
|
|
161
|
+
$ bundle install
|
|
162
|
+
|
|
163
|
+
$ bundle exec foreman run rspec
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
require 'bundler/gem_tasks'
|
|
3
|
+
|
|
4
|
+
Bundler::GemHelper.install_tasks
|
|
5
|
+
|
|
6
|
+
require 'rspec/core/rake_task'
|
|
7
|
+
|
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
9
|
+
|
|
10
|
+
task test: :spec
|
|
11
|
+
task default: :spec
|
|
12
|
+
|
|
13
|
+
namespace :doc do
|
|
14
|
+
require 'yard'
|
|
15
|
+
|
|
16
|
+
YARD::Rake::YardocTask.new do |task|
|
|
17
|
+
task.files = ['README.md', 'LICENSE', 'lib/**/*.rb']
|
|
18
|
+
task.options = [
|
|
19
|
+
'--output-dir', 'doc/yard',
|
|
20
|
+
'--markup', 'markdown',
|
|
21
|
+
]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'faraday'
|
|
2
|
+
require 'multi_json'
|
|
3
|
+
|
|
4
|
+
# @api private
|
|
5
|
+
module Faraday
|
|
6
|
+
class Response::RaiseDioError < Response::Middleware
|
|
7
|
+
def on_complete(response)
|
|
8
|
+
case response[:status].to_i
|
|
9
|
+
when 400
|
|
10
|
+
raise Ronnie::BadRequest, error_message(response)
|
|
11
|
+
when 401
|
|
12
|
+
raise Ronnie::Unauthorized, error_message(response)
|
|
13
|
+
when 403
|
|
14
|
+
raise Ronnie::Forbidden, error_message(response)
|
|
15
|
+
when 404
|
|
16
|
+
raise Ronnie::NotFound, error_message(response)
|
|
17
|
+
when 406
|
|
18
|
+
raise Ronnie::NotAcceptable, error_message(response)
|
|
19
|
+
when 422
|
|
20
|
+
raise Ronnie::UnprocessableEntity, error_message(response)
|
|
21
|
+
when 500
|
|
22
|
+
raise Ronnie::InternalServerError, error_message(response)
|
|
23
|
+
when 501
|
|
24
|
+
raise Ronnie::NotImplemented, error_message(response)
|
|
25
|
+
when 502
|
|
26
|
+
raise Ronnie::BadGateway, error_message(response)
|
|
27
|
+
when 503
|
|
28
|
+
raise Ronnie::ServiceUnavailable, error_message(response)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def error_message(response)
|
|
33
|
+
message = if (body = response[:body]) && !body.empty?
|
|
34
|
+
if body.is_a?(String)
|
|
35
|
+
body = MultiJson.load(body, :symbolize_keys => true)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
": #{body[:error] || body[:message] || ''}"
|
|
39
|
+
else
|
|
40
|
+
''
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]}#{message}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Ronnie
|
|
2
|
+
module Authentication
|
|
3
|
+
def authenticate
|
|
4
|
+
credentials = {}
|
|
5
|
+
|
|
6
|
+
if consumer_key && consumer_secret
|
|
7
|
+
credentials[:consumer_key] = consumer_key
|
|
8
|
+
credentials[:consumer_secret] = consumer_secret
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
credentials
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def authorize
|
|
15
|
+
credentials = {}
|
|
16
|
+
|
|
17
|
+
if token && token_secret
|
|
18
|
+
credentials[:token] = token
|
|
19
|
+
credentials[:token_secret] = token_secret
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
authenticate.merge! credentials
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def authenticated?
|
|
26
|
+
!authenticate.empty?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def authorized?
|
|
30
|
+
!token.nil?
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Ronnie
|
|
2
|
+
class Client
|
|
3
|
+
module Albums
|
|
4
|
+
# Retrieve Album
|
|
5
|
+
#
|
|
6
|
+
# @param album_id [String]
|
|
7
|
+
# @example
|
|
8
|
+
# Ronnie.album('a610550')
|
|
9
|
+
def album(album_id, options={})
|
|
10
|
+
post('get', { keys: album_id })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Find Albums by Artist
|
|
14
|
+
#
|
|
15
|
+
# @param artist_id [String]
|
|
16
|
+
# @example
|
|
17
|
+
# Ronnie.find_albums_by_artist('r235282')
|
|
18
|
+
def find_albums_by_artist(artist_id, options={})
|
|
19
|
+
post('getAlbumsForArtist', { artist: artist_id })
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Find Albums by Label
|
|
23
|
+
#
|
|
24
|
+
# @param label_id [String]
|
|
25
|
+
# @example
|
|
26
|
+
# Ronnie.find_albums_by_upc('r235282')
|
|
27
|
+
def find_albums_by_label(label_id, options={})
|
|
28
|
+
post('getAlbumsForLabel', { label: label_id })
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Find Albums by UPC
|
|
32
|
+
#
|
|
33
|
+
# @param upc [String]
|
|
34
|
+
# @example
|
|
35
|
+
# Ronnie.find_albums_by_upc('r235282')
|
|
36
|
+
def find_albums_by_upc(upc, options={})
|
|
37
|
+
post('getAlbumsByUPC', { upc: upc })
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Search Albums
|
|
41
|
+
#
|
|
42
|
+
# @param query [String]
|
|
43
|
+
# @example
|
|
44
|
+
# Ronnie.search_albums('Clear Moon')
|
|
45
|
+
def search_albums(query, options={})
|
|
46
|
+
post('search', { query: query, types: 'Album' })
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Ronnie
|
|
2
|
+
class Client
|
|
3
|
+
module Artists
|
|
4
|
+
# Find Artists by Label
|
|
5
|
+
#
|
|
6
|
+
# @param label_id [String]
|
|
7
|
+
# @example
|
|
8
|
+
# Ronnie.find_artists_by_label('l2270')
|
|
9
|
+
def find_artists_by_label(label_id, options={})
|
|
10
|
+
post('getArtistsForLabel', { label: label_id })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Search Artists
|
|
14
|
+
#
|
|
15
|
+
# @param query [String]
|
|
16
|
+
# @example
|
|
17
|
+
# Ronnie.search_artists('Mount Eerie')
|
|
18
|
+
def search_artists(query, options={})
|
|
19
|
+
post('search', { query: query, types: 'Artist' })
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Ronnie
|
|
2
|
+
class Client
|
|
3
|
+
module Collections
|
|
4
|
+
# Add Playlists to Collection
|
|
5
|
+
#
|
|
6
|
+
# @param playlists [Array]
|
|
7
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#addToCollection
|
|
8
|
+
# @example
|
|
9
|
+
# Ronnie.add_playlists_to_collection(['p1429320'])
|
|
10
|
+
def add_playlists_to_collection(playlists, options={})
|
|
11
|
+
post('addToCollection', { keys: playlists.join(', ') })
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Add Tracks to Collection
|
|
15
|
+
#
|
|
16
|
+
# @param tracks [Array]
|
|
17
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#addToCollection
|
|
18
|
+
# @example
|
|
19
|
+
# Ronnie.add_tracks_to_collection(['t15940486'])
|
|
20
|
+
def add_tracks_to_collection(tracks, options={})
|
|
21
|
+
post('addToCollection', { keys: tracks.join(', ') })
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Remove Playlists from Collection
|
|
25
|
+
#
|
|
26
|
+
# @param playlists [Array]
|
|
27
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#removeFromCollection
|
|
28
|
+
# @example
|
|
29
|
+
# Ronnie.remove_playlists_from_collection(['p1429320'])
|
|
30
|
+
def remove_playlists_from_collection(playlists, options={})
|
|
31
|
+
post('removeFromCollection', { keys: playlists.join(', ') })
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Remove Tracks from Collection
|
|
35
|
+
#
|
|
36
|
+
# @param tracks [Array]
|
|
37
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#removeFromCollection
|
|
38
|
+
# @example
|
|
39
|
+
# Ronnie.remove_tracks_from_collection(['t15940486'])
|
|
40
|
+
def remove_tracks_from_collection(tracks, options={})
|
|
41
|
+
post('removeFromCollection', { keys: tracks.join(', ') })
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Sync Playlists
|
|
45
|
+
#
|
|
46
|
+
# @param playlists [Array]
|
|
47
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setAvailableOffline
|
|
48
|
+
# @example
|
|
49
|
+
# Ronnie.sync_playlists(['p1429320'])
|
|
50
|
+
def sync_playlists(playlists)
|
|
51
|
+
post('setAvailableOffline', { keys: playlists.join(', '), offline: true })
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Sync Tracks
|
|
55
|
+
#
|
|
56
|
+
# @param tracks [Array]
|
|
57
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setAvailableOffline
|
|
58
|
+
# @example
|
|
59
|
+
# Ronnie.sync_tracks(['t15940486'])
|
|
60
|
+
def sync_tracks(tracks)
|
|
61
|
+
post('setAvailableOffline', { keys: tracks.join(', '), offline: true })
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Unsync Playlists
|
|
65
|
+
#
|
|
66
|
+
# @param playlists [Array]
|
|
67
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setAvailableOffline
|
|
68
|
+
# @example
|
|
69
|
+
# Ronnie.unsync_playlists(['p1429320'])
|
|
70
|
+
def unsync_playlists(playlists)
|
|
71
|
+
post('setAvailableOffline', { keys: playlists.join(', '), offline: false })
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Unsync Tracks
|
|
75
|
+
#
|
|
76
|
+
# @param tracks [Array]
|
|
77
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setAvailableOffline
|
|
78
|
+
# @example
|
|
79
|
+
# Ronnie.unsync_tracks(['t15940486'])
|
|
80
|
+
def unsync_tracks(tracks)
|
|
81
|
+
post('setAvailableOffline', { keys: tracks.join(', '), offline: false })
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
module Ronnie
|
|
2
|
+
class Client
|
|
3
|
+
module Playlists
|
|
4
|
+
# Retrieve Playlists
|
|
5
|
+
#
|
|
6
|
+
# @param playlist_id [String]
|
|
7
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#getPlaylists
|
|
8
|
+
# @example
|
|
9
|
+
# Ronnie.playlists('s112675')
|
|
10
|
+
# @example
|
|
11
|
+
# @client.playlist
|
|
12
|
+
def playlists(user_id=nil, options={})
|
|
13
|
+
if user_id
|
|
14
|
+
post('getPlaylists', { user: user_id })
|
|
15
|
+
else
|
|
16
|
+
post('getPlaylists')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Search Playlists
|
|
21
|
+
#
|
|
22
|
+
# @param query [String]
|
|
23
|
+
# @example
|
|
24
|
+
# Ronnie.search_playlists('Allen Goodman')
|
|
25
|
+
def search_playlists(query, options={})
|
|
26
|
+
post('search', { query: query, types: 'Playlist' })
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Retrieve Playlist
|
|
30
|
+
#
|
|
31
|
+
# @param playlist_id [String]
|
|
32
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#get
|
|
33
|
+
# @example
|
|
34
|
+
# Ronnie.playlist('p87188')
|
|
35
|
+
def playlist(playlist_id, options={})
|
|
36
|
+
post('get', { keys: playlist_id })
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Update Playlist
|
|
40
|
+
#
|
|
41
|
+
# @param playlist_id [String]
|
|
42
|
+
# @param name [String]
|
|
43
|
+
# @param description [String]
|
|
44
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setPlaylistFields
|
|
45
|
+
# @example
|
|
46
|
+
# Ronnie.update_playlist('p87188', 'updated name', 'updated description')
|
|
47
|
+
def update_playlist(playlist_id, name, description, options={})
|
|
48
|
+
required_options = {
|
|
49
|
+
playlist: playlist_id,
|
|
50
|
+
name: name,
|
|
51
|
+
description: description,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
post('setPlaylistFields', required_options.merge!(options))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Add Tracks to Playlist
|
|
58
|
+
#
|
|
59
|
+
# @param tracks [Array]
|
|
60
|
+
# @param playlist_id [String]
|
|
61
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#addToPlaylist
|
|
62
|
+
# @example
|
|
63
|
+
# Ronnie.add_tracks_to_playlist(['t15940486'], 'p1429320')
|
|
64
|
+
def add_tracks_to_playlist(tracks, playlist_id, options={})
|
|
65
|
+
post('addToPlaylist', {
|
|
66
|
+
tracks: tracks.join(', '),
|
|
67
|
+
playlist: playlist_id
|
|
68
|
+
})
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Remove Tracks from Playlist
|
|
72
|
+
#
|
|
73
|
+
# @param tracks [Array]
|
|
74
|
+
# @param index [Integer]
|
|
75
|
+
# @param count [Integer]
|
|
76
|
+
# @param playlist_id [String]
|
|
77
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#removeFromPlaylist
|
|
78
|
+
# @example
|
|
79
|
+
# Ronnie.remove_tracks_from_playlist(['t15940486'], 'p1429320')
|
|
80
|
+
def remove_tracks_from_playlist(tracks, index, count, playlist_id, options={})
|
|
81
|
+
post('removeFromPlaylist', {
|
|
82
|
+
index: index,
|
|
83
|
+
count: count,
|
|
84
|
+
tracks: tracks.join(', '),
|
|
85
|
+
playlist: playlist_id
|
|
86
|
+
})
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Enable Public Collaboration
|
|
90
|
+
#
|
|
91
|
+
# @param playlist_id [String]
|
|
92
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setPlaylistCollaborationMode
|
|
93
|
+
# @example
|
|
94
|
+
# Ronnie.enable_public_collaboration('p1429320')
|
|
95
|
+
def enable_public_collaboration(playlist_id)
|
|
96
|
+
post('setPlaylistCollaborationMode', { playlist: playlist_id, mode: 1 })
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Enable Restricted Collaboration
|
|
100
|
+
#
|
|
101
|
+
# @param playlist_id [String]
|
|
102
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setPlaylistCollaborationMode
|
|
103
|
+
# @example
|
|
104
|
+
# Ronnie.enable_restricted_collaboration('p1429320')
|
|
105
|
+
def enable_restricted_collaboration(playlist_id)
|
|
106
|
+
post('setPlaylistCollaborationMode', { playlist: playlist_id, mode: 2 })
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Disable Collaboration
|
|
110
|
+
#
|
|
111
|
+
# @param playlist_id [String]
|
|
112
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#setPlaylistCollaborationMode
|
|
113
|
+
# @example
|
|
114
|
+
# Ronnie.disable_collaboration('p1429320')
|
|
115
|
+
def disable_collaboration(playlist_id)
|
|
116
|
+
post('setPlaylistCollaborationMode', { playlist: playlist_id, mode: 0 })
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Create a Playlist
|
|
120
|
+
#
|
|
121
|
+
# Requires authorized client.
|
|
122
|
+
#
|
|
123
|
+
# @param name [String] playlist name.
|
|
124
|
+
# @param description [String] playlist description.
|
|
125
|
+
# @param tracks [Array] playlist contents.
|
|
126
|
+
# @return [Hashie::Mash]
|
|
127
|
+
# @see Ronnie::Client
|
|
128
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#createPlaylist
|
|
129
|
+
# @example
|
|
130
|
+
# Ronnie.create_playlist(
|
|
131
|
+
# 'Your Ecclesiastical Adolescence',
|
|
132
|
+
# 'Music performed by Winona Ryder as Lelaina Pierce.',
|
|
133
|
+
# 't20680151'
|
|
134
|
+
# )
|
|
135
|
+
def create_playlist(name, description, tracks, options={})
|
|
136
|
+
required_options = {
|
|
137
|
+
name: name,
|
|
138
|
+
description: description,
|
|
139
|
+
tracks: tracks.join(', ')
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
post('createPlaylist', required_options.merge!(options))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Delete a playlist.
|
|
146
|
+
#
|
|
147
|
+
# Requires authorized client.
|
|
148
|
+
#
|
|
149
|
+
# @param playlist_id [String]
|
|
150
|
+
# @return [Boolean]
|
|
151
|
+
# @see http://developer.rdio.com/docs/read/rest/Methods#deletePlaylist
|
|
152
|
+
# @example
|
|
153
|
+
# Ronnie.delete_playlist('p87188')
|
|
154
|
+
def delete_playlist(playlist_id, options={})
|
|
155
|
+
post('deletePlaylist', { playlist: playlist_id })
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Ronnie
|
|
2
|
+
class Client
|
|
3
|
+
module Tracks
|
|
4
|
+
# Find Tracks by Artist
|
|
5
|
+
#
|
|
6
|
+
# @param artist_id [String]
|
|
7
|
+
# @example
|
|
8
|
+
# Ronnie.find_tracks_by_artist('r235282')
|
|
9
|
+
def find_tracks_by_artist(artist_id, options={})
|
|
10
|
+
post('getTracksForArtist', { artist: artist_id })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Find Tracks by ISRC
|
|
14
|
+
#
|
|
15
|
+
# @param isrc [String]
|
|
16
|
+
# @example
|
|
17
|
+
# Ronnie.find_tracks_by_isrc('GBAYE0200771')
|
|
18
|
+
def find_tracks_by_isrc(isrc, options={})
|
|
19
|
+
post('getTracksByISRC', { isrc: isrc })
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Search Tracks
|
|
23
|
+
#
|
|
24
|
+
# @param query [String]
|
|
25
|
+
# @example
|
|
26
|
+
# Ronnie.search_tracks('Through The Trees pt. 2')
|
|
27
|
+
def search_tracks(query, options={})
|
|
28
|
+
post('search', { query: query, types: 'Track' })
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|