vk_music 3.0.1 → 3.1.1

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: 2c51759b83b9c94ae99db4f957e80f9d7e071d998e171813dd33ccb1883d8d5c
4
- data.tar.gz: abd153ed90bc234046c4e38f41870fb66bc38ae390d7755cadce110b54c384bc
3
+ metadata.gz: fa5586e89dfad05d417c5b0c2466a561091c4a9383857da45fee1ee126f8b6a5
4
+ data.tar.gz: f4c788d950d1a36e25df46e7edbfe4507dc21078f35956f6503f18832c91b7c0
5
5
  SHA512:
6
- metadata.gz: f5476442c461a25f5753cc707238ba01ee9d0cd1a180be23d8d5f7d3f46439a61bfc05106c15396745a62f2a5c8da6590c1c03f83cc0f86f5d10e95026a02505
7
- data.tar.gz: 8aade904f7fe57f4c073686a9aa15173083b6ed86ec30863723573fab391daacc2a6288cb3c47fdb253d806fa3607a5c3c0ee37c152b8a38df158c2145d6ebd2
6
+ metadata.gz: 99793ea61b1020faa0290d94adfcbb9734deb1f7770a8f9fb5bd390ed686fe138d32f72ce5a4d2ebb80d120ed98af19179f6481d810aba63163f158d8fe05ab8
7
+ data.tar.gz: 0274015ac09a8189c09fdb9979c784607a08c67b4f090149e3306b73915cfd68b78c2aa729f117bf392e8bfff42e432dd303843bb7db0afe27a39f8bcd45423c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vk_music (3.0.0)
4
+ vk_music (3.1.0)
5
5
  execjs (~> 2.7)
6
6
  json (~> 2.0)
7
7
  logger (~> 1.4)
@@ -17,7 +17,7 @@ GEM
17
17
  execjs (2.7.0)
18
18
  http-cookie (1.0.3)
19
19
  domain_name (~> 0.5)
20
- json (2.2.0)
20
+ json (2.3.0)
21
21
  logger (1.4.1)
22
22
  mechanize (2.7.6)
23
23
  domain_name (~> 0.5, >= 0.5.1)
@@ -36,13 +36,15 @@ GEM
36
36
  minitest (5.13.0)
37
37
  net-http-digest_auth (1.4.1)
38
38
  net-http-persistent (2.9.4)
39
- nokogiri (1.10.7-x64-mingw32)
39
+ nokogiri (1.10.8)
40
+ mini_portile2 (~> 2.4.0)
41
+ nokogiri (1.10.8-x64-mingw32)
40
42
  mini_portile2 (~> 2.4.0)
41
43
  ntlm-http (0.1.1)
42
44
  pry (0.12.2)
43
45
  coderay (~> 1.1.0)
44
46
  method_source (~> 0.9.0)
45
- rake (10.5.0)
47
+ rake (13.0.1)
46
48
  unf (0.1.4)
47
49
  unf_ext
48
50
  unf_ext (0.0.7.6)
@@ -50,6 +52,7 @@ GEM
50
52
  yard (0.9.20)
51
53
 
52
54
  PLATFORMS
55
+ ruby
53
56
  x64-mingw32
54
57
 
55
58
  DEPENDENCIES
@@ -58,7 +61,7 @@ DEPENDENCIES
58
61
  mechanize (~> 2.7)
59
62
  minitest (~> 5.0)
60
63
  pry (~> 0.12.2)
61
- rake (~> 10.0)
64
+ rake (~> 13.0)
62
65
  vk_music!
63
66
  yard (~> 0.9)
64
67
 
data/README.md CHANGED
@@ -71,6 +71,13 @@ audios = client.post(url: "https://vk.com/wall-4790861_5453")
71
71
  urls = audios.map(&:url) # URLs for every audio
72
72
  ```
73
73
 
74
+ ### Recommended audios and etc
75
+ You can load audios from recommended sections, novices and VK charts:
76
+
77
+ ```ruby
78
+ audios = client.block(url: "https://m.vk.com/audio?act=block&block=PUlQVA8GR0R3W0tMF2teRGpJUVQPGVpfdF1YRwMGXUpkXktMF2tYUWRHS0IXDlpKZFpcVA8FFg")
79
+ ```
80
+
74
81
 
75
82
  ## Development
76
83
 
data/bin/console CHANGED
@@ -7,4 +7,18 @@ require "vk_music"
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  require "pry"
10
+
11
+ print "Login (leave this empty if no login required): "
12
+ username = STDIN.gets.chomp
13
+
14
+ unless username.empty?
15
+ print "Password: "
16
+ password = STDIN.gets.chomp
17
+ puts
18
+
19
+ $client = VkMusic::Client.new(username: username, password: password)
20
+ puts "You can now access client at $client"
21
+ end
22
+ puts
23
+
10
24
  Pry.start
@@ -196,6 +196,7 @@ module VkMusic
196
196
  end
197
197
  end
198
198
  alias_method :from_id, :get_urls
199
+
199
200
  ##
200
201
  # Update download URLs of audios.
201
202
  # @param audios [Array<Audio>]
@@ -207,6 +208,25 @@ module VkMusic
207
208
  end
208
209
  end
209
210
 
211
+ ##
212
+ # Retrieve audios from recommendations or alike pages.
213
+ # Specify either +url+ or +block_id+.
214
+ # @param url [String] URL.
215
+ # @param block_id [String] ID of block.
216
+ # @return [Array<Audio>] array of audios attached to post. Most of audios will
217
+ # already have download URLs, but there might be audios which can't be resolved.
218
+ def block(url: nil, block_id: nil)
219
+ begin
220
+ block_id = url.match(Constants::Regex::VK_BLOCK_URL).captures.first if url
221
+ rescue
222
+ raise Exceptions::ParseError
223
+ end
224
+
225
+ uri = URI(Constants::URL::VK[:audios])
226
+ uri.query = Utility.hash_to_params({ "act" => "block", "block" => block_id })
227
+ audios_from_page(uri)
228
+ end
229
+
210
230
  ##
211
231
  # @!endgroup
212
232
 
@@ -22,7 +22,7 @@ module VkMusic
22
22
  login_action: "https://login.vk.com",
23
23
  wall: "https://m.vk.com/wall",
24
24
  audio_unavailable: "https://m.vk.com/mp3/audio_api_unavailable.mp3",
25
- profile_audios: "https://m.vk.com/audios",
25
+ profile_audios: "https://m.vk.com/audios"
26
26
  }
27
27
  end
28
28
 
@@ -59,6 +59,9 @@ module VkMusic
59
59
  ##
60
60
  # Post URL regular expression #2.
61
61
  VK_WALL_URL_POSTFIX = /.*wall(-?\d+)_(\d+)/
62
+ ##
63
+ # Audios block ID
64
+ VK_BLOCK_URL = /(?:section=recoms_block&type=|act=block&block=)([a-zA-Z\d]+)/
62
65
  end
63
66
 
64
67
  ##
@@ -29,6 +29,8 @@ module VkMusic
29
29
  :playlist
30
30
  when Constants::Regex::VK_WALL_URL_POSTFIX, Constants::Regex::VK_POST_URL_POSTFIX
31
31
  :post
32
+ when Constants::Regex::VK_BLOCK_URL
33
+ :block
32
34
  when Constants::Regex::VK_URL
33
35
  :audios
34
36
  else
@@ -1,5 +1,5 @@
1
1
  module VkMusic
2
2
  ##
3
3
  # Library version.
4
- VERSION = "3.0.1"
4
+ VERSION = "3.1.1"
5
5
  end
data/vk_music.gemspec CHANGED
@@ -1,40 +1,40 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "vk_music/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "vk_music"
7
- spec.version = VkMusic::VERSION
8
- spec.authors = ["Fizvlad"]
9
- spec.email = ["fizvlad@mail.ru"]
10
-
11
- spec.summary = "Provides interface to work with VK music via HTTP requests"
12
- spec.description = "Library to work with audios on popular Russian social network vk.com. VK disabled their public API for audios, so it is now necessary to use parsers instead."
13
- spec.homepage = "https://github.com/fizvlad/vk-music-rb"
14
- spec.license = "MIT"
15
-
16
- spec.required_ruby_version = ">=2.3.1"
17
-
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/fizvlad/vk-music-rb"
21
- spec.metadata["changelog_uri"] = "https://github.com/fizvlad/vk-music-rb/releases"
22
-
23
- # Specify which files should be added to the gem when it is released.
24
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- end
28
- spec.require_paths = ["lib"]
29
-
30
- spec.add_development_dependency "bundler", "~> 2.0"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "yard", "~>0.9"
33
- spec.add_development_dependency "minitest", "~> 5.0"
34
-
35
- spec.add_runtime_dependency "logger", "~>1.4"
36
- spec.add_runtime_dependency "mechanize", "~>2.7"
37
- spec.add_runtime_dependency "net-http-persistent", "2.9.4" # Required for mechanize. Future versions cause error.
38
- spec.add_runtime_dependency "execjs", "~>2.7"
39
- spec.add_runtime_dependency "json", "~>2.0"
40
- end
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "vk_music/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "vk_music"
7
+ spec.version = VkMusic::VERSION
8
+ spec.authors = ["Fizvlad"]
9
+ spec.email = ["fizvlad@mail.ru"]
10
+
11
+ spec.summary = "Provides interface to work with VK music via HTTP requests"
12
+ spec.description = "Library to work with audios on popular Russian social network vk.com. VK disabled their public API for audios, so it is now necessary to use parsers instead."
13
+ spec.homepage = "https://github.com/fizvlad/vk-music-rb"
14
+ spec.license = "MIT"
15
+
16
+ spec.required_ruby_version = ">=2.3.1"
17
+
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/fizvlad/vk-music-rb"
21
+ spec.metadata["changelog_uri"] = "https://github.com/fizvlad/vk-music-rb/releases"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
+ spec.add_development_dependency "yard", "~>0.9"
33
+ spec.add_development_dependency "minitest", "~> 5.0"
34
+
35
+ spec.add_runtime_dependency "logger", "~>1.4"
36
+ spec.add_runtime_dependency "mechanize", "~>2.7"
37
+ spec.add_runtime_dependency "net-http-persistent", "2.9.4" # Required for mechanize. Future versions cause error.
38
+ spec.add_runtime_dependency "execjs", "~>2.7"
39
+ spec.add_runtime_dependency "json", "~>2.0"
40
+ 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: 3.0.1
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fizvlad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yard
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  requirements: []
189
- rubygems_version: 3.1.0.pre2
189
+ rubygems_version: 3.0.4
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Provides interface to work with VK music via HTTP requests