Module: VkMusic::Utility::AudiosLoader

Defined in:
lib/vk_music/utility/audios_loader.rb

Overview

Load user or group audios

Class Method Summary collapse

Class Method Details

.call(agent, client_id, owner_id, up_to) ⇒ Playlist?

Parameters:

  • agent (Mechanize)
  • client_id (Integer)
  • owner_id (Integer)
  • up_to (Integer)

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vk_music/utility/audios_loader.rb', line 13

def call(agent, client_id, owner_id, up_to)
  page = Request::PlaylistSection.new(owner_id, -1, '', 0, client_id).call(agent)
  audios = page.audios
  return if audios.nil? || audios.empty?

  up_to = page.real_size if up_to > page.real_size

  load_till_up_to(audios, agent, client_id, owner_id, up_to)

  Playlist.new(audios, id: -1, owner_id: owner_id, access_hash: '',
                       title: page.title, subtitle: page.subtitle, real_size: page.real_size)
end