Class: KodiClient::Methods::AudioLibrary

Inherits:
KodiMethod
  • Object
show all
Defined in:
lib/kodi_client/methods/audio_library.rb

Overview

contains all Kodi Application methods

Constant Summary collapse

CLEAN =
'AudioLibrary.Clean'
EXPORT =
'AudioLibrary.Export'
GET_ALBUM_DETAILS =
'AudioLibrary.GetAlbumDetails'
GET_ALBUMS =
'AudioLibrary.GetAlbums'
GET_ARTIST_DETAILS =
'AudioLibrary.GetArtistDetails'
GET_ARTISTS =
'AudioLibrary.GetArtists'
GET_AVAILABLE_ART =
'AudioLibrary.GetAvailableArt'
GET_AVAILABLE_ART_TYPES =
'AudioLibrary.GetAvailableArtTypes'
GET_GENRES =
'AudioLibrary.GetGenres'
GET_PROPERTIES =
'AudioLibrary.GetProperties'
GET_RECENTLY_ADDED_ALBUMS =
'AudioLibrary.GetRecentlyAddedAlbums'
GET_RECENTLY_ADDED_SONGS =
'AudioLibrary.GetRecentlyAddedSongs'
GET_RECENTLY_PLAYED_ALBUMS =
'AudioLibrary.GetRecentlyPlayedAlbums'
GET_RECENTLY_PLAYED_SONGS =
'AudioLibrary.GetRecentlyPlayedSongs'
GET_ROLES =
'AudioLibrary.GetRoles'
GET_SONG_DETAILS =
'AudioLibrary.GetSongDetails'
GET_SOURCES =
'AudioLibrary.GetSources'
GET_SONGS =
'AudioLibrary.GetSongs'
SCAN =
'AudioLibrary.Scan'
SET_ALBUM_DETAILS =
'AudioLibrary.SetAlbumDetails'
SET_ARTIST_DETAILS =
'AudioLibrary.SetArtistDetails'
SET_SONG_DETAILS =
'AudioLibrary.SetSongDetails'

Instance Method Summary collapse

Methods inherited from KodiMethod

#apply_options, #invoke_api

Instance Method Details

#clean(show_dialogs = true, kodi_id = 1) ⇒ Object



31
32
33
34
35
# File 'lib/kodi_client/methods/audio_library.rb', line 31

def clean(show_dialogs = true, kodi_id = 1)
  request = KodiRequest.new(kodi_id, CLEAN, { 'showdialogs' => show_dialogs })
  json = invoke_api(request)
  KodiResponse.new(json)
end

#export(path, kodi_id = 1) ⇒ Object



43
44
45
46
47
# File 'lib/kodi_client/methods/audio_library.rb', line 43

def export(path, kodi_id = 1)
  request = KodiRequest.new(kodi_id, EXPORT, { 'options' => { 'path' => path } })
  json = invoke_api(request)
  KodiResponse.new(json)
end

#get_album_details(album_id, properties = Types::Audio::AudioFieldsAlbum.all_properties, kodi_id = 1) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/kodi_client/methods/audio_library.rb', line 49

def get_album_details(album_id, properties = Types::Audio::AudioFieldsAlbum.all_properties, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_ALBUM_DETAILS, { 'albumid' => album_id, 'properties' => properties })
  json = invoke_api(request)
  album_details = json['result'].nil? ? nil : json['result']['albumdetails']
  json['result'] = Types::Audio::AudioDetailsAlbum.create(album_details)
  KodiResponse.new(json)
end

#get_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, include_singles = false, all_roles = false, kodi_id = 1) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/kodi_client/methods/audio_library.rb', line 57

def get_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties,
               limits = Types::List::ListLimits.new(0, 50),
               sort = Types::List::ListSort.new, include_singles = false, all_roles = false, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_ALBUMS,
                            { 'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h,
                              'includesingles' => include_singles, 'allroles' => all_roles })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetAlbumsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_artist_details(artist_id, properties = Types::Audio::AudioFieldsArtist.all_properties, kodi_id = 1) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/kodi_client/methods/audio_library.rb', line 70

def get_artist_details(artist_id, properties = Types::Audio::AudioFieldsArtist.all_properties, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_ARTIST_DETAILS, { 'artistid' => artist_id, 'properties' => properties })
  json = invoke_api(request)
  artist_details = json['result'].nil? ? nil : json['result']['artistdetails']
  json['result'] = Types::Audio::AudioDetailsArtist.create(artist_details)
  KodiResponse.new(json)
end

#get_artists(album_artists_only = nil, properties = Types::Audio::AudioFieldsArtist.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, all_roles = false, kodi_id = 1) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/kodi_client/methods/audio_library.rb', line 78

def get_artists(album_artists_only = nil, properties = Types::Audio::AudioFieldsArtist.all_properties,
                limits = Types::List::ListLimits.new(0, 50),
                sort = Types::List::ListSort.new, all_roles = false, kodi_id = 1)
  params = { 'albumartistsonly' => album_artists_only, 'properties' => properties,
             'limits' => limits.to_h, 'sort' => sort.to_h, 'allroles' => all_roles }
  params['albumartistsonly'] = album_artists_only unless album_artists_only.nil?
  request = KodiRequest.new(kodi_id, GET_ARTISTS, params)
  json = invoke_api(request)
  json['result'] = Types::Audio::GetArtistsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_available_art_for_album(artist_id, art_type = '', kodi_id = 1) ⇒ Object



94
95
96
# File 'lib/kodi_client/methods/audio_library.rb', line 94

def get_available_art_for_album(artist_id, art_type = '', kodi_id = 1)
  get_available_art({ 'albumid' => artist_id }, art_type, kodi_id)
end

#get_available_art_for_artist(artist_id, art_type = '', kodi_id = 1) ⇒ Object



90
91
92
# File 'lib/kodi_client/methods/audio_library.rb', line 90

def get_available_art_for_artist(artist_id, art_type = '', kodi_id = 1)
  get_available_art({ 'artistid' => artist_id }, art_type, kodi_id)
end

#get_available_art_types_for_album(album_id, kodi_id = 1) ⇒ Object



110
111
112
# File 'lib/kodi_client/methods/audio_library.rb', line 110

def get_available_art_types_for_album(album_id, kodi_id = 1)
  get_available_art_types({ 'albumid' => album_id }, kodi_id)
end

#get_available_art_types_for_artist(artist_id, kodi_id = 1) ⇒ Object



106
107
108
# File 'lib/kodi_client/methods/audio_library.rb', line 106

def get_available_art_types_for_artist(artist_id, kodi_id = 1)
  get_available_art_types({ 'artistid' => artist_id }, kodi_id)
end

#get_genres(properties = Types::Library::LibraryFieldsGenre.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/kodi_client/methods/audio_library.rb', line 122

def get_genres(properties = Types::Library::LibraryFieldsGenre.all_properties,
               limits = Types::List::ListLimits.new(0, 50),
               sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_GENRES, { 'properties' => properties,
                                                   'limits' => limits.to_h,
                                                   'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetGenresReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_properties(properties = Types::Audio::PropertyName.all_properties, kodi_id = 1) ⇒ Object



133
134
135
136
137
138
# File 'lib/kodi_client/methods/audio_library.rb', line 133

def get_properties(properties = Types::Audio::PropertyName.all_properties, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_PROPERTIES, { 'properties' => properties, })
  json = invoke_api(request)
  json['result'] = Types::Audio::PropertyValue.create(json['result'])
  KodiResponse.new(json)
end

#get_recently_added_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/kodi_client/methods/audio_library.rb', line 140

def get_recently_added_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties,
                              limits = Types::List::ListLimits.new(0, 50),
                              sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_RECENTLY_ADDED_ALBUMS,
                            { 'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetAlbumsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_recently_added_songs(album_limit = 100, properties = Types::Audio::AudioFieldsSong.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/kodi_client/methods/audio_library.rb', line 152

def get_recently_added_songs(album_limit = 100, properties = Types::Audio::AudioFieldsSong.all_properties,
                             limits = Types::List::ListLimits.new(0, 50),
                             sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_RECENTLY_ADDED_SONGS,
                            { 'albumlimit' => album_limit,
                              'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetSongsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_recently_played_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/kodi_client/methods/audio_library.rb', line 165

def get_recently_played_albums(properties = Types::Audio::AudioFieldsAlbum.all_properties,
                               limits = Types::List::ListLimits.new(0, 50),
                               sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_RECENTLY_PLAYED_ALBUMS,
                            { 'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetAlbumsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_recently_played_songs(album_limit = 100, properties = Types::Audio::AudioFieldsSong.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/kodi_client/methods/audio_library.rb', line 177

def get_recently_played_songs(album_limit = 100, properties = Types::Audio::AudioFieldsSong.all_properties,
                              limits = Types::List::ListLimits.new(0, 50),
                              sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_RECENTLY_PLAYED_SONGS,
                            { 'albumlimit' => album_limit,
                              'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetSongsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_roles(properties = Types::Audio::AudioFieldsRole.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



190
191
192
193
194
195
196
197
198
199
# File 'lib/kodi_client/methods/audio_library.rb', line 190

def get_roles(properties = Types::Audio::AudioFieldsRole.all_properties,
              limits = Types::List::ListLimits.new(0, 50),
              sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_ROLES, { 'properties' => properties,
                                                  'limits' => limits.to_h,
                                                  'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetRolesReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_song_details(song_id, properties = Types::Audio::AudioFieldsSong.all_properties, kodi_id = 1) ⇒ Object



201
202
203
204
205
206
207
# File 'lib/kodi_client/methods/audio_library.rb', line 201

def get_song_details(song_id, properties = Types::Audio::AudioFieldsSong.all_properties, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_SONG_DETAILS, { 'songid' => song_id, 'properties' => properties })
  json = invoke_api(request)
  song_details = json['result'].nil? ? nil : json['result']['songdetails']
  json['result'] = Types::Audio::AudioDetailsSong.create(song_details)
  KodiResponse.new(json)
end

#get_songs(properties = Types::Audio::AudioFieldsSong.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, include_singles = true, all_roles = true, singles_only = false, kodi_id = 1) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/kodi_client/methods/audio_library.rb', line 221

def get_songs(properties = Types::Audio::AudioFieldsSong.all_properties,
              limits = Types::List::ListLimits.new(0, 50),
              sort = Types::List::ListSort.new, include_singles = true, all_roles = true,
              singles_only = false, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_SONGS,
                            { 'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h, 'includesingles' => include_singles, 'allroles' => all_roles,
                              'singlesonly' => singles_only })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetSongsReturned.create(json['result'])
  KodiResponse.new(json)
end

#get_sources(properties = Types::Library::LibraryFieldsSource.all_properties, limits = Types::List::ListLimits.new(0, 50), sort = Types::List::ListSort.new, kodi_id = 1) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
# File 'lib/kodi_client/methods/audio_library.rb', line 209

def get_sources(properties = Types::Library::LibraryFieldsSource.all_properties,
                limits = Types::List::ListLimits.new(0, 50),
                sort = Types::List::ListSort.new, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_SOURCES,
                            { 'properties' => properties,
                              'limits' => limits.to_h,
                              'sort' => sort.to_h })
  json = invoke_api(request)
  json['result'] = Types::Audio::GetSourcesReturned.create(json['result'])
  KodiResponse.new(json)
end

#scan(show_dialogs = true, kodi_id = 1) ⇒ Object



37
38
39
40
41
# File 'lib/kodi_client/methods/audio_library.rb', line 37

def scan(show_dialogs = true, kodi_id = 1)
  request = KodiRequest.new(kodi_id, SCAN, { 'showdialogs' => show_dialogs })
  json = invoke_api(request)
  KodiResponse.new(json)
end

#set_album_details(album_id, title = nil, artist = nil, description = nil, genre = nil, theme = nil, mood = nil, style = nil, type = nil, album_label = nil, rating = nil, year = nil, user_rating = nil, votes = nil, musicbrainz_album_id = nil, musicbrainz_release_group_id = nil, sort_artist = nil, display_artist = nil, musicbrainz_album_artist_id = nil, art = nil, is_box_set = nil, release_date = nil, original_date = nil, kodi_id = 1) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/kodi_client/methods/audio_library.rb', line 235

def set_album_details(album_id, title = nil, artist = nil, description = nil, genre = nil, theme = nil,
                      mood = nil, style = nil, type = nil, album_label = nil, rating = nil, year = nil,
                      user_rating = nil, votes = nil, musicbrainz_album_id = nil,
                      musicbrainz_release_group_id = nil, sort_artist = nil, display_artist = nil,
                      musicbrainz_album_artist_id = nil, art = nil, is_box_set = nil, release_date = nil,
                      original_date = nil, kodi_id = 1)
  params = { 'albumid' => album_id }
  params['title'] = title unless title.nil?
  params['artist'] = artist unless artist.nil?
  params['description'] = description unless description.nil?
  params['genre'] = genre unless genre.nil?
  params['theme'] = theme unless theme.nil?
  params['mood'] = mood unless mood.nil?
  params['style'] = style unless style.nil?
  params['type'] = type unless type.nil?
  params['albumlabel'] = album_label unless album_label.nil?
  params['rating'] = rating unless rating.nil?
  params['year'] = year unless year.nil?
  params['userrating'] = user_rating unless user_rating.nil?
  params['votes'] = votes unless votes.nil?
  params['musicbrainzalbumid'] = musicbrainz_album_id unless musicbrainz_album_id.nil?
  params['musicbrainzreleasegroupid'] = musicbrainz_release_group_id unless musicbrainz_release_group_id.nil?
  params['sortartist'] = sort_artist unless sort_artist.nil?
  params['displayartist'] = display_artist unless display_artist.nil?
  params['musicbrainzalbumartistid'] = musicbrainz_album_artist_id unless musicbrainz_album_artist_id.nil?
  params['art'] = art.to_h unless art.nil?
  params['isboxset'] = is_box_set unless is_box_set.nil?
  params['releasedate'] = release_date unless release_date.nil?
  params['originaldate'] = original_date unless original_date.nil?

  request = KodiRequest.new(kodi_id, SET_ALBUM_DETAILS, params)
  json = invoke_api(request)
  KodiResponse.new(json)
end

#set_artist_details(artist_id, artist = nil, instrument = nil, style = nil, mood = nil, born = nil, formed = nil, description = nil, genre = nil, died = nil, disbanded = nil, years_active = nil, musicbrainz_artist_id = nil, sort_name = nil, type = nil, gender = nil, disambiguation = nil, art = nil, kodi_id = 1) ⇒ Object



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/kodi_client/methods/audio_library.rb', line 270

def set_artist_details(artist_id, artist = nil, instrument = nil, style = nil, mood = nil, born = nil,
                       formed = nil, description = nil, genre = nil, died = nil, disbanded = nil,
                       years_active = nil, musicbrainz_artist_id = nil, sort_name = nil, type = nil,
                       gender = nil, disambiguation = nil, art = nil, kodi_id = 1)
  params = { 'artistid' => artist_id }
  params['artist'] = artist unless artist.nil?
  params['instrument'] = instrument unless instrument.nil?
  params['style'] = style unless style.nil?
  params['mood'] = mood unless mood.nil?
  params['born'] = born unless born.nil?
  params['formed'] = formed unless formed.nil?
  params['description'] = description unless description.nil?
  params['genre'] = genre unless genre.nil?
  params['died'] = died unless died.nil?
  params['disbanded'] = disbanded unless disbanded.nil?
  params['yearsactive'] = years_active unless years_active.nil?
  params['musicbrainzartistid'] = musicbrainz_artist_id unless musicbrainz_artist_id.nil?
  params['sortname'] = sort_name unless sort_name.nil?
  params['type'] = type unless type.nil?
  params['gender'] = gender unless gender.nil?
  params['disambiguation'] = disambiguation unless disambiguation.nil?
  params['art'] = art.to_h unless art.nil?
  request = KodiRequest.new(kodi_id, SET_ARTIST_DETAILS, params)
  json = invoke_api(request)
  KodiResponse.new(json)
end

#set_song_details(song_id, title = nil, artist = nil, genre = nil, year = nil, rating = nil, track = nil, disc = nil, duration = nil, comment = nil, musicbrainz_track_id = nil, musicbrainz_artist_id = nil, play_count = nil, last_played = nil, user_rating = nil, votes = nil, display_artist = nil, sort_artist = nil, mood = nil, art = nil, release_date = nil, original_date = nil, bpm = nil, kodi_id = 1) ⇒ Object



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/kodi_client/methods/audio_library.rb', line 297

def set_song_details(song_id, title = nil, artist = nil, genre = nil, year = nil, rating = nil, track = nil,
                     disc = nil, duration = nil, comment = nil, musicbrainz_track_id = nil,
                     musicbrainz_artist_id = nil, play_count = nil, last_played = nil, user_rating = nil,
                     votes = nil, display_artist = nil, sort_artist = nil, mood = nil, art = nil,
                     release_date = nil, original_date = nil, bpm = nil, kodi_id = 1)
  params = { 'songid' => song_id }
  params['title'] = title unless title.nil?
  params['artist'] = artist unless artist.nil?
  params['genre'] = genre unless genre.nil?
  params['year'] = year unless year.nil?
  params['rating'] = rating unless rating.nil?
  params['track'] = track unless track.nil?
  params['disc'] = disc unless disc.nil?
  params['duration'] = duration unless duration.nil?
  params['comment'] = comment unless comment.nil?
  params['musicbrainztrackid'] = musicbrainz_track_id unless musicbrainz_track_id.nil?
  params['musicbrainzartistid'] = musicbrainz_artist_id unless musicbrainz_artist_id.nil?
  params['playcount'] = play_count unless play_count.nil?
  params['lastplayed'] = last_played unless last_played.nil?
  params['userrating'] = user_rating unless user_rating.nil?
  params['votes'] = votes unless votes.nil?
  params['displayartist'] = display_artist unless display_artist.nil?
  params['sortartist'] = sort_artist unless sort_artist.nil?
  params['mood'] = mood unless mood.nil?
  params['art'] = art.to_h unless art.nil?
  params['releasedate'] = release_date unless release_date.nil?
  params['originaldate'] = original_date unless original_date.nil?
  params['bpm'] = bpm unless bpm.nil?

  request = KodiRequest.new(kodi_id, SET_SONG_DETAILS, params)
  json = invoke_api(request)
  KodiResponse.new(json)
end