grooveshark 0.2.8.1 → 0.2.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d353bdcd6c8de12ac82635d8cf21b4aff0a0398
4
+ data.tar.gz: 23702348073546abd32c472875a36b6b427fa9bb
5
+ SHA512:
6
+ metadata.gz: ac645b069fd9956049d8c982c7b2cf74d275d40c50c64f56095a7132c4ab1e038fe7ec31d53d622e2305110a1ff0a1ef7ac8a1e0f9af9d3df3ec3434a87778a1
7
+ data.tar.gz: a5d38d2e45caa98a721eaf6142a75cbc458e9862ade9310a170e04a4168be09a7eecab3e848007561ac657b58e9e75ed696cd2665b28e941c5c8f077fe3a0f5f
data/README.md ADDED
@@ -0,0 +1,252 @@
1
+ # Grooveshark API
2
+
3
+ Unofficial grooveshark API ruby library gives your ability to search and stream songs,
4
+ manage playlists, media library and favorites.
5
+ API was discovered using http proxy and does not pretend to be always valid due to website API changes.
6
+
7
+ ## Installation
8
+
9
+ Install gem from rubygems:
10
+
11
+ ```
12
+ gem install grooveshark
13
+ ```
14
+
15
+ Or add this line to your `Gemfile`:
16
+
17
+ ```
18
+ gem "grooveshark"
19
+ ```
20
+
21
+ And install bundle:
22
+
23
+ ```
24
+ bundle install
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ First, you'll need to create a session. Grooveshark's session is a
30
+ regular PHP session with expiration date of 7 days.
31
+
32
+ ```ruby
33
+ require 'grooveshark'
34
+
35
+ client = Grooveshark::Client.new
36
+ ```
37
+
38
+ To get session key just call
39
+
40
+ ```
41
+ session = client.session
42
+ ```
43
+
44
+ You can store this key for 7 days after creation and use it like this:
45
+
46
+ ```
47
+ client = Grooveshark::Client.new(SESSION_KEY)
48
+ ```
49
+
50
+ Now we can find some songs:
51
+
52
+ ```ruby
53
+ songs = client.search_songs('Nirvana')
54
+
55
+ songs.each do |s|
56
+ s.id # Song ID
57
+ s.name # Song name
58
+ s.artist # Song artist name
59
+ s.album # Song album name
60
+ s.duration # Song duration in seconds (not always present, 0 by default)
61
+ end
62
+ ```
63
+
64
+ We got collection of songs. Check Song object for additional attributes.
65
+ In order to stream song we need to get the authorization
66
+
67
+ ```ruby
68
+ song = songs.first
69
+ url = client.get_song_url(song)
70
+ ```
71
+
72
+ Given url is valid only for current session and cannot be shared or stored permanently.
73
+ Also, it probably violates terms of service.
74
+
75
+ ### User Authentication
76
+
77
+ To get your user account you need to provide username and password.
78
+ If username or password is not valid InvalidAuthentication exception will be raised.
79
+
80
+ ```ruby
81
+ client = Grooveshark::Client.new
82
+
83
+ begin
84
+ user = client.login('username', 'password')
85
+ rescue InvalidAuthentication
86
+ puts "Oooops! Wrong username or password"
87
+ end
88
+ ```
89
+
90
+ ### Playlists and favorites
91
+
92
+ Get all user playlists:
93
+
94
+ ```ruby
95
+ user.playlists.each do |p|
96
+ p.id # Playlist ID
97
+ p.name # Playlist name
98
+ p.about # Playlist description (empty by default)
99
+ end
100
+ ```
101
+
102
+ Get user playlist:
103
+
104
+ ```ruby
105
+ playlist = user.get_playlist(PLAYLIST_ID)
106
+ ```
107
+
108
+ Get all playlist songs:
109
+
110
+ ```ruby
111
+ playlist = user.get_playlist(ID)
112
+ playlist.load_songs
113
+ songs = playlist.songs
114
+ ```
115
+
116
+ Rename existing playlist:
117
+
118
+ ```ruby
119
+ playlist = user.get_playlist(ID)
120
+ playlist.rename('NEW NAME', 'NEW DESCRIPTION')
121
+ ```
122
+
123
+ Delete existing user playlist
124
+
125
+ ```ruby
126
+ playlist = user.get_playlist(ID)
127
+ playlist.delete
128
+ ```
129
+
130
+ Create a new playlist. First parameter is mandatory, description and songs are optional.
131
+ For songs you can provide array of Song objects or array of IDs.
132
+
133
+ ```ruby
134
+ songs = client.search_songs('Joe Satriani')
135
+ p = user.create_playlist('NAME', 'DESCRIPTION', songs)
136
+ ```
137
+
138
+ Get user favorite songs:
139
+
140
+ ```ruby
141
+ songs = user.favorites
142
+ ```
143
+
144
+ Add song to favorites:
145
+
146
+ ```ruby
147
+ user.add_favorite(song) # Song object or song ID
148
+ ```
149
+
150
+ Remove song from favorites:
151
+
152
+ ```ruby
153
+ user.remove_favorite(song) # Song object or song ID
154
+ ```
155
+
156
+ ### User library
157
+
158
+ Get all songs from library as a collection of Song objects
159
+
160
+ ```ruby
161
+ songs = user.library
162
+ ```
163
+
164
+ Add songs to library:
165
+
166
+ ```ruby
167
+ songs = client.search_songs('The Beatles')
168
+ user.library_add(songs)
169
+ ```
170
+
171
+ Remove selected songs from library.
172
+ Unfortunately mass-deletion is not supported by Grooveshark API.
173
+ You will have to delete each song via separate method call.
174
+
175
+ ```ruby
176
+ song = user.library.first # Lest pick a first song in the library
177
+ user.library_remove(song)
178
+ ```
179
+
180
+ ### Explore community
181
+
182
+ Get all recently active users:
183
+
184
+ ```ruby
185
+ client.recent_users
186
+ ```
187
+
188
+ Find user by ID:
189
+
190
+ ```ruby
191
+ client.get_user_by_id('ID')
192
+ ```
193
+
194
+ Find user by username:
195
+
196
+ ```ruby
197
+ client.get_user_by_username('username')
198
+ ```
199
+
200
+ Fetch recent user activity:
201
+
202
+ ```ruby
203
+ user = client.get_user_by_username('user')
204
+ user.feed
205
+ ```
206
+
207
+ ## Known issues
208
+
209
+ - Communication token gets rejected after some time. This timeframe is always different. Additional research didnt show any results.
210
+
211
+ ## TODO
212
+
213
+ - Testing
214
+ - Library management coverage
215
+ - More methods
216
+
217
+ ## Testing
218
+
219
+ Run test suite:
220
+
221
+ ```
222
+ rake test
223
+ ```
224
+
225
+ ## Contact
226
+
227
+ - Dan Sosedoff
228
+ - dan.sosedoff@gmail.com
229
+ - http://twitter.com/dan_sosedoff
230
+
231
+ ## License
232
+
233
+ MIT License
234
+
235
+ Copyright (c) 2011-2013 Dan Sosedoff.
236
+
237
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
238
+ this software and associated documentation files (the "Software"), to deal in
239
+ the Software without restriction, including without limitation the rights to
240
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
241
+ the Software, and to permit persons to whom the Software is furnished to do so,
242
+ subject to the following conditions:
243
+
244
+ The above copyright notice and this permission notice shall be included in all
245
+ copies or substantial portions of the Software.
246
+
247
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
248
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
249
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
250
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
251
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
252
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/grooveshark.gemspec CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Dan Sosedoff"]
10
10
  s.email = "dan.sosedoff@gmail.com"
11
11
  s.homepage = "http://github.com/sosedoff/grooveshark"
12
+ s.license = "MIT"
12
13
 
13
14
  s.files = `git ls-files`.split("\n")
14
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -20,7 +20,7 @@ module Grooveshark
20
20
 
21
21
  # Fetch playlist songs
22
22
  def load_songs
23
- @songs = @client.request('playlistGetSongs', :playlistID => @id)['songs']
23
+ @songs = @client.request('getPlaylistByID', :playlistID => @id)['songs']
24
24
  @songs.map! { |s| Song.new(s) }
25
25
  end
26
26
 
@@ -41,4 +41,4 @@ module Grooveshark
41
41
  @client.request('deletePlaylist', {:playlistID => @id, :name => @name})
42
42
  end
43
43
  end
44
- end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Grooveshark
2
- VERSION = '0.2.8.1'
2
+ VERSION = "0.2.8.2"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grooveshark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8.1
5
- prerelease:
4
+ version: 0.2.8.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan Sosedoff
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-18 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,39 +41,34 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: json
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.4.6
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.4.6
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rest-client
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: 1.5.1
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: 1.5.1
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: uuid
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -101,7 +90,7 @@ files:
101
90
  - .rspec
102
91
  - Gemfile
103
92
  - LICENSE
104
- - README.rdoc
93
+ - README.md
105
94
  - Rakefile
106
95
  - grooveshark.gemspec
107
96
  - lib/grooveshark.rb
@@ -116,34 +105,28 @@ files:
116
105
  - spec/helper.rb
117
106
  - spec/utils_spec.rb
118
107
  homepage: http://github.com/sosedoff/grooveshark
119
- licenses: []
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
120
111
  post_install_message:
121
112
  rdoc_options: []
122
113
  require_paths:
123
114
  - lib
124
115
  required_ruby_version: !ruby/object:Gem::Requirement
125
- none: false
126
116
  requirements:
127
- - - ! '>='
117
+ - - '>='
128
118
  - !ruby/object:Gem::Version
129
119
  version: '0'
130
- segments:
131
- - 0
132
- hash: 2904794095928449912
133
120
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
121
  requirements:
136
- - - ! '>='
122
+ - - '>='
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
- segments:
140
- - 0
141
- hash: 2904794095928449912
142
125
  requirements: []
143
126
  rubyforge_project:
144
- rubygems_version: 1.8.25
127
+ rubygems_version: 2.0.5
145
128
  signing_key:
146
- specification_version: 3
129
+ specification_version: 4
147
130
  summary: Grooveshark API
148
131
  test_files:
149
132
  - spec/client_spec.rb
data/README.rdoc DELETED
@@ -1,159 +0,0 @@
1
- = Grooveshark API
2
-
3
- Unofficial grooveshark API ruby library gives your ability to search and stream songs,
4
- manage playlists, media library and favorites.
5
- API was discovered using http proxy and does not pretend to be always valid due to website API changes.
6
-
7
- = Installation
8
-
9
- gem install grooveshark
10
-
11
- = Getting Started
12
-
13
- Lets first create a session.
14
- Grooveshark session is a regular PHP session with expiration date of 7 days.
15
-
16
- require 'rubygems'
17
- require 'grooveshark'
18
-
19
- client = Grooveshark::Client.new
20
-
21
- To get session key just call
22
-
23
- session = client.session
24
-
25
- You can store this key for 7 days after creation and use it like this:
26
-
27
- client = Grooveshark::Client.new(SESSION_KEY)
28
-
29
- Now we can find some songs:
30
-
31
- songs = client.search_songs('Nirvana')
32
-
33
- songs.each do |s|
34
- s.id # Song ID
35
- s.name # Song name
36
- s.artist # Song artist name
37
- s.album # Song album name
38
- s.duration # Song duration in seconds (not always present, 0 by default)
39
- end
40
-
41
- We got collection of songs. Check Song object for additional attributes.
42
- In order to stream song we need to get the authorization
43
-
44
- song = songs.first
45
- url = client.get_song_url(song)
46
-
47
- Given url is valid only for current session and cannot be shared or stored permanently.
48
- Also, it probably violates terms of service.
49
-
50
- = User Authentication
51
-
52
- To get your user account you need to provide username and password.
53
- If username or password is not valid InvalidAuthentication exception will be raised.
54
-
55
- client = Grooveshark::Client.new
56
-
57
- begin
58
- user = client.login('username', 'password')
59
- rescue InvalidAuthentication
60
- puts "Oooops! Wrong username or password"
61
- end
62
-
63
- = Playlists and favorites
64
-
65
- Get all user playlists
66
-
67
- user.playlists.each do |p|
68
- p.id # Playlist ID
69
- p.name # Playlist name
70
- p.about # Playlist description (empty by default)
71
- end
72
-
73
- Get user playlist
74
-
75
- playlist = user.get_playlist(PLAYLIST_ID)
76
-
77
- Get all playlist songs
78
-
79
- playlist = user.get_playlist(ID)
80
- playlist.load_songs
81
- songs = playlist.songs
82
-
83
- Rename existing playlist
84
-
85
- playlist = user.get_playlist(ID)
86
- playlist.rename('NEW NAME', 'NEW DESCRIPTION')
87
-
88
- Delete existing user playlist
89
-
90
- playlist = user.get_playlist(ID)
91
- playlist.delete
92
-
93
- Create a new playlist. First parameter is mandatory, description and songs are optional.
94
- For songs you can provide array of Song objects or array of IDs.
95
-
96
- songs = client.search_songs('Joe Satriani')
97
- p = user.create_playlist('NAME', 'DESCRIPTION', songs)
98
-
99
- Get user favorite songs
100
-
101
- songs = user.favorites
102
-
103
- Add song to favorites
104
-
105
- user.add_favorite(song) # Song object or song ID
106
-
107
- Remove song from favorites
108
-
109
- user.remove_favorite(song) # Song object or song ID
110
-
111
- = User library
112
-
113
- Get all songs from library as a collection of Song objects
114
-
115
- songs = user.library
116
-
117
- Add songs to library
118
-
119
- songs = client.search_songs('The Beatles')
120
- user.library_add(songs)
121
-
122
- Remove selected songs from library. Unfortunately mass-deletion is not supported by Grooveshark API. You will have to delete each song via separate method call.
123
-
124
- song = user.library.first # Lest pick a first song in the library
125
- user.library_remove(song)
126
-
127
- = Explore community
128
-
129
- Get all recently active users
130
-
131
- client.recent_users
132
-
133
- Find user by ID
134
-
135
- client.get_user_by_id('ID')
136
-
137
- Find user by username
138
-
139
- client.get_user_by_username('username')
140
-
141
- Fetch recent user activity
142
-
143
- user = client.get_user_by_username('user')
144
- user.feed
145
-
146
- = Known issues
147
-
148
- * Communication token gets rejected after some time. This timeframe is always different. Additional research didnt show any results.
149
-
150
- = TODO
151
-
152
- * Testing
153
- * Library management coverage
154
- * More methods
155
-
156
- = Credits
157
-
158
- * Dan Sosedoff - http://github.com/sosedoff
159
- * Daniel Lamando - http://github.com/danopia