Module: Vk::DSL::Audio

Included in:
Vk::DSL
Defined in:
lib/vk/dsl/audio.rb

Constant Summary collapse

AUDIO_SORT =
{
  popularity: 2,
  duration: 1,
  date: 0
}

Instance Method Summary collapse

Instance Method Details

#get_audio_albums(owner_id, options = {}) ⇒ Object

Parameters:

  • owner_id (Integer)

    user’s identifier

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :offset (Fixnum)
  • :count (Fixnum)


26
27
28
# File 'lib/vk/dsl/audio.rb', line 26

def get_audio_albums(owner_id, options = {})
  Vk::Result.new('audio.getAlbums', Vk::Audio::Album, options.merge(owner_id: owner_id))
end

#get_audios(owner_id, options = {}) ⇒ Object

Parameters:

  • owner_id (Integer)

    user’s identifier

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :offset (Fixnum)
  • :count (Fixnum)


17
18
19
20
# File 'lib/vk/dsl/audio.rb', line 17

def get_audios(owner_id, options = {})
  fail NotImplementedError, ':need_user is not supported for audio.get method' if options.key?(:need_user)
  Vk::Result.new('audio.get', Vk::Audio, options.merge(owner_id: owner_id))
end

#get_lyrics(lyrics_id) ⇒ Vk::Audio::Lyrics

Parameters:

  • lyrics_id (Fixnum)

Returns:



32
33
34
# File 'lib/vk/dsl/audio.rb', line 32

def get_lyrics(lyrics_id)
  Vk::Audio::Lyrics.new(request('audio.getLyrics', {lyrics_id: lyrics_id}))
end

#search_lyrics(q, options = {}) ⇒ Object

Parameters:

  • q (String)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :offset (Fixnum)
  • :count (Fixnum)
  • :auto_complete (Fixnum)


41
42
43
44
45
46
47
48
# File 'lib/vk/dsl/audio.rb', line 41

def search_lyrics(q, options = {})
  options[:auto_complete] = !!options[:auto_complete] ? 1 : 0 if options.key?(:auto_complete)
  options[:lyrics] = !!options[:lyrics] ? 1 : 0 if options.key?(:lyrics)
  options[:performer_only] = !!options[:performer_only] ? 1 : 0 if options.key?(:performer_only)
  options[:sort] = AUDIO_SORT[options[:sort]] if options[:sort].is_a?(Symbol)
  options[:search_own] = !!options[:search_own] ? 1 : 0 if options.key?(:search_own)
  Vk::Result.new('audio.search', Vk::Audio, options.merge(q: q))
end