Class: Rocksky::Library
- Inherits:
-
Object
- Object
- Rocksky::Library
- Defined in:
- lib/rocksky/library.rb
Overview
Authenticated client for the app.rocksky.library.* API — the Subsonic / navidrome-compatible surface over a user's uploaded music. Every method requires auth, so a token is mandatory at construction (see Rocksky.library). Optional params are Ruby keyword args (nil = omitted); wire keys stay camelCase. Returns the parsed JSON payload.
Instance Method Summary collapse
-
#create_playlist(name) ⇒ Object
app.rocksky.library.createPlaylist.
-
#delete_album(id) ⇒ Object
app.rocksky.library.deleteAlbum.
-
#delete_playlist(id) ⇒ Object
app.rocksky.library.deletePlaylist.
-
#delete_song(id) ⇒ Object
app.rocksky.library.deleteSong.
-
#get_album(id) ⇒ Object
app.rocksky.library.getAlbum.
-
#get_album_info(id) ⇒ Object
app.rocksky.library.getAlbumInfo.
-
#get_album_list(type, size: nil, offset: nil, from_year: nil, to_year: nil, genre: nil) ⇒ Object
app.rocksky.library.getAlbumList.
-
#get_artist(id) ⇒ Object
app.rocksky.library.getArtist.
-
#get_artist_info(id) ⇒ Object
app.rocksky.library.getArtistInfo.
-
#get_artists ⇒ Object
app.rocksky.library.getArtists.
-
#get_cover_art_url(id, size: nil) ⇒ Object
app.rocksky.library.getCoverArtUrl.
-
#get_download_url(id) ⇒ Object
app.rocksky.library.getDownloadUrl.
-
#get_genres ⇒ Object
app.rocksky.library.getGenres.
-
#get_indexes ⇒ Object
app.rocksky.library.getIndexes.
-
#get_internet_radio_stations ⇒ Object
app.rocksky.library.getInternetRadioStations.
-
#get_license ⇒ Object
app.rocksky.library.getLicense.
-
#get_lyrics(artist: nil, title: nil) ⇒ Object
app.rocksky.library.getLyrics.
-
#get_music_directory(id) ⇒ Object
app.rocksky.library.getMusicDirectory.
-
#get_music_folders ⇒ Object
app.rocksky.library.getMusicFolders.
-
#get_now_playing ⇒ Object
app.rocksky.library.getNowPlaying.
-
#get_play_queue ⇒ Object
app.rocksky.library.getPlayQueue.
-
#get_playlist(id) ⇒ Object
app.rocksky.library.getPlaylist.
-
#get_playlists ⇒ Object
app.rocksky.library.getPlaylists.
-
#get_random_songs(size: nil, genre: nil, from_year: nil, to_year: nil) ⇒ Object
app.rocksky.library.getRandomSongs.
-
#get_scan_status ⇒ Object
app.rocksky.library.getScanStatus.
-
#get_similar_songs(id, count: nil) ⇒ Object
app.rocksky.library.getSimilarSongs.
-
#get_song(id) ⇒ Object
app.rocksky.library.getSong.
-
#get_songs_by_genre(genre, count: nil, offset: nil) ⇒ Object
app.rocksky.library.getSongsByGenre.
-
#get_starred ⇒ Object
app.rocksky.library.getStarred.
-
#get_stream_url(id, max_bit_rate: nil, format: nil) ⇒ Object
app.rocksky.library.getStreamUrl.
-
#get_top_songs(artist, count: nil) ⇒ Object
app.rocksky.library.getTopSongs.
-
#get_user ⇒ Object
app.rocksky.library.getUser.
-
#initialize(token, base: nil) ⇒ Library
constructor
A new instance of Library.
-
#ping ⇒ Object
app.rocksky.library.ping.
-
#save_play_queue(id: nil, current: nil, position: nil) ⇒ Object
app.rocksky.library.savePlayQueue.
-
#scrobble(id, time: nil, submission: nil) ⇒ Object
app.rocksky.library.scrobble.
-
#search(query, artist_count: nil, artist_offset: nil, album_count: nil, album_offset: nil, song_count: nil, song_offset: nil) ⇒ Object
app.rocksky.library.search.
-
#star(id, album_id: nil, artist_id: nil) ⇒ Object
app.rocksky.library.star.
-
#start_scan ⇒ Object
app.rocksky.library.startScan.
-
#unstar(id, album_id: nil, artist_id: nil) ⇒ Object
app.rocksky.library.unstar.
-
#update_now_playing(id) ⇒ Object
app.rocksky.library.updateNowPlaying.
-
#update_playlist(playlist_id, name: nil, comment: nil, song_id_to_add: nil, song_index_to_remove: nil) ⇒ Object
app.rocksky.library.updatePlaylist.
Constructor Details
#initialize(token, base: nil) ⇒ Library
Returns a new instance of Library.
10 11 12 13 14 15 |
# File 'lib/rocksky/library.rb', line 10 def initialize(token, base: nil) raise Error, "app.rocksky.library.* requires an access token" if token.nil? || token.to_s.empty? @token = token.to_s @base = base.to_s end |
Instance Method Details
#create_playlist(name) ⇒ Object
app.rocksky.library.createPlaylist
153 154 155 |
# File 'lib/rocksky/library.rb', line 153 def create_playlist(name) procedure("app.rocksky.library.createPlaylist", { name: name }) end |
#delete_album(id) ⇒ Object
app.rocksky.library.deleteAlbum
173 174 175 |
# File 'lib/rocksky/library.rb', line 173 def delete_album(id) procedure("app.rocksky.library.deleteAlbum", { id: id }) end |
#delete_playlist(id) ⇒ Object
app.rocksky.library.deletePlaylist
163 164 165 |
# File 'lib/rocksky/library.rb', line 163 def delete_playlist(id) procedure("app.rocksky.library.deletePlaylist", { id: id }) end |
#delete_song(id) ⇒ Object
app.rocksky.library.deleteSong
168 169 170 |
# File 'lib/rocksky/library.rb', line 168 def delete_song(id) procedure("app.rocksky.library.deleteSong", { id: id }) end |
#get_album(id) ⇒ Object
app.rocksky.library.getAlbum
68 69 70 |
# File 'lib/rocksky/library.rb', line 68 def get_album(id) query("app.rocksky.library.getAlbum", { id: id }) end |
#get_album_info(id) ⇒ Object
app.rocksky.library.getAlbumInfo
78 79 80 |
# File 'lib/rocksky/library.rb', line 78 def get_album_info(id) query("app.rocksky.library.getAlbumInfo", { id: id }) end |
#get_album_list(type, size: nil, offset: nil, from_year: nil, to_year: nil, genre: nil) ⇒ Object
app.rocksky.library.getAlbumList
73 74 75 |
# File 'lib/rocksky/library.rb', line 73 def get_album_list(type, size: nil, offset: nil, from_year: nil, to_year: nil, genre: nil) query("app.rocksky.library.getAlbumList", { type: type, size: size, offset: offset, fromYear: from_year, toYear: to_year, genre: genre }) end |
#get_artist(id) ⇒ Object
app.rocksky.library.getArtist
58 59 60 |
# File 'lib/rocksky/library.rb', line 58 def get_artist(id) query("app.rocksky.library.getArtist", { id: id }) end |
#get_artist_info(id) ⇒ Object
app.rocksky.library.getArtistInfo
63 64 65 |
# File 'lib/rocksky/library.rb', line 63 def get_artist_info(id) query("app.rocksky.library.getArtistInfo", { id: id }) end |
#get_artists ⇒ Object
app.rocksky.library.getArtists
48 49 50 |
# File 'lib/rocksky/library.rb', line 48 def get_artists() query("app.rocksky.library.getArtists", {}) end |
#get_cover_art_url(id, size: nil) ⇒ Object
app.rocksky.library.getCoverArtUrl
213 214 215 |
# File 'lib/rocksky/library.rb', line 213 def get_cover_art_url(id, size: nil) query("app.rocksky.library.getCoverArtUrl", { id: id, size: size }) end |
#get_download_url(id) ⇒ Object
app.rocksky.library.getDownloadUrl
208 209 210 |
# File 'lib/rocksky/library.rb', line 208 def get_download_url(id) query("app.rocksky.library.getDownloadUrl", { id: id }) end |
#get_genres ⇒ Object
app.rocksky.library.getGenres
118 119 120 |
# File 'lib/rocksky/library.rb', line 118 def get_genres() query("app.rocksky.library.getGenres", {}) end |
#get_indexes ⇒ Object
app.rocksky.library.getIndexes
53 54 55 |
# File 'lib/rocksky/library.rb', line 53 def get_indexes() query("app.rocksky.library.getIndexes", {}) end |
#get_internet_radio_stations ⇒ Object
app.rocksky.library.getInternetRadioStations
218 219 220 |
# File 'lib/rocksky/library.rb', line 218 def get_internet_radio_stations() query("app.rocksky.library.getInternetRadioStations", {}) end |
#get_license ⇒ Object
app.rocksky.library.getLicense
23 24 25 |
# File 'lib/rocksky/library.rb', line 23 def get_license() query("app.rocksky.library.getLicense", {}) end |
#get_lyrics(artist: nil, title: nil) ⇒ Object
app.rocksky.library.getLyrics
108 109 110 |
# File 'lib/rocksky/library.rb', line 108 def get_lyrics(artist: nil, title: nil) query("app.rocksky.library.getLyrics", { artist: artist, title: title }) end |
#get_music_directory(id) ⇒ Object
app.rocksky.library.getMusicDirectory
113 114 115 |
# File 'lib/rocksky/library.rb', line 113 def get_music_directory(id) query("app.rocksky.library.getMusicDirectory", { id: id }) end |
#get_music_folders ⇒ Object
app.rocksky.library.getMusicFolders
28 29 30 |
# File 'lib/rocksky/library.rb', line 28 def get_music_folders() query("app.rocksky.library.getMusicFolders", {}) end |
#get_now_playing ⇒ Object
app.rocksky.library.getNowPlaying
188 189 190 |
# File 'lib/rocksky/library.rb', line 188 def () query("app.rocksky.library.getNowPlaying", {}) end |
#get_play_queue ⇒ Object
app.rocksky.library.getPlayQueue
193 194 195 |
# File 'lib/rocksky/library.rb', line 193 def get_play_queue() query("app.rocksky.library.getPlayQueue", {}) end |
#get_playlist(id) ⇒ Object
app.rocksky.library.getPlaylist
148 149 150 |
# File 'lib/rocksky/library.rb', line 148 def get_playlist(id) query("app.rocksky.library.getPlaylist", { id: id }) end |
#get_playlists ⇒ Object
app.rocksky.library.getPlaylists
143 144 145 |
# File 'lib/rocksky/library.rb', line 143 def get_playlists() query("app.rocksky.library.getPlaylists", {}) end |
#get_random_songs(size: nil, genre: nil, from_year: nil, to_year: nil) ⇒ Object
app.rocksky.library.getRandomSongs
88 89 90 |
# File 'lib/rocksky/library.rb', line 88 def get_random_songs(size: nil, genre: nil, from_year: nil, to_year: nil) query("app.rocksky.library.getRandomSongs", { size: size, genre: genre, fromYear: from_year, toYear: to_year }) end |
#get_scan_status ⇒ Object
app.rocksky.library.getScanStatus
33 34 35 |
# File 'lib/rocksky/library.rb', line 33 def get_scan_status() query("app.rocksky.library.getScanStatus", {}) end |
#get_similar_songs(id, count: nil) ⇒ Object
app.rocksky.library.getSimilarSongs
98 99 100 |
# File 'lib/rocksky/library.rb', line 98 def get_similar_songs(id, count: nil) query("app.rocksky.library.getSimilarSongs", { id: id, count: count }) end |
#get_song(id) ⇒ Object
app.rocksky.library.getSong
83 84 85 |
# File 'lib/rocksky/library.rb', line 83 def get_song(id) query("app.rocksky.library.getSong", { id: id }) end |
#get_songs_by_genre(genre, count: nil, offset: nil) ⇒ Object
app.rocksky.library.getSongsByGenre
93 94 95 |
# File 'lib/rocksky/library.rb', line 93 def get_songs_by_genre(genre, count: nil, offset: nil) query("app.rocksky.library.getSongsByGenre", { genre: genre, count: count, offset: offset }) end |
#get_starred ⇒ Object
app.rocksky.library.getStarred
128 129 130 |
# File 'lib/rocksky/library.rb', line 128 def get_starred() query("app.rocksky.library.getStarred", {}) end |
#get_stream_url(id, max_bit_rate: nil, format: nil) ⇒ Object
app.rocksky.library.getStreamUrl
203 204 205 |
# File 'lib/rocksky/library.rb', line 203 def get_stream_url(id, max_bit_rate: nil, format: nil) query("app.rocksky.library.getStreamUrl", { id: id, maxBitRate: max_bit_rate, format: format }) end |
#get_top_songs(artist, count: nil) ⇒ Object
app.rocksky.library.getTopSongs
103 104 105 |
# File 'lib/rocksky/library.rb', line 103 def get_top_songs(artist, count: nil) query("app.rocksky.library.getTopSongs", { artist: artist, count: count }) end |
#get_user ⇒ Object
app.rocksky.library.getUser
43 44 45 |
# File 'lib/rocksky/library.rb', line 43 def get_user() query("app.rocksky.library.getUser", {}) end |
#ping ⇒ Object
app.rocksky.library.ping
18 19 20 |
# File 'lib/rocksky/library.rb', line 18 def ping() query("app.rocksky.library.ping", {}) end |
#save_play_queue(id: nil, current: nil, position: nil) ⇒ Object
app.rocksky.library.savePlayQueue
198 199 200 |
# File 'lib/rocksky/library.rb', line 198 def save_play_queue(id: nil, current: nil, position: nil) procedure("app.rocksky.library.savePlayQueue", { id: id, current: current, position: position }) end |
#scrobble(id, time: nil, submission: nil) ⇒ Object
app.rocksky.library.scrobble
178 179 180 |
# File 'lib/rocksky/library.rb', line 178 def scrobble(id, time: nil, submission: nil) procedure("app.rocksky.library.scrobble", { id: id, time: time, submission: submission }) end |
#search(query, artist_count: nil, artist_offset: nil, album_count: nil, album_offset: nil, song_count: nil, song_offset: nil) ⇒ Object
app.rocksky.library.search
123 124 125 |
# File 'lib/rocksky/library.rb', line 123 def search(query, artist_count: nil, artist_offset: nil, album_count: nil, album_offset: nil, song_count: nil, song_offset: nil) query("app.rocksky.library.search", { query: query, artistCount: artist_count, artistOffset: artist_offset, albumCount: album_count, albumOffset: album_offset, songCount: song_count, songOffset: song_offset }) end |
#star(id, album_id: nil, artist_id: nil) ⇒ Object
app.rocksky.library.star
133 134 135 |
# File 'lib/rocksky/library.rb', line 133 def star(id, album_id: nil, artist_id: nil) procedure("app.rocksky.library.star", { id: id, albumId: album_id, artistId: artist_id }) end |
#start_scan ⇒ Object
app.rocksky.library.startScan
38 39 40 |
# File 'lib/rocksky/library.rb', line 38 def start_scan() query("app.rocksky.library.startScan", {}) end |
#unstar(id, album_id: nil, artist_id: nil) ⇒ Object
app.rocksky.library.unstar
138 139 140 |
# File 'lib/rocksky/library.rb', line 138 def unstar(id, album_id: nil, artist_id: nil) procedure("app.rocksky.library.unstar", { id: id, albumId: album_id, artistId: artist_id }) end |
#update_now_playing(id) ⇒ Object
app.rocksky.library.updateNowPlaying
183 184 185 |
# File 'lib/rocksky/library.rb', line 183 def (id) procedure("app.rocksky.library.updateNowPlaying", { id: id }) end |
#update_playlist(playlist_id, name: nil, comment: nil, song_id_to_add: nil, song_index_to_remove: nil) ⇒ Object
app.rocksky.library.updatePlaylist
158 159 160 |
# File 'lib/rocksky/library.rb', line 158 def update_playlist(playlist_id, name: nil, comment: nil, song_id_to_add: nil, song_index_to_remove: nil) procedure("app.rocksky.library.updatePlaylist", { playlistId: playlist_id, name: name, comment: comment, songIdToAdd: song_id_to_add, songIndexToRemove: song_index_to_remove }) end |