Module: VkMusic::Utility::LinkDecoder

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

Overview

Link decoding utilities

Constant Summary collapse

@@js_context =

JS context with unmasking link

ExecJS.compile(JS_CODE)

Class Method Summary collapse

Class Method Details

.call(link, client_id) ⇒ String?

Unmask audio download URL

Parameters:

Returns:

  • (String?)

    audio download URL, which can be used only from current IP.



98
99
100
101
102
103
104
# File 'lib/vk_music/utility/link_decoder.rb', line 98

def self.call(link, client_id)
  VkMusic.log.debug('LinkDecoder') { "Unmasking link `#{link}` with client id #{client_id}" }
  @@js_context.call('vk_unmask_link', link, client_id)
rescue StandardError => e
  VkMusic.log.warn('LinkDecoder') { "Failed to decode link `#{link}`: #{e.full_message}" }
  nil
end