Class: VkMusic::WebParser::Search
- Defined in:
- lib/vk_music/web_parser/search.rb
Overview
Audio search page parser
Instance Method Summary collapse
-
#audios ⇒ Array<Audio>
Audios found.
-
#audios_all_path ⇒ String?
Path to page with all results.
-
#playlists ⇒ Array<Playlist>
Playlists found.
-
#playlists_all_path ⇒ String?
Path to page with all results.
Methods inherited from Base
Constructor Details
This class inherits a constructor from VkMusic::WebParser::Base
Instance Method Details
#audios ⇒ Array<Audio>
Audios found
9 10 11 12 13 14 15 16 |
# File 'lib/vk_music/web_parser/search.rb', line 9 def audios title_index = search_result_blocks.find_index { |node| node.inner_text.include?('Все аудиозаписи') } return [] if title_index.nil? block = search_result_blocks[title_index + 1] Utility::AudioItemsParser.call(block, @client_id) end |
#audios_all_path ⇒ String?
Path to page with all results
20 21 22 23 24 25 |
# File 'lib/vk_music/web_parser/search.rb', line 20 def audios_all_path title = search_result_blocks.find { |node| node.inner_text.include?('Все аудиозаписи') } return if title.nil? title.at_css('a').attribute('href').value end |
#playlists ⇒ Array<Playlist>
Playlists found
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vk_music/web_parser/search.rb', line 29 def playlists title_index = search_result_blocks.find_index { |node| node.inner_text.include?('Альбомы') } return [] if title_index.nil? block = search_result_blocks[title_index + 1] block.css('.audioPlaylists__item').map do |elem| Utility::PlaylistNodeParser.call(elem) end end |
#playlists_all_path ⇒ String?
Path to page with all results
42 43 44 45 46 47 |
# File 'lib/vk_music/web_parser/search.rb', line 42 def playlists_all_path title = search_result_blocks.find { |node| node.inner_text.include?('Альбомы') } return if title.nil? title.at_css('a').attribute('href').value end |