vk_music 0.1.1 → 0.1.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: 75c5a7995475caabd8779990209db2cca18f9fb17227680e4f5925cd0fb93480
4
- data.tar.gz: afb4818c76ea686851bb191154d46a09458655d14b9253659a93edbb4e83ebba
3
+ metadata.gz: 25c3df47d7b4d786a9ee10b0eb5c899f572c58d4bc9a634cbbf70d46c93a8c36
4
+ data.tar.gz: e55054576e38c23768e31646d2ca8217f60abd85256ea0d6dd2ea9d25eee73d0
5
5
  SHA512:
6
- metadata.gz: f1c85be3faff79c6a5c6a00604c6108f76d5121384282783c4451334dd0653b9e0d9cd2e9690ed76e259c4646299283385406281e0a3c3b87e94506365ef1b9b
7
- data.tar.gz: f3caed90799b89082654ddbdb048fdbf9df791add1c7b88710a48e96a69e9ee8e6096bd53d5a631da4498738b3a6c006149af3f43aff98c73b7840998722693b
6
+ metadata.gz: bcc72c7b4e438ba08072b48d4deb7e63d69fb624487b9fada6444b087dc9d6aa3af8ed29e27ffe449573bf0929e78b31e2b6b0daf2321d59583f4a1d0aa071cd
7
+ data.tar.gz: 54066b7c151a1d3f2b29c166d67b5ba6a33a43c8824d0bdcdefd104d2f8f6efd447d94671be7d72b892721b84e0bd93d88ac89ff027298d27181209568bccc3a
@@ -1,7 +1,7 @@
1
- require_relative 'vk_music/utility.rb'
2
- require_relative 'vk_music/constants.rb'
3
- require_relative 'vk_music/exceptions.rb'
4
- require_relative 'vk_music/audio.rb'
5
- require_relative 'vk_music/link_decoder.rb'
6
- require_relative 'vk_music/playlist.rb'
7
- require_relative 'vk_music/client.rb'
1
+ require_relative "vk_music/utility.rb"
2
+ require_relative "vk_music/constants.rb"
3
+ require_relative "vk_music/exceptions.rb"
4
+ require_relative "vk_music/audio.rb"
5
+ require_relative "vk_music/link_decoder.rb"
6
+ require_relative "vk_music/playlist.rb"
7
+ require_relative "vk_music/client.rb"
@@ -28,13 +28,14 @@ module VkMusic
28
28
  end
29
29
 
30
30
  def get_playlist(url, up_to = nil)
31
- url, owner_id, id, access_hash = url.match(PLAYLIST_URL_REGEX).to_a
32
-
33
- # Load first page and get info
34
- first_page = load_playlist_page(owner_id: owner_id, id: id, access_hash: access_hash, offset: 0)
35
-
36
- # Trying to parse out essential data
31
+ # NOTICE: it is possible to use same type of requests as in get_audios method
37
32
  begin
33
+ url, owner_id, id, access_hash = url.match(PLAYLIST_URL_REGEX).to_a
34
+
35
+ # Load first page and get info
36
+ first_page = load_playlist_page(owner_id: owner_id, id: id, access_hash: access_hash, offset: 0)
37
+
38
+ # Parse out essential data
38
39
  title = first_page.at_css(".audioPlaylist__title").text.strip
39
40
  subtitle = first_page.at_css(".audioPlaylist__subtitle").text.strip
40
41
 
@@ -46,7 +47,7 @@ module VkMusic
46
47
  playlist_size = 0
47
48
  end
48
49
  rescue Exception => error
49
- raise PlaylistParseError, "unable to parse playlist page. Redirected to #{first_page.uri.to_s}. Error: #{error.message}", caller
50
+ raise PlaylistParseError, "unable to parse playlist page. Error: #{error.message}", caller
50
51
  end
51
52
  # Now we can be sure we are on correct page
52
53
 
@@ -77,6 +78,8 @@ module VkMusic
77
78
  def get_audios(id, up_to = nil)
78
79
  Warning.warn("Current implementation of method VkMusic::Client#get_audios is only able to load first 100 audios from user page.\n") if (up_to && up_to > 100)
79
80
  # NOTICE: this method is only able to load first 100 audios
81
+ # 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).
82
+ # NOTICE: it is possible to load up to 2000 audios **without url** if offset is negative
80
83
 
81
84
  # Trying to parse out audios
82
85
  begin
@@ -87,7 +90,7 @@ module VkMusic
87
90
  raise AudiosSectionParseError, "unable to load or parse audios section: #{error.message}", caller
88
91
  end
89
92
 
90
- #total_count = first_data["totalCount"] # NOTICE: not used due to restrictions dexcribed above
93
+ #total_count = first_data["totalCount"] # NOTICE: not used due to restrictions described above
91
94
  total_count = first_data_audios.length
92
95
  up_to = total_count if (up_to.nil? || up_to < 0 || up_to > total_count)
93
96
  list = first_data_audios[0, up_to]
@@ -49,4 +49,10 @@ class TestVkMusic < MiniTest::Test
49
49
  refute_empty(pl[-1].url, "Audio must have download url")
50
50
  end
51
51
 
52
+ def test_bad_url
53
+ assert_raises(VkMusic::PlaylistParseError) do
54
+ CLIENT.get_playlist("ae")
55
+ end
56
+ end
57
+
52
58
  end
@@ -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 = "0.1.1"
5
+ s.version = "0.1.2"
6
6
  s.author = "Kuznetsov Vladislav"
7
7
  s.email = "fizvlad@mail.ru"
8
8
  s.homepage = "https://github.com/fizvlad/vk-music-rb"
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: 0.1.1
4
+ version: 0.1.2
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-06-20 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize