vk_music 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a54709405afad78ce1cfc55e5487ecb55d8a7930e3ef511997175eb01995c9a
4
- data.tar.gz: dc49da61941078903e7b3da469631ba7d4eb266260ceed882a1b811e11d3ddaf
3
+ metadata.gz: 982d3964597ca683823d8dfd1aff172ef5f117b740e9020aabf5019cb43beea5
4
+ data.tar.gz: 6bd53fb80d6105287e0db7e2b6af63c224d5ce366b4e227cbb0d310d49c167ec
5
5
  SHA512:
6
- metadata.gz: dc27e9b56575d82481157b0cbde9d4ad742fd002f117601c8b8461422cb956bd18654f477499459480c1b298f768452ff01586017a0121865b8cc446feb1c444
7
- data.tar.gz: 21a10dc20607098e432f9da31172c74d83f59b2e2cb41879d9aaaa25f3907c3bffbbc2440195f121178a5d349aed7f7f69cf7ccf1f8913d8cf82920f32012e94
6
+ metadata.gz: d15ced8f7a23fdce6ee9304264092b11fceeb93d78f213ff1be8b2e47566c334011b1f8065d88e7125c81df5b4939ca21ee9f986e72f2a13c183edd35c861304
7
+ data.tar.gz: 39294ec31d752dc92147916a69f2460110fad028ff7115210bbfae19b786707c7dbc9e7cee5f19a3254b668605785cde10c3fde40cc93d1bd80825415da0a4aa
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vk_music (4.0.1)
4
+ vk_music (4.0.2)
5
5
  execjs (~> 2.7)
6
6
  json (~> 2.3)
7
7
  logger (~> 1.4)
@@ -26,7 +26,7 @@ GEM
26
26
  hashdiff (1.0.1)
27
27
  http-cookie (1.0.3)
28
28
  domain_name (~> 0.5)
29
- json (2.3.1)
29
+ json (2.4.1)
30
30
  logger (1.4.2)
31
31
  mechanize (2.7.6)
32
32
  domain_name (~> 0.5, >= 0.5.1)
@@ -47,7 +47,7 @@ GEM
47
47
  nokogiri (1.10.10)
48
48
  mini_portile2 (~> 2.4.0)
49
49
  ntlm-http (0.1.1)
50
- parallel (1.19.2)
50
+ parallel (1.20.1)
51
51
  parser (2.7.2.0)
52
52
  ast (~> 2.4.1)
53
53
  pry (0.13.1)
@@ -56,7 +56,7 @@ GEM
56
56
  public_suffix (4.0.6)
57
57
  rainbow (3.0.0)
58
58
  rake (13.0.1)
59
- regexp_parser (1.8.2)
59
+ regexp_parser (2.0.0)
60
60
  rexml (3.2.4)
61
61
  rspec (3.10.0)
62
62
  rspec-core (~> 3.10.0)
@@ -71,28 +71,30 @@ GEM
71
71
  diff-lcs (>= 1.2.0, < 2.0)
72
72
  rspec-support (~> 3.10.0)
73
73
  rspec-support (3.10.0)
74
- rubocop (1.2.0)
74
+ rubocop (1.6.1)
75
75
  parallel (~> 1.10)
76
76
  parser (>= 2.7.1.5)
77
77
  rainbow (>= 2.2.2, < 4.0)
78
- regexp_parser (>= 1.8)
78
+ regexp_parser (>= 1.8, < 3.0)
79
79
  rexml
80
- rubocop-ast (>= 1.0.1)
80
+ rubocop-ast (>= 1.2.0, < 2.0)
81
81
  ruby-progressbar (~> 1.7)
82
82
  unicode-display_width (>= 1.4.0, < 2.0)
83
- rubocop-ast (1.1.1)
83
+ rubocop-ast (1.3.0)
84
84
  parser (>= 2.7.1.5)
85
85
  ruby-progressbar (1.10.1)
86
- simplecov (0.19.1)
86
+ simplecov (0.20.0)
87
87
  docile (~> 1.1)
88
88
  simplecov-html (~> 0.11)
89
+ simplecov_json_formatter (~> 0.1)
89
90
  simplecov-html (0.12.3)
91
+ simplecov_json_formatter (0.1.2)
90
92
  unf (0.1.4)
91
93
  unf_ext
92
94
  unf_ext (0.0.7.7)
93
95
  unicode-display_width (1.7.0)
94
96
  vcr (6.0.0)
95
- webmock (3.9.5)
97
+ webmock (3.10.0)
96
98
  addressable (>= 2.3.6)
97
99
  crack (>= 0.3.2)
98
100
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -101,7 +103,6 @@ GEM
101
103
 
102
104
  PLATFORMS
103
105
  ruby
104
- x64-mingw32
105
106
 
106
107
  DEPENDENCIES
107
108
  byebug
@@ -51,12 +51,6 @@ module VkMusic
51
51
  false
52
52
  end
53
53
 
54
- # Unmask old VK music link
55
- # @param limk [String]
56
- def unmask_link(link)
57
- VkMusic::LinkDecoder.unmask_link(link, @id)
58
- end
59
-
60
54
  # Search for audio or playlist
61
55
  #
62
56
  # Possible values of +type+ option:
@@ -3,17 +3,17 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Parse {Audio} from +Array+ of audio data
6
- class AudioDataParser
6
+ module AudioDataParser
7
7
  class << self
8
8
  # @param data [Array]
9
9
  # @param client_id [Integer]
10
10
  # @return [Audio]
11
11
  def call(data, client_id)
12
12
  url_encoded = get_url_encoded(data)
13
- secrets = get_secrets(data)
13
+ _add_hash, _edit_hash, action_hash, _delete_hash, _teplace_hash, url_hash = get_secrets(data)
14
14
 
15
15
  Audio.new(id: data[0], owner_id: data[1],
16
- secret1: secrets[2], secret2: secrets[5],
16
+ secret1: action_hash, secret2: url_hash,
17
17
  artist: CGI.unescapeHTML(data[4]), title: CGI.unescapeHTML(data[3]),
18
18
  duration: data[5],
19
19
  url_encoded: url_encoded, url: nil, client_id: client_id)
@@ -3,12 +3,12 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Parse {Audio} from +Nokogiri::XML::Node+
6
- class AudioItemsParser
6
+ module AudioItemsParser
7
7
  # @param node [Nokogiri::XML::Node]
8
8
  # @param client_id [Integer]
9
9
  # @return [Array<Audio>]
10
10
  def self.call(node, client_id)
11
- node.css('.audio_item.ai_has_btn').map do |elem|
11
+ node.css('.audio_item.ai_has_btn,.audio_item.audio_item_disabled').map do |elem|
12
12
  data = JSON.parse(elem.attribute('data-audio').value)
13
13
  Utility::AudioDataParser.call(data, client_id)
14
14
  end
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Parse {Audio} from +Nokogiri::XML::Node+
6
- class AudioNodeParser
6
+ module AudioNodeParser
7
7
  class << self
8
8
  # @param node [Nokogiri::XML::Node]
9
9
  # @param client_id [Integer]
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load audios from ids
6
- class AudiosFromIdsLoader
6
+ module AudiosFromIdsLoader
7
7
  # @param agent [Mechanize]
8
8
  # @param ids [Array<String>]
9
9
  # @return [Array<Audio>]
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load ids from array of data
6
- class AudiosIdsGetter
6
+ module AudiosIdsGetter
7
7
  # @param args [Array<Audio, (owner_id, audio_id, secret_1, secret_2),
8
8
  # "#{owner_id}_#{id}_#{secret_1}_#{secret_2}">]
9
9
  # @return [Array<String>] array of uniq full ids
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load user or group audios
6
- class AudiosLoader
6
+ module AudiosLoader
7
7
  class << self
8
8
  # @param agent [Mechanize]
9
9
  # @param client_id [Integer]
@@ -6,7 +6,7 @@ require_relative 'post_url_parser'
6
6
  module VkMusic
7
7
  module Utility
8
8
  # Guess type of method to use based on string data
9
- class DataTypeGuesser
9
+ module DataTypeGuesser
10
10
  # End of playlist URL
11
11
  PLAYLIST_POSTFIX = PlaylistUrlParser::VK_PLAYLIST_URL_POSTFIX
12
12
  public_constant :PLAYLIST_POSTFIX
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Turn human readable track length to its size in seconds
6
- class DurationParser
6
+ module DurationParser
7
7
  # @param str [String] string in format "HH:MM:SS" or something alike (+/d++ Regex selector is used)
8
8
  # @return [Integer] amount of seconds
9
9
  def self.call(str)
@@ -5,7 +5,7 @@ require_relative 'profile_id_resolver'
5
5
  module VkMusic
6
6
  module Utility
7
7
  # Get user or group id from url
8
- class LastProfilePostLoader
8
+ module LastProfilePostLoader
9
9
  # vk.com url regex
10
10
  VK_PATH = ProfileIdResolver::VK_PATH
11
11
  private_constant :VK_PATH
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Link decoding utilities
6
- class LinkDecoder
6
+ module LinkDecoder
7
7
  # JS code which creates function to unmask audio URL.
8
8
  JS_CODE = <<~HEREDOC
9
9
  function vk_unmask_link(link, vk_id) {
@@ -96,9 +96,10 @@ module VkMusic
96
96
  # @param client_id [Integer] ID of user which got this link. ID is required for decoding.
97
97
  # @return [String?] audio download URL, which can be used only from current IP.
98
98
  def self.call(link, client_id)
99
+ VkMusic.log.debug('LinkDecoder') { "Unmasking link `#{link}` with client id #{client_id}" }
99
100
  @@js_context.call('vk_unmask_link', link, client_id)
100
- rescue StandardError
101
- VkMusic.log.warn('LinkDecoder') { "Failed to decode link: #{link}" }
101
+ rescue StandardError => e
102
+ VkMusic.log.warn('LinkDecoder') { "Failed to decode link `#{link}`: #{e.full_message}" }
102
103
  nil
103
104
  end
104
105
  end
@@ -3,11 +3,11 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Read inner of text-childrens of +Nokogiri::XML::Node+ node
6
- class NodeTextChildrenReader
6
+ module NodeTextChildrenReader
7
7
  # @param node [Nokogiri::XML::Node]
8
8
  # @return [String]
9
9
  def self.call(node)
10
- node.children.select(&:text?).map(&:text).join('').strip
10
+ node.children.select(&:text?).map(&:text).join.strip
11
11
  end
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load playlist audios
6
- class PlaylistLoader
6
+ module PlaylistLoader
7
7
  # @param agent [Mechanize]
8
8
  # @param client_id [Integer]
9
9
  # @param owner_id [Integer]
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Read inner of text-childrens of +Nokogiri::XML::Node+ node
6
- class PlaylistNodeParser
6
+ module PlaylistNodeParser
7
7
  # @param node [Nokogiri::XML::Node]
8
8
  # @return [Playlist]
9
9
  def self.call(node)
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load sections into playlist
6
- class PlaylistSectionLoader
6
+ module PlaylistSectionLoader
7
7
  # @param agent [Mechanize]
8
8
  # @param client_id [Integer]
9
9
  # @param owner_id [Integer]
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Read inner of text-childrens of +Nokogiri::XML::Node+ node
6
- class PlaylistUrlParser
6
+ module PlaylistUrlParser
7
7
  # Regular expression to parse playlist link. Oh my, it is so big
8
8
  VK_PLAYLIST_URL_POSTFIX = %r{
9
9
  .* # Garbage
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load wall audios
6
- class PostLoader
6
+ module PostLoader
7
7
  # @param agent [Mechanize]
8
8
  # @param client_id [Integer]
9
9
  # @param owner_id [Integer]
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load wall audios
6
- class PostUrlParser
6
+ module PostUrlParser
7
7
  # Regex for post URL
8
8
  POST_POSTFIX = /.*wall(-?\d+)_(\d+)/.freeze
9
9
  public_constant :POST_POSTFIX
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Get user or group id from url
6
- class ProfileIdResolver
6
+ module ProfileIdResolver
7
7
  # vk.com url regex
8
8
  VK_PATH = %r{(?:https?://)?(?:vk\.com/)?([^/?&]+)}.freeze
9
9
  public_constant :VK_PATH
@@ -3,7 +3,7 @@
3
3
  module VkMusic
4
4
  module Utility
5
5
  # Load wall audios
6
- class WallLoader
6
+ module WallLoader
7
7
  # @param agent [Mechanize]
8
8
  # @param client_id [Integer]
9
9
  # @param owner_id [Integer]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module VkMusic
4
4
  # Library version.
5
- VERSION = '4.0.1'
5
+ VERSION = '4.0.2'
6
6
  public_constant :VERSION
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vk_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fizvlad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-29 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs