module VkMusic::Utility::PlaylistUrlParser

Read inner of text-childrens of Nokogiri::XML::Node node

Constants

VK_PLAYLIST_URL_POSTFIX

Regular expression to parse playlist link. Oh my, it is so big

Public Class Methods

call(url) click to toggle source

@param url [String] @return [Array(Integer?, Integer?, String?)] playlist data array:

+[owner_id, playlist_id, access_hash]+
# File lib/vk_music/utility/playlist_url_parser.rb, line 19
def self.call(url)
  owner_id, playlist_id, access_hash = url.match(VK_PLAYLIST_URL_POSTFIX).captures

  owner_id = Integer(owner_id, 10)
  playlist_id = Integer(playlist_id, 10)
  access_hash = nil if access_hash&.empty?

  [owner_id, playlist_id, access_hash]
rescue StandardError
  [nil, nil, nil]
end