vk_music 1.0.2 → 1.1.0

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: d96b191b936962a943c634a8a1667c01a8e8e8e59c7fbc6aba7f8eb4af2d0747
4
- data.tar.gz: 946947c3481a6ddf163697d6b50fcae9bd6f8f366e91520078bfc72695494dac
3
+ metadata.gz: 3ccf9ed379a89eda14ad649e19b7b5626045d6d348d4bdb0855155ab83cae752
4
+ data.tar.gz: de7cd8866f59df7bea26f5cffa29900361d70e3559704b26d93928b657172d66
5
5
  SHA512:
6
- metadata.gz: 83f8555922971eec5df0b8460871a6138cbcbc7620390b501f36480bf2473ff11dc5e7511e3bd631e6a3de242f2fbae8c89d4743a57d5a9e5ac4eb3c3d231b0a
7
- data.tar.gz: 3ed0e50c05292ed49dcd31d344b1ed757631e85981abf256b6a0e8850b280322289e45865e64c96f817fb147865e4b885e55f61be2a8aeff94c36ea6b169a17d
6
+ metadata.gz: 1d4ebee0fb3e0cd2a38fc077de818e167c6f154a3c065ce524359f1c2dd9e3813dfbeb53ebcedf68e91d401f0be90647a851a97a527ae6d985364105a41f363f
7
+ data.tar.gz: 41122b9abf3f900c5ea56b063368f1e902eefc7afa939f3ea2febd18fd5978394ac18f6ade0abd7446aa064d95ddc73859f1c15f3a9144a34c07a5ad7c280149
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  ## Dependencies
7
7
 
8
8
  * [mechanize](https://github.com/sparklemotion/mechanize "mechanize") (interaction with website)
9
- * [duktape](https://github.com/judofyr/duktape.rb "duktape") (JS interpreter)
9
+ * [execjs](https://github.com/rails/execjs "execjs") (JS interpreter)
10
10
 
11
11
 
12
12
  ## Installation
@@ -65,3 +65,9 @@ You can set how many audios you actually need as well:
65
65
  ```ruby
66
66
  user_playlist = client.get_audios("8024985", 10)
67
67
  ```
68
+
69
+ ### Audios from post
70
+ You can load up to 10 audios attached to some post. Those audios will be returned as array:
71
+ ```ruby
72
+ audios = client.get_audios_from_post("https://vk.com/wall-4790861_5453")
73
+ ```
data/Rakefile CHANGED
@@ -24,13 +24,13 @@ task :test do
24
24
  password = STDIN.gets.chomp
25
25
  puts
26
26
 
27
- print "Path to SSL certificate (leave empty if there is no troubles with SSL):"
27
+ print "Path to SSL certificate (leave empty if there is no troubles with SSL): "
28
28
  ssl_cert_path = STDIN.gets.chomp
29
29
  puts
30
- ENV["SSL_CERT_FILE"] = ssl_cert_path
30
+ ENV["SSL_CERT_FILE"] = ssl_cert_path unless ssl_cert_path.empty?
31
31
 
32
32
  Dir[ "test/test*.rb" ].each do |file|
33
33
  puts "\n\nRunning #{file}:"
34
34
  ruby "-w #{file} '#{username}' '#{password}'"
35
35
  end
36
- end
36
+ end
@@ -4,11 +4,28 @@ module VkMusic
4
4
 
5
5
  class Audio
6
6
 
7
- attr_reader :id, :owner_id, :artist, :title, :duration, :url, :url_encoded
7
+ attr_reader :id, :owner_id, :secret_1, :secret_2, :artist, :title, :duration, :url, :url_encoded
8
+
9
+ def update_url(options)
10
+ raise ArgumentError, "options hash must be provided", caller unless options.class == Hash
11
+ if !options[:url].to_s.empty?
12
+ @url_encoded = ""
13
+ @url = options[:url].to_s
14
+ elsif !options[:url].to_s.empty? && options[:client_id]
15
+ @url_encoded = options[:url_encoded].to_s
16
+ @url = VkMusic.unmask_link(options[:url_encoded], options[:client_id])
17
+ else
18
+ raise ArgumentError, "You should either provide :url or :url_encoded and :client_id", caller
19
+ end
20
+ end
8
21
 
9
22
  def to_s
10
23
  "#{@artist} - #{@title} [#{Utility.format_seconds(@duration)}]"
11
24
  end
25
+
26
+ def pp
27
+ "#{to_s} (Got decoded URL: #{@url ? "yes" : "no"}, able to get URL from VK: #{@id && @owner_id && @secret_1 && @secret_2 ? "yes" : "no"})"
28
+ end
12
29
 
13
30
  def initialize(options)
14
31
  # Arguments check
@@ -20,6 +37,8 @@ module VkMusic
20
37
  # Setting up attributes
21
38
  @id = options[:id].to_s
22
39
  @owner_id = options[:owner_id].to_s
40
+ @secret_1 = options[:secret_1].to_s
41
+ @secret_2 = options[:secret_2].to_s
23
42
  @artist = options[:artist].to_s
24
43
  @title = options[:title].to_s
25
44
  @duration = options[:duration].to_i
@@ -47,9 +66,13 @@ module VkMusic
47
66
  url_encoded = data[2]
48
67
  url_encoded = nil if url_encoded == ""
49
68
 
69
+ secrets = data[13].split("/")
70
+
50
71
  new({
51
72
  :id => data[0],
52
73
  :owner_id => data[1],
74
+ :secret_1 => secrets[3],
75
+ :secret_2 => secrets[5],
53
76
  :artist => CGI.unescapeHTML(data[4]),
54
77
  :title => CGI.unescapeHTML(data[3]),
55
78
  :duration => data[5],
@@ -60,4 +83,4 @@ module VkMusic
60
83
 
61
84
  end
62
85
 
63
- end
86
+ end
@@ -23,7 +23,7 @@ module VkMusic
23
23
 
24
24
  def find_audio(query)
25
25
  uri = URI(VK_URL[:audios])
26
- uri.query = URI.encode_www_form({ "act" => "search", "q" => query.to_s })
26
+ uri.query = Utility.hash_to_params({ "act" => "search", "q" => query.to_s })
27
27
  load_audios_from_page(uri)
28
28
  end
29
29
 
@@ -76,8 +76,8 @@ module VkMusic
76
76
  end
77
77
 
78
78
  def get_audios(obj, up_to = nil)
79
- if up_to && up_to > 100 && defined?(Warning.warn)
80
- Warning.warn("Current implementation of method VkMusic::Client#get_audios is only able to load first 100 audios from user page.\n")
79
+ if up_to && up_to > 100
80
+ Utility.warn("Current implementation of method VkMusic::Client#get_audios is only able to load first 100 audios from user page.")
81
81
  end
82
82
  # NOTICE: this method is only able to load first 100 audios
83
83
  # NOTICE: it is possible to download 50 audios per request on "https://m.vk.com/audios#{owner_id}?offset=#{offset}", so it will cost A LOT to download all of audios (up to 200 requests).
@@ -88,17 +88,20 @@ module VkMusic
88
88
 
89
89
  # Trying to parse out audios
90
90
  begin
91
- first_json = load_playlist_json_section(id: id.to_s, playlist_id: -1, offset: 0)
91
+ first_json = load_playlist_json_section(id.to_s, -1, 0)
92
92
  first_data = first_json["data"][0]
93
- first_data_audios = load_audios_from_data(first_data)
93
+ first_data_audios = load_audios_from_data(first_data["list"])
94
94
  rescue Exception => error
95
95
  raise AudiosSectionParseError, "unable to load or parse audios section: #{error.message}", caller
96
96
  end
97
97
 
98
98
  #total_count = first_data["totalCount"] # NOTICE: not used due to restrictions described above
99
- total_count = first_data_audios.length
99
+ total_count = first_data_audios.length # Using this instead
100
+
101
+ # TODO: Loading rest
102
+
100
103
  up_to = total_count if (up_to.nil? || up_to < 0 || up_to > total_count)
101
- list = first_data_audios[0, up_to]
104
+ list = first_data_audios.first(up_to)
102
105
 
103
106
  # It turns out user audios are just playlist with id -1
104
107
  Playlist.new(list, {
@@ -109,7 +112,61 @@ module VkMusic
109
112
  :subtitle => CGI.unescapeHTML(first_data["subtitle"].to_s),
110
113
  })
111
114
  end
115
+
116
+ def get_audios_by_id(*arr)
117
+ if arr.size > 10
118
+ Utility.warn("Current implementation of method VkMusic::Client#get_audios_by_id is only able to handle first 10 audios.")
119
+ arr = arr.first(10)
120
+ end
121
+
122
+ arr.map! do |el|
123
+ case el
124
+ when Array
125
+ el.join("_")
126
+ when Audio
127
+ "#{el.owner_id}_#{el.id}_#{el.secret_1}_#{el.secret_2}"
128
+ else
129
+ el.to_s
130
+ end
131
+ end
132
+ json = load_audios_json_by_id(arr)
133
+ result = load_audios_from_data(json["data"][0].to_a)
134
+ raise ReloadAudiosParseError, "Result size don't match: excepected #{arr.size}, got #{result.size}", caller if result.size != arr.size
135
+
136
+ result
137
+ end
138
+
139
+ def get_audios_from_wall(owner_id, post_id, up_to = nil)
140
+ begin
141
+ json = load_audios_json_from_wall(owner_id, post_id)
142
+ data = json["data"][0]
143
+ no_url_audios = load_audios_from_data(data["list"])
144
+ rescue Exception => error
145
+ raise WallParseError, "Failed to parse wall from #{@owner_id}_#{post_id}. Error: #{error.message}", caller
146
+ end
147
+
148
+ up_to = no_url_audios.size if (up_to.nil? || up_to < 0 || up_to > no_url_audios.size)
149
+ no_url_audios = no_url_audios.first(up_to)
150
+
151
+ list = get_audios_by_id(*no_url_audios)
152
+
153
+ Playlist.new(list, {
154
+ :id => data["id"],
155
+ :owner_id => data["owner_id"],
156
+ :access_hash => data["access_hash"],
157
+ :title => CGI.unescapeHTML(data["title"].to_s),
158
+ :subtitle => CGI.unescapeHTML(data["subtitle"].to_s),
159
+ })
160
+ end
112
161
 
162
+ def get_audios_from_post(url)
163
+ url, owner_id, post_id = url.match(POST_URL_REGEX).to_a
164
+
165
+ amount = get_amount_of_audios_in_post(owner_id, post_id)
166
+ get_audios_from_wall(owner_id, post_id, amount).to_a
167
+ end
168
+
169
+
113
170
  def get_id(str)
114
171
  case str
115
172
  when VK_URL_REGEX
@@ -141,7 +198,19 @@ module VkMusic
141
198
  raise IdParseError, "unable to convert \"#{str}\" into id"
142
199
  end
143
200
  end
144
-
201
+
202
+ def get_amount_of_audios_in_post(owner_id, post_id)
203
+ begin
204
+ page = load_page("#{VK_URL[:wall]}#{owner_id}_#{post_id}")
205
+ result = page.css(".wi_body > .pi_medias .medias_audio").size
206
+ rescue Exception => error
207
+ raise PostParseError, "Unable to get amount of audios in post #{owner_id}_#{post_id}. Error: #{error.message}", caller
208
+ end
209
+ raise PostParseError, "Post not found: #{owner_id}_#{post_id}", caller if result == 0 && !page.css(".service_msg_error").empty?
210
+ result
211
+ end
212
+
213
+
145
214
  private
146
215
 
147
216
  # Loading pages
@@ -156,21 +225,52 @@ module VkMusic
156
225
 
157
226
  def load_playlist_page(options)
158
227
  uri = URI(VK_URL[:audios])
159
- uri.query = URI.encode_www_form({
228
+ uri.query = Utility.hash_to_params({
160
229
  "act" => "audio_playlist#{options[:owner_id]}_#{options[:id]}",
161
230
  "access_hash" => options[:access_hash].to_s,
162
231
  "offset" => options[:offset].to_i
163
232
  })
164
233
  load_page(uri)
165
234
  end
166
- def load_playlist_json_section(options)
235
+ def load_playlist_json_section(owner_id, playlist_id, offset = 0)
167
236
  uri = URI(VK_URL[:audios])
168
- uri.query = URI.encode_www_form({
237
+ uri.query = Utility.hash_to_params({
169
238
  "act" => "load_section",
170
- "owner_id" => options[:id],
171
- "playlist_id" => options[:playlist_id],
239
+ "owner_id" => owner_id,
240
+ "playlist_id" => playlist_id,
172
241
  "type" => "playlist",
173
- "offset" => options[:offset].to_i,
242
+ "offset" => offset,
243
+ "utf8" => true
244
+ })
245
+ begin
246
+ load_json(uri)
247
+ rescue Exception => error
248
+ raise AudiosSectionParseError, "unable to load or parse audios section: #{error.message}", caller
249
+ end
250
+ end
251
+
252
+ def load_audios_json_by_id(ids)
253
+ uri = URI(VK_URL[:audios])
254
+ uri.query = Utility.hash_to_params({
255
+ "act" => "reload_audio",
256
+ "ids" => ids,
257
+ "utf8" => true
258
+ })
259
+ begin
260
+ load_json(uri)
261
+ rescue Exception => error
262
+ raise AudiosSectionParseError, "unable to load or parse audios section: #{error.message}", caller
263
+ end
264
+ end
265
+
266
+ def load_audios_json_from_wall(owner_id, post_id)
267
+ uri = URI(VK_URL[:audios])
268
+ uri.query = Utility.hash_to_params({
269
+ "act" => "load_section",
270
+ "owner_id" => owner_id,
271
+ "post_id" => post_id,
272
+ "type" => "wall",
273
+ "wall_type" => "own",
174
274
  "utf8" => true
175
275
  })
176
276
  begin
@@ -187,7 +287,7 @@ module VkMusic
187
287
  page.css(".audio_item.ai_has_btn").map { |elem| Audio.from_node(elem, @id) }
188
288
  end
189
289
  def load_audios_from_data(data)
190
- data["list"].map { |audio_data| Audio.from_data_array(audio_data, @id) }
290
+ data.map { |audio_data| Audio.from_data_array(audio_data, @id) }
191
291
  end
192
292
 
193
293
 
@@ -216,4 +316,4 @@ module VkMusic
216
316
 
217
317
  end
218
318
 
219
- end
319
+ end
@@ -12,6 +12,7 @@ module VkMusic
12
12
  :audios => "https://m.vk.com/audio",
13
13
  :login => "https://m.vk.com/login",
14
14
  :login_action => "https://login.vk.com",
15
+ :wall => "https://m.vk.com/wall"
15
16
  }
16
17
 
17
18
  VK_LOGIN_FORM_NAMES = {
@@ -29,9 +30,12 @@ module VkMusic
29
30
  VK_HREF_ID_CONTAINING_REGEX = /(?:audios|photo|write|owner_id=|friends\?id=)-?\d+/
30
31
 
31
32
  # Playlist
32
- PLAYLIST_URL_REGEX = /.*audio_playlist(-?[\d]+)_([\d]+)(?:(?:(?:&access_hash=)|\/|%2F)([\da-z]+))?/
33
+ PLAYLIST_URL_REGEX = /.*audio_playlist(-?\d+)_(\d+)(?:(?:(?:&access_hash=)|\/|%2F)([\da-z]+))?/
34
+
35
+ # Post
36
+ POST_URL_REGEX = /.*wall(-?\d+)_(\d+)/
33
37
 
34
38
 
35
39
  # QUESTION: Should I move ALL the constants (string, regex etc) here? It would make code more flexible, but seems like overkill
36
40
 
37
- end
41
+ end
@@ -1,23 +1,30 @@
1
1
  module VkMusic
2
2
 
3
- class LoginError < RuntimeError
4
- # Unable to login
5
- end
6
-
7
- class PlaylistParseError < RuntimeError
8
- # Unable to find playlist or got permission error
9
- end
10
-
11
- class AudiosParseError < RuntimeError
12
- # Unable to find user/group or got permission error
13
- end
3
+ # General class for all the errors
4
+ class VkMusicError < RuntimeError; end
5
+
6
+ # Failed to login
7
+ class LoginError < VkMusicError; end
14
8
 
15
- class AudiosSectionParseError < AudiosParseError
16
- # Unable to load or parse audios section
17
- end
9
+ # Unable to parse audios from somewhere
10
+ class AudiosParseError < VkMusicError; end
11
+
12
+ # Unable to find playlist or got permission error
13
+ class PlaylistParseError < AudiosParseError; end
14
+
15
+ # Unable to load or parse audios section from json
16
+ class AudiosSectionParseError < AudiosParseError; end
17
+
18
+ # Unable to load or parse all of audios by ids
19
+ class ReloadAudiosParseError < AudiosParseError; end
18
20
 
19
- class IdParseError < AudiosParseError
20
- # Unable to convert string to id
21
- end
21
+ # Unable to convert string to id
22
+ class IdParseError < AudiosParseError; end
23
+
24
+ # Unable to parse audios from wall
25
+ class WallParseError < AudiosParseError; end
26
+
27
+ # Unable to parse audios from post
28
+ class PostParseError < AudiosParseError; end
22
29
 
23
- end
30
+ end
@@ -11,7 +11,15 @@ module VkMusic
11
11
  alias size length
12
12
 
13
13
  def to_s
14
- "#{@subtitle} - #{@title} (#{self.length} аудиозаписей)"
14
+ (@subtitle.empty? ? "" : "#{@subtitle} - ") + "#{@title} (#{self.length} аудиозаписей)"
15
+ end
16
+
17
+ def pp
18
+ "#{to_s}:\n#{@list.map(&:to_s).join("\n")}"
19
+ end
20
+
21
+ def to_a
22
+ @list.dup
15
23
  end
16
24
 
17
25
  def each(&block)
@@ -43,4 +51,4 @@ module VkMusic
43
51
 
44
52
  end
45
53
 
46
- end
54
+ end
@@ -1,3 +1,5 @@
1
+ require "cgi"
2
+
1
3
  module VkMusic
2
4
 
3
5
  module Utility
@@ -12,13 +14,37 @@ module VkMusic
12
14
  case str
13
15
  when PLAYLIST_URL_REGEX
14
16
  :playlist
17
+ when POST_URL_REGEX
18
+ :post
15
19
  when VK_URL_REGEX
16
20
  :audios
17
21
  else
18
22
  :find
19
23
  end
20
24
  end
25
+
26
+ def self.hash_to_params(hash = {})
27
+ qs = ""
28
+ hash.each_key do |key|
29
+ qs << "&" unless qs.empty?
30
+ case hash[key]
31
+ when Array
32
+ qs << CGI.escape(key.to_s) << "=" << hash[key].map { |value| CGI.escape(value.to_s) }.join(",")
33
+ else
34
+ qs << CGI.escape(key.to_s) << "=" << CGI.escape(hash[key].to_s)
35
+ end
36
+ end
37
+ qs
38
+ end
39
+
40
+ def self.warn(*args)
41
+ if defined?(Warning.warn)
42
+ Warning.warn args.join("\n")
43
+ else
44
+ STDERR.puts "Warning:", *args
45
+ end
46
+ end
21
47
 
22
48
  end
23
49
 
24
- end
50
+ end
@@ -0,0 +1,49 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/vk_music.rb"
3
+
4
+ begin
5
+ CLIENT = VkMusic::Client.new(username: ARGV[0], password: ARGV[1])
6
+ rescue VkMusic::LoginError
7
+ puts "Unable to login! Please check provided credetionals"
8
+ exit
9
+ end
10
+
11
+ class TestVkMusic < MiniTest::Test
12
+
13
+ def test_one_id
14
+ results = CLIENT.get_audios_by_id("2000202604_456242434_32f6f3df29dc8e9c71_82fbafed15ef65709b")
15
+ refute_empty(results, "There must be some music")
16
+ assert_instance_of(Array, results, "Resultmust be an Array")
17
+ assert_instance_of(VkMusic::Audio, results[0], "Results of search must be of class Audio")
18
+ refute_empty(results[0].url, "Audio must have download url")
19
+ end
20
+
21
+ def test_two_id
22
+ results = CLIENT.get_audios_by_id("2000202604_456242434_32f6f3df29dc8e9c71_82fbafed15ef65709b",
23
+ ["2000023175", "456242595", "addd832f78d7c61b6d", "b6b14f49280d4d55f0"])
24
+ assert_equal(2, results.size, "There must be 2 audios")
25
+ refute_empty(results[1].url, "Audio must have download url")
26
+ end
27
+
28
+ def test_bad_last
29
+ assert_raises(VkMusic::ReloadAudiosParseError) do
30
+ CLIENT.get_audios_by_id("2000202604_456242434_32f6f3df29dc8e9c71_82fbafed15ef65709b",
31
+ ["42", "1337", "aaaa", "aaaaaa"])
32
+ end
33
+ end
34
+
35
+ def test_bad_first
36
+ assert_raises(VkMusic::ReloadAudiosParseError) do
37
+ CLIENT.get_audios_by_id(["42", "1337", "aaaa", "aaaaaa"],
38
+ "2000202604_456242434_32f6f3df29dc8e9c71_82fbafed15ef65709b")
39
+ end
40
+ end
41
+
42
+ def test_bad_all
43
+ assert_raises(VkMusic::ReloadAudiosParseError) do
44
+ CLIENT.get_audios_by_id(["42", "1337", "aaaa", "aaaaaa"],
45
+ "123_123_123_123")
46
+ end
47
+ end
48
+
49
+ end
data/test/test_post.rb ADDED
@@ -0,0 +1,75 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/vk_music.rb"
3
+
4
+ begin
5
+ CLIENT = VkMusic::Client.new(username: ARGV[0], password: ARGV[1])
6
+ rescue VkMusic::LoginError
7
+ puts "Unable to login! Please check provided credetionals"
8
+ exit
9
+ end
10
+
11
+ class TestVkMusic < MiniTest::Test
12
+
13
+ def test_single_audio
14
+ audios = CLIENT.get_audios_from_post("https://vk.com/wall-184089233_6")
15
+ assert_instance_of(Array, audios, "Result must be of class Array")
16
+ assert_equal(1, audios.length, "This post got 1 attached audio")
17
+ assert_instance_of(VkMusic::Audio, audios[0], "Array must consist of class Audio")
18
+ refute_empty(audios[0].url, "Audio must have download url")
19
+ end
20
+
21
+ def test_no_audio
22
+ audios = CLIENT.get_audios_from_post("https://vk.com/wall-184089233_2")
23
+ assert_empty(audios, "This post got no attached audio")
24
+ end
25
+
26
+ def test_url_to_reply
27
+ audios = CLIENT.get_audios_from_post("https://m.vk.com/wall-4790861_10108")
28
+ assert_equal(1, audios.length, "Although this link redirects to comment, audios from post must be parsed")
29
+ end
30
+
31
+ def test_playlist
32
+ audios = CLIENT.get_audios_from_post("vk.com/wall-184089233_4")
33
+ assert_empty(audios, "This post got attached playlist but those audios must not be parsed")
34
+ end
35
+
36
+ def test_comments_with_audios
37
+ audios = CLIENT.get_audios_from_post("https://m.vk.com/wall-39786657_189247")
38
+ assert_equal(1, audios.length, "This post got comments with audios but those audios must not be parsed")
39
+ end
40
+
41
+ def test_repost_with_no_audios
42
+ audios = CLIENT.get_audios_from_post("https://vk.com/wall-184936953_1")
43
+ assert_empty(audios, "This post got no attached audios")
44
+ end
45
+
46
+ def test_repost_with_audios
47
+ audios = CLIENT.get_audios_from_post("https://vk.com/wall-184936953_2")
48
+ assert_equal(1, audios.length, "This repost got 1 attached audio")
49
+ refute_empty(audios[0].url, "Audio must have download url")
50
+ end
51
+
52
+ def test_repost_with_playlist
53
+ audios = CLIENT.get_audios_from_post("https://vk.com/wall-184936953_3")
54
+ assert_empty(audios, "This post got no attached audios")
55
+ end
56
+
57
+ def test_bad_url
58
+ assert_raises(VkMusic::PostParseError) do
59
+ CLIENT.get_audios_from_post("ae")
60
+ end
61
+ end
62
+
63
+ def test_nonexistent_post_1
64
+ assert_raises(VkMusic::PostParseError) do
65
+ CLIENT.get_audios_from_post("https://m.vk.com/wall-4790861_1052600000")
66
+ end
67
+ end
68
+
69
+ def test_nonexistent_post_2
70
+ assert_raises(VkMusic::PostParseError) do
71
+ CLIENT.get_audios_from_post("https://m.vk.com/wall-4790861_-1")
72
+ end
73
+ end
74
+
75
+ end
data/vk_music.gemspec CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2
2
  s.name = "vk_music"
3
3
  s.summary = "Provides interface to work with VK music via HTTP requests"
4
4
  s.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."
5
- s.version = "1.0.2"
5
+ s.version = "1.1.0"
6
6
  s.author = "Kuznetsov Vladislav"
7
7
  s.email = "fizvlad@mail.ru"
8
8
  s.homepage = "https://github.com/fizvlad/vk-music-rb"
@@ -13,7 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.license = "MIT"
14
14
 
15
15
  s.add_runtime_dependency "mechanize", "~>2.7"
16
+ s.add_runtime_dependency "net-http-persistent", "2.9.4" # Required for mechanize. Future versions cause error.
16
17
  s.add_runtime_dependency "execjs", "~>2.7"
17
18
  s.add_runtime_dependency "json", "~>2.0"
18
19
  s.add_runtime_dependency "rake", "~>12.3"
19
- end
20
+ 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: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuznetsov Vladislav
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-12 00:00:00.000000000 Z
11
+ date: 2019-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-http-persistent
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.9.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.9.4
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: execjs
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -84,9 +98,11 @@ files:
84
98
  - lib/vk_music/link_decoder.rb
85
99
  - lib/vk_music/playlist.rb
86
100
  - lib/vk_music/utility.rb
101
+ - test/test_audios_by_id.rb
87
102
  - test/test_get_id.rb
88
103
  - test/test_login.rb
89
104
  - test/test_playlist.rb
105
+ - test/test_post.rb
90
106
  - test/test_search.rb
91
107
  - test/test_user_or_group_audios.rb
92
108
  - vk_music.gemspec
@@ -109,14 +125,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
125
  - !ruby/object:Gem::Version
110
126
  version: '0'
111
127
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.6.2
128
+ rubygems_version: 3.0.4
114
129
  signing_key:
115
130
  specification_version: 4
116
131
  summary: Provides interface to work with VK music via HTTP requests
117
132
  test_files:
133
+ - test/test_audios_by_id.rb
118
134
  - test/test_get_id.rb
119
135
  - test/test_login.rb
120
136
  - test/test_playlist.rb
137
+ - test/test_post.rb
121
138
  - test/test_search.rb
122
139
  - test/test_user_or_group_audios.rb