Class: Grooveshark

Inherits:
Object
  • Object
show all
Defined in:
lib/grooveshark-ruby/new.rb,
lib/grooveshark-ruby/core.rb,
lib/grooveshark-ruby/recs.rb,
lib/grooveshark-ruby/urls.rb,
lib/grooveshark-ruby/users.rb,
lib/grooveshark-ruby/search.rb,
lib/grooveshark-ruby/trials.rb,
lib/grooveshark-ruby/request.rb,
lib/grooveshark-ruby/autoplay.rb,
lib/grooveshark-ruby/register.rb,
lib/grooveshark-ruby/sessions.rb,
lib/grooveshark-ruby/tinysong.rb,
lib/grooveshark-ruby/autocomplete.rb,
lib/grooveshark-ruby/subscriberstreams.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, secret) ⇒ Grooveshark

Returns a new instance of Grooveshark.



5
6
7
8
9
10
# File 'lib/grooveshark-ruby/new.rb', line 5

def initialize(key, secret)
	@key = key
	@secret = secret
	@session = startSession
	# @ipaddress = request.remote_ip
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



3
4
5
# File 'lib/grooveshark-ruby/new.rb', line 3

def session
  @session
end

Instance Method Details

#addSongToAutoplay(song, autoplayState) ⇒ Object



27
28
29
# File 'lib/grooveshark-ruby/autoplay.rb', line 27

def addSongToAutoplay(song, autoplayState)
	request('addSongToAutoplay', {'song' => song, 'autoplayState' => autoplayState})
end

#addUserFavoriteSong(songID) ⇒ Object



43
44
45
# File 'lib/grooveshark-ruby/core.rb', line 43

def addUserFavoriteSong(songID)
	request('addUserFavoriteSong', {'songID' => songID})
end

#addUserLibrarySongs(songIDs, albumIDs, artistIDs) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/core.rb', line 3

def addUserLibrarySongs(songIDs, albumIDs, artistIDs) 
	request('addUserLibrarySongs', {'songIDs' => songIDs, 'albumIDs' => albumIDs, 'artistIDs' => artistIDs})
end

#authenticate(login, password) ⇒ Object



151
152
153
154
# File 'lib/grooveshark-ruby/core.rb', line 151

def authenticate(, password)
	password = Digest::MD5.hexdigest(password)
	user = request('authenticate', {'login' => , 'password' => password}, true)['result']
end

#authenticateToken(token) ⇒ Object



160
161
162
# File 'lib/grooveshark-ruby/core.rb', line 160

def authenticateToken(token)
	request('authenticateToken', {'token' => token}, true)['result']
end

#authenticateUser(username, token) ⇒ Object



156
157
158
# File 'lib/grooveshark-ruby/core.rb', line 156

def authenticateUser(username, token)
	request('authenticateUser', {'username' => username, 'token' => token}, true)['result']
end

#createPlaylist(name, songIDs) ⇒ Object



83
84
85
# File 'lib/grooveshark-ruby/core.rb', line 83

def createPlaylist(name, songIDs)
	request('createPlaylist', {'name' => name, 'songIDs' => songIDs})
end

#createTrial(uniqueID) ⇒ Object



7
8
9
# File 'lib/grooveshark-ruby/trials.rb', line 7

def createTrial(uniqueID)
	request('createTrial', {'uniqueID' => uniqueID})
end

#deletePlaylist(playlistID) ⇒ Object



91
92
93
# File 'lib/grooveshark-ruby/core.rb', line 91

def deletePlaylist(playlistID)
	request('deletePlaylist', {'playlistID' => playlistID})
end

#getAlbumSearchResults(query, limit = false, offset = false) ⇒ Object



11
12
13
# File 'lib/grooveshark-ruby/search.rb', line 11

def getAlbumSearchResults(query, limit = false, offset = false)
	request('getAlbumSearchResults', { 'query' => query, 'limit' => limit, 'offset' => offset })['result']['albums']
end

#getAlbumsInfo(albumIDs) ⇒ Object



111
112
113
# File 'lib/grooveshark-ruby/core.rb', line 111

def getAlbumsInfo(albumIDs)
	request('getAlbumsInfo', {'albumIDs' => albumIDs})['result']['albums']
end

#getAlbumSongs(albumID, limit = nil) ⇒ Object



115
116
117
# File 'lib/grooveshark-ruby/core.rb', line 115

def getAlbumSongs(albumID, limit = nil)
	request('getAlbumSongs', {'albumID' => albumID, 'limit' => limit})['result']['songs']
end

#getArtistAlbums(artistID) ⇒ Object



147
148
149
# File 'lib/grooveshark-ruby/core.rb', line 147

def getArtistAlbums(artistID)
	request('getArtistAlbums', {'artistID' => artistID})['result']['albums']
end

#getArtistPopularSongs(artistID) ⇒ Object



143
144
145
# File 'lib/grooveshark-ruby/core.rb', line 143

def getArtistPopularSongs(artistID)
	request('getArtistPopularSongs', {'artistID' => artistID})['result']['songs']
end

#getArtistSearchResults(query, limit = false, offset = false) ⇒ Object



15
16
17
# File 'lib/grooveshark-ruby/search.rb', line 15

def getArtistSearchResults(query, limit = false, offset = false)
	request('getArtistSearchResults', { 'query' => query, 'limit' => limit, 'offset' => offset })['result']['artists']
end

#getArtistsInfo(artistIDs) ⇒ Object



119
120
121
# File 'lib/grooveshark-ruby/core.rb', line 119

def getArtistsInfo(artistIDs)
	request('getArtistsInfo', {'artistIDs' => artistIDs})['result']['artists']
end

#getArtistVerifiedAlbums(artistID) ⇒ Object



139
140
141
# File 'lib/grooveshark-ruby/core.rb', line 139

def getArtistVerifiedAlbums(artistID)
	request('getArtistVerifiedAlbums', {'artistID' => artistID})['result']['albums']
end

#getAutocompleteSearchResults(query, type, limit = false) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/autocomplete.rb', line 3

def getAutocompleteSearchResults(query, type, limit = false)
	request('getAutocompleteSearchResults', {'query' => query, 'type' => type, 'limit' => limit})
end

#getAutoplaySong(autoplayState) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/autoplay.rb', line 3

def getAutoplaySong(autoplayState)
	request('getAutoplaySong', {'autoplayState' => autoplayState})
end

#getAutoplayTagsObject



7
8
9
# File 'lib/grooveshark-ruby/autoplay.rb', line 7

def getAutoplayTags
	request('getAutoplayTags')
end

#getCountry(ip = nil) ⇒ Object



59
60
61
# File 'lib/grooveshark-ruby/core.rb', line 59

def getCountry(ip = nil)
	request('getCountry', {'ip' => ip})['result']
end

#getDoesAlbumExist(albumID) ⇒ Object



127
128
129
# File 'lib/grooveshark-ruby/core.rb', line 127

def getDoesAlbumExist(albumID)
	request('getDoesAlbumExist', {'albumID' => albumID})['result']
end

#getDoesArtistExist(artistID) ⇒ Object



135
136
137
# File 'lib/grooveshark-ruby/core.rb', line 135

def getDoesArtistExist(artistID)
	request('getDoesArtistExist', {'artistID' => artistID})['result']
end

#getDoesSongExist(songID) ⇒ Object



131
132
133
# File 'lib/grooveshark-ruby/core.rb', line 131

def getDoesSongExist(songID)
	request('getDoesSongExist', {'songID' => songID})['result']
end

#getPlaylist(playlistID, limit = nil) ⇒ Object



51
52
53
# File 'lib/grooveshark-ruby/core.rb', line 51

def getPlaylist(playlistID, limit = nil)
	request('getPlaylist', {'playlistID' => playlistID, 'limit' => limit})['result']
end

#getPlaylistInfo(playlistID) ⇒ Object



75
76
77
# File 'lib/grooveshark-ruby/core.rb', line 75

def getPlaylistInfo(playlistID)
	request('getPlaylistInfo', {'playlistID' => playlistID})['result']
end

#getPlaylistSearchResults(query, limit = false, offset = false) ⇒ Object



7
8
9
# File 'lib/grooveshark-ruby/search.rb', line 7

def getPlaylistSearchResults(query, limit = false, offset = false)
	request('getPlaylistSearchResults', { 'query' => query, 'limit' => limit, 'offset' => offset })['result']['playlists']
end

#getPlaylistSongs(playlistID, limit = nil) ⇒ Object



99
100
101
# File 'lib/grooveshark-ruby/core.rb', line 99

def getPlaylistSongs(playlistID, limit = nil)
	request('getPlaylistSongs', {'playlistID' => playlistID, 'limit' => limit})
end

#getPlaylistURLFromPlaylistID(playlistID) ⇒ Object



11
12
13
# File 'lib/grooveshark-ruby/urls.rb', line 11

def getPlaylistURLFromPlaylistID(playlistID)
	request('getPlaylistURLFromPlaylistID', {'playlistID' => playlistID})['result']['url']
end

#getPopularSongsMonth(limit = nil) ⇒ Object



63
64
65
# File 'lib/grooveshark-ruby/core.rb', line 63

def getPopularSongsMonth(limit = nil)
	request('getPopularSongsMonth', {'limit' => limit})['result']['songs']
end

#getPopularSongsToday(limit = nil) ⇒ Object



55
56
57
# File 'lib/grooveshark-ruby/core.rb', line 55

def getPopularSongsToday(limit = nil)
	request('getPopularSongsToday', {'limit' => limit})['result']['songs']
end

#getServiceDescriptionObject



67
68
69
# File 'lib/grooveshark-ruby/core.rb', line 67

def getServiceDescription
	request('getServiceDescription')['result']
end

#getSimilarArtists(artistID, limit = nil, page = nil) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/recs.rb', line 3

def getSimilarArtists(artistID, limit = nil, page = nil)
	request('getSimilarArtists', {'artistID' => artistID, 'limit' => limit, 'page' => page})
end

#getSongIDFromTinysongBase62(base62) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/tinysong.rb', line 3

def getSongIDFromTinysongBase62(base62)
	request('getSongIDFromTinysongBase62', {'base62' => base62})
end

#getSongSearchResults(query, country, limit = nil, offset = nil) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/search.rb', line 3

def getSongSearchResults(query, country, limit = nil, offset = nil)
	request('getSongSearchResults', { 'query' => query, 'country' => country, 'limit' => limit, 'offset' => offset })['result']['songs']
end

#getSongsInfo(songIDs) ⇒ Object



123
124
125
# File 'lib/grooveshark-ruby/core.rb', line 123

def getSongsInfo(songIDs)
	request('getSongsInfo', {'songIDs' => songIDs})['result']['songs']
end

#getSongURLFromSongID(songID) ⇒ Object



7
8
9
# File 'lib/grooveshark-ruby/urls.rb', line 7

def getSongURLFromSongID(songID)
	request('getSongURLFromSongID', {'songID' => songID})['result']['url']
end

#getSongURLFromTinysongBase62(base62) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/urls.rb', line 3

def getSongURLFromTinysongBase62(base62)
	request('getSongURLFromTinysongBase62', {'base62' => base62})['result']['url']
end

#getSubscriberStreamKey(songID, country, lowBitrate = nil, uniqueID = nil) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/subscriberstreams.rb', line 3

def getSubscriberStreamKey(songID, country, lowBitrate = nil, uniqueID = nil)
	request('getSubscriberStreamKey', {'songID' => songID, 'country' => country, 'lowBitrate' => lowBitrate, 'uniqueID' => uniqueID})
end

#getTinysongURLFromSongID(songID) ⇒ Object



15
16
17
# File 'lib/grooveshark-ruby/urls.rb', line 15

def getTinysongURLFromSongID(songID)
	request('getTinysongURLFromSongID', {'songID' => songID})['result']['url']
end

#getTrialInfo(uniqueID) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/trials.rb', line 3

def getTrialInfo(uniqueID)
	request('getTrialInfo', {'uniqueID' => uniqueID})
end

#getUserFavoriteSongs(limit = nil) ⇒ Object



27
28
29
# File 'lib/grooveshark-ruby/core.rb', line 27

def getUserFavoriteSongs(limit = nil)
	request('getUserFavoriteSongs', {'limit' => limit})['result']['songs']
end

#getUserIDFromUsername(username) ⇒ Object



107
108
109
# File 'lib/grooveshark-ruby/core.rb', line 107

def getUserIDFromUsername(username)
	request('getUserIDFromUsername', {'username' => username})
end

#getUserInfoObject



35
36
37
# File 'lib/grooveshark-ruby/core.rb', line 35

def getUserInfo
	request('getUserInfo')['result']
end

#getUserInfoFromUserID(userID) ⇒ Object



7
8
9
# File 'lib/grooveshark-ruby/users.rb', line 7

def getUserInfoFromUserID(userID)
	request('getUserInfoFromUserID', {'userID' => userID})
end

#getUserLibrarySongs(limit = nil, page = nil) ⇒ Object



7
8
9
# File 'lib/grooveshark-ruby/core.rb', line 7

def getUserLibrarySongs(limit = nil, page = nil)
	request('getUserLibrarySongs', {'limit' => limit, 'page' => page})['result']
end

#getUserPlaylists(limit = nil) ⇒ Object



15
16
17
# File 'lib/grooveshark-ruby/core.rb', line 15

def getUserPlaylists(limit = nil)
	request('getUserPlaylists', {'limit' => limit})['result']['playlists']
end

#getUserPlaylistsByUserID(userID, limit = nil) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/users.rb', line 3

def getUserPlaylistsByUserID(userID, limit = nil)
	request('getUserPlaylistsByUserID', {'userID' => userID, 'limit' => limit})
end

#getUserPlaylistsSubscribedObject



23
24
25
# File 'lib/grooveshark-ruby/core.rb', line 23

def getUserPlaylistsSubscribed
	request('getUserPlaylistsSubscribed')['result']['playlists']
end

#getUserSubscriptionDetailsObject



39
40
41
# File 'lib/grooveshark-ruby/core.rb', line 39

def getUserSubscriptionDetails
	request('getUserSubscriptionDetails')['result']
end

#logoutObject



164
165
166
# File 'lib/grooveshark-ruby/core.rb', line 164

def logout
	request('logout')
end

#makeToken(username, password) ⇒ Object



103
104
105
# File 'lib/grooveshark-ruby/core.rb', line 103

def makeToken(username, password)
	Digest::MD5.hexdigest(username.downcase + Digest::MD5.hexdigest(password))
end

#markSongComplete(songID, streamKey, streamServerID, autoplayState = nil) ⇒ Object



11
12
13
# File 'lib/grooveshark-ruby/subscriberstreams.rb', line 11

def markSongComplete(songID, streamKey, streamServerID, autoplayState = nil)
	request('markSongComplete', {'songID' => songID, 'streamKey' => streamKey, 'streamServerID' => streamServerID, 'autoplayState' => autoplayState})
end

#markStreamKeyOver30Secs(streamKey, streamServerID, uniqueID = nil) ⇒ Object



7
8
9
# File 'lib/grooveshark-ruby/subscriberstreams.rb', line 7

def markStreamKeyOver30Secs(streamKey, streamServerID, uniqueID = nil)
	request('markStreamKeyOver30Secs', {'streamKey' => streamKey, 'streamServerID' => streamServerID, 'uniqueID' => uniqueID})
end

#pingServiceObject



71
72
73
# File 'lib/grooveshark-ruby/core.rb', line 71

def pingService
	request('pingService')['result']
end

#registerUser(emailAddress, password, fullName, username = nil, gender = nil, birthDate = nil) ⇒ Object



3
4
5
# File 'lib/grooveshark-ruby/register.rb', line 3

def registerUser(emailAddress, password, fullName, username = nil, gender = nil, birthDate = nil)
	request('registerUser', {'emailAddress' => emailAddress, 'password' => password, 'fullName' => fullName, 'username' => username, 'gender' => gender, 'birthDate' => birthDate}, true)
end

#removeSongFromAutoplay(song, autoplayState) ⇒ Object



31
32
33
# File 'lib/grooveshark-ruby/autoplay.rb', line 31

def removeSongFromAutoplay(song, autoplayState)
	request('removeSongFromAutoplay', {'song' => song, 'autoplayState' => autoplayState})
end

#removeUserFavoriteSongs(songIDs) ⇒ Object



31
32
33
# File 'lib/grooveshark-ruby/core.rb', line 31

def removeUserFavoriteSongs(songIDs)
	request('removeUserFavoriteSongs', {'songIDs' => songIDs})
end

#removeUserLibrarySongs(songIDs, albumIDs, artistIDs) ⇒ Object



11
12
13
# File 'lib/grooveshark-ruby/core.rb', line 11

def removeUserLibrarySongs(songIDs, albumIDs, artistIDs)
	request('removeUserLibrarySongs', {'songIDs' => songIDs, 'albumIDs' => albumIDs, 'artistIDs' => artistIDs})
end

#removeVoteDownAutoplaySong(song, autoplayState) ⇒ Object



35
36
37
# File 'lib/grooveshark-ruby/autoplay.rb', line 35

def removeVoteDownAutoplaySong(song, autoplayState)
	request('removeVoteDownAutoplaySong', {'song' => song, 'autoplayState' => autoplayState})
end

#removeVoteUpAutoplaySong(song, autoplayState) ⇒ Object



19
20
21
# File 'lib/grooveshark-ruby/autoplay.rb', line 19

def removeVoteUpAutoplaySong(song, autoplayState)
	request('removeVoteUpAutoplaySong', {'song' => song, 'autoplayState' => autoplayState})
end

#renamePlaylist(playlistID, name) ⇒ Object



87
88
89
# File 'lib/grooveshark-ruby/core.rb', line 87

def renamePlaylist(playlistID, name)
	request('renamePlaylist', {'playlistID' => playlistID, 'name' => name})
end

#request(method, params = {}, secure = false, session = @session) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/grooveshark-ruby/request.rb', line 3

def request(method, params = {}, secure = false, session = @session)
	data = {
		"method" => method,
		"parameters" => params,
		"header" => { "wsKey" => @key,
					  "sessionID" => session
					}
	}.to_json
	sig = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::MD5.new, @secret, data)
	url = "#{secure ? 'https' : 'http'}://api.grooveshark.com/ws3.php?sig=#{sig}"
	response = RestClient.post(url, data)
	JSON.parse(response)
end

#setPlaylistSongs(playlistID, songIDs) ⇒ Object



95
96
97
# File 'lib/grooveshark-ruby/core.rb', line 95

def setPlaylistSongs(playlistID, songIDs)
	request('setPlaylistSongs', {'playlistID' => playlistID, 'songIDs' => songIDs})
end

#startAutoplay(artistIDs, songIDs = nil) ⇒ Object



15
16
17
# File 'lib/grooveshark-ruby/autoplay.rb', line 15

def startAutoplay(artistIDs, songIDs = nil)
	request('startAutoplay', {'artistIDs' => artistIDs, 'songIDs' => songIDs})
end

#startAutoplayTag(tagID) ⇒ Object



11
12
13
# File 'lib/grooveshark-ruby/autoplay.rb', line 11

def startAutoplayTag(tagID)
	request('startAutoplayTag', {'tagID' => tagID})
end

#startSessionObject



3
4
5
# File 'lib/grooveshark-ruby/sessions.rb', line 3

def startSession
	request('startSession', {}, true, nil)['result']['sessionID']
end

#subscribePlaylist(playlistID) ⇒ Object



19
20
21
# File 'lib/grooveshark-ruby/core.rb', line 19

def subscribePlaylist(playlistID)
	request('subscribePlaylist', {'playlistID' => playlistID})
end

#undeletePlaylist(playlistID) ⇒ Object



79
80
81
# File 'lib/grooveshark-ruby/core.rb', line 79

def undeletePlaylist(playlistID)
	request('undeletePlaylist', {'playlistID' => playlistID})
end

#unsubscribePlaylist(playlistID) ⇒ Object



47
48
49
# File 'lib/grooveshark-ruby/core.rb', line 47

def unsubscribePlaylist(playlistID)
	request('unsubscribePlaylist', {'playlistID' => playlistID})
end

#voteDownAutoplaySong(song, autoplayState) ⇒ Object



39
40
41
# File 'lib/grooveshark-ruby/autoplay.rb', line 39

def voteDownAutoplaySong(song, autoplayState)
	request('voteDownAutoplaySong', {'song' => song, 'autoplayState' => autoplayState})
end

#voteUpAutoplaySong(song, autoplayState) ⇒ Object



23
24
25
# File 'lib/grooveshark-ruby/autoplay.rb', line 23

def voteUpAutoplaySong(song, autoplayState)
	request('voteUpAutoplaySong', {'song' => song, 'autoplayState' => autoplayState})
end