vk_music 4.0.1 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +31 -27
  3. data/README.md +8 -0
  4. data/lib/vk_music/audio.rb +6 -5
  5. data/lib/vk_music/client.rb +13 -7
  6. data/lib/vk_music/request/artist.rb +24 -0
  7. data/lib/vk_music/request/{audios.rb → audios_reload.rb} +0 -0
  8. data/lib/vk_music/utility/artist_loader.rb +17 -0
  9. data/lib/vk_music/utility/artist_url_parser.rb +22 -0
  10. data/lib/vk_music/utility/audio_data_parser.rb +3 -3
  11. data/lib/vk_music/utility/audio_items_parser.rb +2 -2
  12. data/lib/vk_music/utility/audio_node_parser.rb +1 -1
  13. data/lib/vk_music/utility/audios_from_ids_loader.rb +1 -1
  14. data/lib/vk_music/utility/audios_ids_getter.rb +1 -1
  15. data/lib/vk_music/utility/audios_loader.rb +1 -1
  16. data/lib/vk_music/utility/data_type_guesser.rb +7 -1
  17. data/lib/vk_music/utility/duration_parser.rb +1 -1
  18. data/lib/vk_music/utility/last_profile_post_loader.rb +1 -1
  19. data/lib/vk_music/utility/link_decoder.rb +4 -3
  20. data/lib/vk_music/utility/node_text_children_reader.rb +2 -2
  21. data/lib/vk_music/utility/playlist_loader.rb +1 -1
  22. data/lib/vk_music/utility/playlist_node_parser.rb +1 -1
  23. data/lib/vk_music/utility/playlist_section_loader.rb +1 -1
  24. data/lib/vk_music/utility/playlist_url_parser.rb +1 -1
  25. data/lib/vk_music/utility/post_loader.rb +1 -1
  26. data/lib/vk_music/utility/post_url_parser.rb +1 -1
  27. data/lib/vk_music/utility/profile_id_resolver.rb +1 -1
  28. data/lib/vk_music/utility/wall_loader.rb +1 -1
  29. data/lib/vk_music/version.rb +1 -1
  30. data/lib/vk_music/web_parser/artist.rb +16 -0
  31. data/lib/vk_music/web_parser/{audios.rb → audios_reload.rb} +0 -0
  32. data/lib/vk_music/web_parser/profile.rb +5 -1
  33. metadata +9 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a54709405afad78ce1cfc55e5487ecb55d8a7930e3ef511997175eb01995c9a
4
- data.tar.gz: dc49da61941078903e7b3da469631ba7d4eb266260ceed882a1b811e11d3ddaf
3
+ metadata.gz: c96600db101ef3b36aae086473d7954009ee3cd2df78e3c0fb00e17274c9375f
4
+ data.tar.gz: 957c1b36785ffdd1f45d772d4a1fa963bf4c9f874947f5f241445801101241a6
5
5
  SHA512:
6
- metadata.gz: dc27e9b56575d82481157b0cbde9d4ad742fd002f117601c8b8461422cb956bd18654f477499459480c1b298f768452ff01586017a0121865b8cc446feb1c444
7
- data.tar.gz: 21a10dc20607098e432f9da31172c74d83f59b2e2cb41879d9aaaa25f3907c3bffbbc2440195f121178a5d349aed7f7f69cf7ccf1f8913d8cf82920f32012e94
6
+ metadata.gz: 07add466eea5a3c516d5b0e9ed968ced90ad5b09077aec19bc4c69f29eeb9894cad9ce174910f323b139daf47bda7b7185664a8e683933210717b75ab0da90c0
7
+ data.tar.gz: ba17cb06417c52cbcd45c7204ae36d6a83b76ab6173a2215c0062a7873ccd997eae145a96e397d305258568bbfece837c9186afa7f0789e18b5e0f5543cb10df
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vk_music (4.0.1)
4
+ vk_music (4.1.2)
5
5
  execjs (~> 2.7)
6
6
  json (~> 2.3)
7
7
  logger (~> 1.4)
@@ -16,9 +16,10 @@ GEM
16
16
  ast (2.4.1)
17
17
  byebug (11.1.3)
18
18
  coderay (1.1.3)
19
- crack (0.4.4)
19
+ crack (0.4.5)
20
+ rexml
20
21
  diff-lcs (1.4.4)
21
- docile (1.3.2)
22
+ docile (1.3.4)
22
23
  domain_name (0.5.20190701)
23
24
  unf (>= 0.0.5, < 1.0.0)
24
25
  dotenv (2.7.6)
@@ -26,9 +27,9 @@ GEM
26
27
  hashdiff (1.0.1)
27
28
  http-cookie (1.0.3)
28
29
  domain_name (~> 0.5)
29
- json (2.3.1)
30
- logger (1.4.2)
31
- mechanize (2.7.6)
30
+ json (2.5.1)
31
+ logger (1.4.3)
32
+ mechanize (2.7.7)
32
33
  domain_name (~> 0.5, >= 0.5.1)
33
34
  http-cookie (~> 1.0)
34
35
  mime-types (>= 1.17.2)
@@ -36,72 +37,75 @@ GEM
36
37
  net-http-persistent (>= 2.5.2)
37
38
  nokogiri (~> 1.6)
38
39
  ntlm-http (~> 0.1, >= 0.1.1)
40
+ webrick (~> 1.7)
39
41
  webrobots (>= 0.0.9, < 0.2)
40
42
  method_source (1.0.0)
41
43
  mime-types (3.3.1)
42
44
  mime-types-data (~> 3.2015)
43
45
  mime-types-data (3.2020.1104)
44
- mini_portile2 (2.4.0)
45
46
  net-http-digest_auth (1.4.1)
46
47
  net-http-persistent (2.9.4)
47
- nokogiri (1.10.10)
48
- mini_portile2 (~> 2.4.0)
48
+ nokogiri (1.11.1-x86_64-linux)
49
+ racc (~> 1.4)
49
50
  ntlm-http (0.1.1)
50
- parallel (1.19.2)
51
- parser (2.7.2.0)
51
+ parallel (1.20.1)
52
+ parser (3.0.0.0)
52
53
  ast (~> 2.4.1)
53
54
  pry (0.13.1)
54
55
  coderay (~> 1.1)
55
56
  method_source (~> 1.0)
56
57
  public_suffix (4.0.6)
58
+ racc (1.5.2)
57
59
  rainbow (3.0.0)
58
- rake (13.0.1)
59
- regexp_parser (1.8.2)
60
+ rake (13.0.3)
61
+ regexp_parser (2.0.3)
60
62
  rexml (3.2.4)
61
63
  rspec (3.10.0)
62
64
  rspec-core (~> 3.10.0)
63
65
  rspec-expectations (~> 3.10.0)
64
66
  rspec-mocks (~> 3.10.0)
65
- rspec-core (3.10.0)
67
+ rspec-core (3.10.1)
66
68
  rspec-support (~> 3.10.0)
67
- rspec-expectations (3.10.0)
69
+ rspec-expectations (3.10.1)
68
70
  diff-lcs (>= 1.2.0, < 2.0)
69
71
  rspec-support (~> 3.10.0)
70
- rspec-mocks (3.10.0)
72
+ rspec-mocks (3.10.1)
71
73
  diff-lcs (>= 1.2.0, < 2.0)
72
74
  rspec-support (~> 3.10.0)
73
- rspec-support (3.10.0)
74
- rubocop (1.2.0)
75
+ rspec-support (3.10.1)
76
+ rubocop (1.7.0)
75
77
  parallel (~> 1.10)
76
78
  parser (>= 2.7.1.5)
77
79
  rainbow (>= 2.2.2, < 4.0)
78
- regexp_parser (>= 1.8)
80
+ regexp_parser (>= 1.8, < 3.0)
79
81
  rexml
80
- rubocop-ast (>= 1.0.1)
82
+ rubocop-ast (>= 1.2.0, < 2.0)
81
83
  ruby-progressbar (~> 1.7)
82
84
  unicode-display_width (>= 1.4.0, < 2.0)
83
- rubocop-ast (1.1.1)
85
+ rubocop-ast (1.4.0)
84
86
  parser (>= 2.7.1.5)
85
- ruby-progressbar (1.10.1)
86
- simplecov (0.19.1)
87
+ ruby-progressbar (1.11.0)
88
+ simplecov (0.21.1)
87
89
  docile (~> 1.1)
88
90
  simplecov-html (~> 0.11)
91
+ simplecov_json_formatter (~> 0.1)
89
92
  simplecov-html (0.12.3)
93
+ simplecov_json_formatter (0.1.2)
90
94
  unf (0.1.4)
91
95
  unf_ext
92
96
  unf_ext (0.0.7.7)
93
97
  unicode-display_width (1.7.0)
94
98
  vcr (6.0.0)
95
- webmock (3.9.5)
99
+ webmock (3.11.0)
96
100
  addressable (>= 2.3.6)
97
101
  crack (>= 0.3.2)
98
102
  hashdiff (>= 0.4.0, < 2.0.0)
103
+ webrick (1.7.0)
99
104
  webrobots (0.1.2)
100
- yard (0.9.25)
105
+ yard (0.9.26)
101
106
 
102
107
  PLATFORMS
103
108
  ruby
104
- x64-mingw32
105
109
 
106
110
  DEPENDENCIES
107
111
  byebug
@@ -117,4 +121,4 @@ DEPENDENCIES
117
121
  yard
118
122
 
119
123
  BUNDLED WITH
120
- 2.1.4
124
+ 2.2.4
data/README.md CHANGED
@@ -81,6 +81,14 @@ You can load up to 10 audios attached to some post. Those audios will be returne
81
81
  audios = client.post(url: "link")
82
82
  ```
83
83
 
84
+ ### Artist audios
85
+
86
+ You can get up to 50 top audios of particular artist:
87
+
88
+ ```ruby
89
+ audios = client.artist(url: "link")
90
+ ```
91
+
84
92
  ### Getting audio URL
85
93
 
86
94
  To get audio URL you should go through following chain:
@@ -90,13 +90,14 @@ module VkMusic
90
90
  # @param [Audio, Array(owner_id, audio_id, secret1, secret2), String]
91
91
  # @return [Boolean] id-based comparison
92
92
  def id_matches?(data)
93
- data_id = case data
94
- when Array then data.join('_')
95
- when Audio then data.full_id
96
- when String then data.strip
93
+ data_owner_id, data_id = case data
94
+ when Audio then [data.owner_id, data.id]
95
+ when Array then data.first(2).reverse.map(&:to_i)
96
+ when String then data.split('_').first(2).map(&:to_i)
97
+ else return false
97
98
  end
98
99
 
99
- full_id == data_id
100
+ owner_id == data_owner_id && id == data_id
100
101
  end
101
102
 
102
103
  # @return [String] pretty-printed audio name
@@ -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:
@@ -131,7 +125,7 @@ module VkMusic
131
125
  Utility::WallLoader.call(agent, id, owner_id, post_id)
132
126
  end
133
127
 
134
- # Get audios attached to post. Specify either +url+ or +(owner_id,post_id)+.
128
+ # Get audios attached to post. Specify either +url+ or +(owner_id,post_id)+
135
129
  # @param url [String]
136
130
  # @param owner_id [Integer]
137
131
  # @param post_id [Integer]
@@ -144,6 +138,18 @@ module VkMusic
144
138
  Utility::PostLoader.call(agent, id, owner_id, post_id)
145
139
  end
146
140
 
141
+ # Artist top audios. Specify either +url+ or +name+ of the artist
142
+ # @param url [String]
143
+ # @param name [String]
144
+ # @return [Array<Audio>] array of audios attached to post
145
+ def artist(url: nil, name: nil)
146
+ name = Utility::ArtistUrlParser.call(url) if url
147
+
148
+ return [] if name.nil? || name.empty?
149
+
150
+ Utility::ArtistLoader.call(agent, id, name)
151
+ end
152
+
147
153
  # Get audios with download URLs by their IDs and secrets
148
154
  # @param args [Array<Audio, (owner_id, audio_id, secret_1, secret_2),
149
155
  # "#{owner_id}_#{id}_#{secret_1}_#{secret_2}">]
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VkMusic
4
+ module Request
5
+ # Artist audios page request
6
+ class Artist < Base
7
+ # Initialize new request
8
+ # @param name [String]
9
+ # @param client_id [Integer]
10
+ def initialize(name, client_id)
11
+ @client_id = client_id
12
+ super("#{VK_ROOT}/artist/#{name}/top_audios", {}, 'GET', {})
13
+ end
14
+
15
+ def_delegators :@parser, :audios
16
+
17
+ private
18
+
19
+ def after_call
20
+ @parser = WebParser::Artist.new(@response, client_id: @client_id)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VkMusic
4
+ module Utility
5
+ # Load artist top audios
6
+ module ArtistLoader
7
+ # @param agent [Mechanize]
8
+ # @param client_id [Integer]
9
+ # @param name [String]
10
+ # @return [Array<Audio>]
11
+ def self.call(agent, client_id, name)
12
+ page = Request::Artist.new(name, client_id).call(agent)
13
+ page.audios
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VkMusic
4
+ module Utility
5
+ # Artist URL parser
6
+ module ArtistUrlParser
7
+ # Regex for artist URL
8
+ ARTIST_POSTFIX = %r{.*artist/([\w.\-~]+)}.freeze
9
+ public_constant :ARTIST_POSTFIX
10
+
11
+ # Get artist name based on provided URL
12
+
13
+ # @param url [String]
14
+ # @return [String?]
15
+ def self.call(url)
16
+ url.match(ARTIST_POSTFIX)&.captures&.first
17
+ rescue StandardError
18
+ nil
19
+ end
20
+ end
21
+ end
22
+ end
@@ -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: url_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]
@@ -1,16 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'playlist_url_parser'
4
+ require_relative 'artist_url_parser'
4
5
  require_relative 'post_url_parser'
5
6
 
6
7
  module VkMusic
7
8
  module Utility
8
9
  # Guess type of method to use based on string data
9
- class DataTypeGuesser
10
+ module DataTypeGuesser
10
11
  # End of playlist URL
11
12
  PLAYLIST_POSTFIX = PlaylistUrlParser::VK_PLAYLIST_URL_POSTFIX
12
13
  public_constant :PLAYLIST_POSTFIX
13
14
 
15
+ # Artist URL postfix
16
+ ARTIST_POSTFIX = ArtistUrlParser::ARTIST_POSTFIX
17
+ public_constant :ARTIST_POSTFIX
18
+
14
19
  # End of post URL
15
20
  POST_POSTFIX = PostUrlParser::POST_POSTFIX
16
21
  public_constant :POST_POSTFIX
@@ -32,6 +37,7 @@ module VkMusic
32
37
  def self.call(data)
33
38
  case data
34
39
  when PLAYLIST_POSTFIX then :playlist
40
+ when ARTIST_POSTFIX then :artist
35
41
  when POST_POSTFIX then :post
36
42
  when WALL_POSTFIX then :wall
37
43
  when AUDIOS_POSTFIX, PROFILE_URL then :audios
@@ -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.1.2'
6
6
  public_constant :VERSION
7
7
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VkMusic
4
+ module WebParser
5
+ # Artist top audios web page
6
+ class Artist < Base
7
+ # @return [Array<Audio>]
8
+ def audios
9
+ audio_section = node.at_css('.AudioSection.AudioSection__artist_audios')
10
+ return [] if audio_section.nil?
11
+
12
+ Utility::AudioItemsParser.call(audio_section, @client_id)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -12,9 +12,13 @@ module VkMusic
12
12
  POST_ANCHOR_NAME_REGEX = /post(-?\d+)_(\d+)/.freeze
13
13
  private_constant :POST_ANCHOR_NAME_REGEX
14
14
 
15
+ # CSS selector for link in basis
16
+ BASIS_LINK_SELECTOR = '.basisProfile a,.basisGroup a,.BasisProfile a,.BasisGroup a'
17
+ private_constant :BASIS_LINK_SELECTOR
18
+
15
19
  # Profile id
16
20
  def id
17
- link = node.link_with(href: ID_CONTAINING_HREF, css: '.basisProfile a,.basisGroup a')
21
+ link = node.link_with(href: ID_CONTAINING_HREF, css: BASIS_LINK_SELECTOR)
18
22
  return unless link
19
23
 
20
24
  Integer(link.href.match(ID_CONTAINING_HREF).captures.first, 10)
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.1.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: 2021-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -103,7 +103,8 @@ files:
103
103
  - lib/vk_music/client.rb
104
104
  - lib/vk_music/playlist.rb
105
105
  - lib/vk_music/request.rb
106
- - lib/vk_music/request/audios.rb
106
+ - lib/vk_music/request/artist.rb
107
+ - lib/vk_music/request/audios_reload.rb
107
108
  - lib/vk_music/request/base.rb
108
109
  - lib/vk_music/request/login.rb
109
110
  - lib/vk_music/request/my_page.rb
@@ -114,6 +115,8 @@ files:
114
115
  - lib/vk_music/request/search.rb
115
116
  - lib/vk_music/request/wall_section.rb
116
117
  - lib/vk_music/utility.rb
118
+ - lib/vk_music/utility/artist_loader.rb
119
+ - lib/vk_music/utility/artist_url_parser.rb
117
120
  - lib/vk_music/utility/audio_data_parser.rb
118
121
  - lib/vk_music/utility/audio_items_parser.rb
119
122
  - lib/vk_music/utility/audio_node_parser.rb
@@ -135,7 +138,8 @@ files:
135
138
  - lib/vk_music/utility/wall_loader.rb
136
139
  - lib/vk_music/version.rb
137
140
  - lib/vk_music/web_parser.rb
138
- - lib/vk_music/web_parser/audios.rb
141
+ - lib/vk_music/web_parser/artist.rb
142
+ - lib/vk_music/web_parser/audios_reload.rb
139
143
  - lib/vk_music/web_parser/base.rb
140
144
  - lib/vk_music/web_parser/login.rb
141
145
  - lib/vk_music/web_parser/my_page.rb
@@ -168,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
172
  - !ruby/object:Gem::Version
169
173
  version: '0'
170
174
  requirements: []
171
- rubygems_version: 3.1.2
175
+ rubygems_version: 3.2.4
172
176
  signing_key:
173
177
  specification_version: 4
174
178
  summary: A library to work with audios on popular Russian social network