vk_music 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vk_music/client.rb +2 -0
- data/lib/vk_music/constants.rb +2 -1
- data/test/test_get_id.rb +10 -0
- data/test/test_user_or_group_audios.rb +10 -0
- data/vk_music.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d96b191b936962a943c634a8a1667c01a8e8e8e59c7fbc6aba7f8eb4af2d0747
|
4
|
+
data.tar.gz: 946947c3481a6ddf163697d6b50fcae9bd6f8f366e91520078bfc72695494dac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83f8555922971eec5df0b8460871a6138cbcbc7620390b501f36480bf2473ff11dc5e7511e3bd631e6a3de242f2fbae8c89d4743a57d5a9e5ac4eb3c3d231b0a
|
7
|
+
data.tar.gz: 3ed0e50c05292ed49dcd31d344b1ed757631e85981abf256b6a0e8850b280322289e45865e64c96f817fb147865e4b885e55f61be2a8aeff94c36ea6b169a17d
|
data/lib/vk_music/client.rb
CHANGED
@@ -117,6 +117,8 @@ module VkMusic
|
|
117
117
|
get_id(path) # Recursive call
|
118
118
|
when VK_ID_REGEX
|
119
119
|
str
|
120
|
+
when VK_AUDIOS_REGEX
|
121
|
+
str.match(/-?\d+/).to_s # Numbers with sigh
|
120
122
|
when VK_PREFIXED_ID_REGEX
|
121
123
|
id = str.match(/\d+/).to_s # Just numbers. Sign needed
|
122
124
|
id = "-#{id}" unless str.start_with?("id")
|
data/lib/vk_music/constants.rb
CHANGED
@@ -21,9 +21,10 @@ module VkMusic
|
|
21
21
|
|
22
22
|
|
23
23
|
VK_ID_REGEX = /^-?\d+$/
|
24
|
+
VK_AUDIOS_REGEX = /^audios-?\d+$/
|
24
25
|
VK_PREFIXED_ID_REGEX = /^(?:id|club|group|public|event)\d+$/ # TODO: Rework. This one is REALLY dirty. Not quite sure every page can return correct id with this regex
|
25
26
|
VK_CUSTOM_ID_REGEX = /^\w+$/
|
26
|
-
VK_URL_REGEX = /(?:https?:\/\/)?(?:m\.|www\.)?vk\.com\/(\w+)/
|
27
|
+
VK_URL_REGEX = /(?:https?:\/\/)?(?:m\.|www\.)?vk\.com\/([\w\-]+)/
|
27
28
|
|
28
29
|
VK_HREF_ID_CONTAINING_REGEX = /(?:audios|photo|write|owner_id=|friends\?id=)-?\d+/
|
29
30
|
|
data/test/test_get_id.rb
CHANGED
@@ -35,6 +35,11 @@ class TestVkMusic < MiniTest::Test
|
|
35
35
|
assert_equal("51842614", id, "Ids don't match")
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_user_audios
|
39
|
+
id = CLIENT.get_id("https://vk.com/audios51842614")
|
40
|
+
assert_equal("51842614", id, "Ids don't match")
|
41
|
+
end
|
42
|
+
|
38
43
|
|
39
44
|
def test_group_link_with_id
|
40
45
|
id = CLIENT.get_id("https://vk.com/public39786657")
|
@@ -61,6 +66,11 @@ class TestVkMusic < MiniTest::Test
|
|
61
66
|
assert_equal("-39786657", id, "Ids don't match")
|
62
67
|
end
|
63
68
|
|
69
|
+
def test_group_audios
|
70
|
+
id = CLIENT.get_id("https://vk.com/audios-39786657")
|
71
|
+
assert_equal("-39786657", id, "Ids don't match")
|
72
|
+
end
|
73
|
+
|
64
74
|
|
65
75
|
def test_user_deleted
|
66
76
|
id = CLIENT.get_id("https://vk.com/id245722576")
|
@@ -17,6 +17,11 @@ class TestVkMusic < MiniTest::Test
|
|
17
17
|
assert_instance_of(VkMusic::Audio, pl[0], "Results must be of class Audio")
|
18
18
|
refute_empty(pl[0].url, "Audio must have download url")
|
19
19
|
end
|
20
|
+
|
21
|
+
def test_user_by_audios_url
|
22
|
+
pl = CLIENT.get_audios("https://m.vk.com/audios8024985")
|
23
|
+
refute_empty(pl, "This user got audios")
|
24
|
+
end
|
20
25
|
|
21
26
|
def test_incorrect_id
|
22
27
|
assert_raises(VkMusic::AudiosParseError) do
|
@@ -64,4 +69,9 @@ class TestVkMusic < MiniTest::Test
|
|
64
69
|
refute_empty(pl, "This group got audios")
|
65
70
|
end
|
66
71
|
|
72
|
+
def test_group_by_audios_url
|
73
|
+
pl = CLIENT.get_audios("https://m.vk.com/audios-39786657")
|
74
|
+
refute_empty(pl, "This group got audios")
|
75
|
+
end
|
76
|
+
|
67
77
|
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.
|
5
|
+
s.version = "1.0.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: 1.0.
|
4
|
+
version: 1.0.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-07-
|
11
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|