vk_music 3.1.7 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +3 -0
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/.rubocop.yml +56 -0
- data/Gemfile +38 -10
- data/Gemfile.lock +123 -70
- data/LICENSE.txt +0 -0
- data/README.md +111 -94
- data/Rakefile +12 -22
- data/bin/console +18 -24
- data/lib/vk_music.rb +32 -18
- data/lib/vk_music/audio.rb +111 -187
- data/lib/vk_music/client.rb +187 -677
- data/lib/vk_music/playlist.rb +44 -97
- data/lib/vk_music/request.rb +13 -0
- data/lib/vk_music/request/audios.rb +29 -0
- data/lib/vk_music/request/base.rb +75 -0
- data/lib/vk_music/request/login.rb +35 -0
- data/lib/vk_music/request/my_page.rb +21 -0
- data/lib/vk_music/request/playlist.rb +31 -0
- data/lib/vk_music/request/playlist_section.rb +35 -0
- data/lib/vk_music/request/post.rb +22 -0
- data/lib/vk_music/request/profile.rb +24 -0
- data/lib/vk_music/request/search.rb +34 -0
- data/lib/vk_music/request/wall_section.rb +34 -0
- data/lib/vk_music/utility.rb +8 -78
- data/lib/vk_music/utility/audio_data_parser.rb +37 -0
- data/lib/vk_music/utility/audio_items_parser.rb +18 -0
- data/lib/vk_music/utility/audio_node_parser.rb +59 -0
- data/lib/vk_music/utility/audios_from_ids_loader.rb +21 -0
- data/lib/vk_music/utility/audios_ids_getter.rb +25 -0
- data/lib/vk_music/utility/audios_loader.rb +37 -0
- data/lib/vk_music/utility/data_type_guesser.rb +43 -0
- data/lib/vk_music/utility/duration_parser.rb +17 -0
- data/lib/vk_music/utility/last_profile_post_loader.rb +26 -0
- data/lib/vk_music/utility/link_decoder.rb +106 -0
- data/lib/vk_music/utility/node_text_children_reader.rb +14 -0
- data/lib/vk_music/utility/playlist_loader.rb +30 -0
- data/lib/vk_music/utility/playlist_node_parser.rb +21 -0
- data/lib/vk_music/utility/playlist_section_loader.rb +29 -0
- data/lib/vk_music/utility/playlist_url_parser.rb +32 -0
- data/lib/vk_music/utility/post_loader.rb +23 -0
- data/lib/vk_music/utility/post_url_parser.rb +24 -0
- data/lib/vk_music/utility/profile_id_resolver.rb +51 -0
- data/lib/vk_music/utility/wall_loader.rb +25 -0
- data/lib/vk_music/version.rb +8 -5
- data/lib/vk_music/web_parser.rb +9 -0
- data/lib/vk_music/web_parser/audios.rb +20 -0
- data/lib/vk_music/web_parser/base.rb +27 -0
- data/lib/vk_music/web_parser/login.rb +13 -0
- data/lib/vk_music/web_parser/my_page.rb +19 -0
- data/lib/vk_music/web_parser/playlist.rb +33 -0
- data/lib/vk_music/web_parser/playlist_section.rb +53 -0
- data/lib/vk_music/web_parser/post.rb +15 -0
- data/lib/vk_music/web_parser/profile.rb +33 -0
- data/lib/vk_music/web_parser/search.rb +56 -0
- data/lib/vk_music/web_parser/wall_section.rb +53 -0
- data/vk_music.gemspec +36 -40
- metadata +58 -77
- data/.travis.yml +0 -7
- data/bin/setup +0 -8
- data/lib/vk_music/constants.rb +0 -78
- data/lib/vk_music/exceptions.rb +0 -21
- data/lib/vk_music/link_decoder.rb +0 -102
- data/lib/vk_music/utility/log.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8c860184e789669f3064d22a6a25e0dc37cb133334b17b8ce029cb2c937c06b
|
4
|
+
data.tar.gz: 4eb06a451e1d69e8838b8aad2423d88a0edbdf2f12b0331dba98d6fdaf636be8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928a6156a75b7724975fc81fd390f8d11a011950fc9741fea4587e8350512b3a204d63acd8bfb846e7b1543979675de3d2b21ac4217a7f5bdc3c9942f6288926
|
7
|
+
data.tar.gz: 34b8788ce3e592d390a09047bd6ac238c4182ad4d680db52aa76f6eef5327fe212cb8a28492cf46dabfb4975a9b3221b4290c15686040eae3db8e232b6cae9f7
|
data/.env.example
ADDED
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
4
|
+
# any parameters. The file can be placed either in your home
|
5
|
+
# directory or in some project directory.
|
6
|
+
#
|
7
|
+
# RuboCop will start looking for the configuration file in the directory
|
8
|
+
# where the inspected file is and continue its way up to the root directory.
|
9
|
+
#
|
10
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
11
|
+
|
12
|
+
AllCops:
|
13
|
+
TargetRubyVersion: 2.7
|
14
|
+
EnabledByDefault: true
|
15
|
+
|
16
|
+
Layout/FirstMethodParameterLineBreak:
|
17
|
+
Enabled: false
|
18
|
+
Layout/FirstMethodArgumentLineBreak:
|
19
|
+
Enabled: false
|
20
|
+
Layout/MultilineMethodArgumentLineBreaks:
|
21
|
+
Enabled: false
|
22
|
+
Layout/EndOfLine:
|
23
|
+
Enabled: false
|
24
|
+
Layout/EndAlignment:
|
25
|
+
EnforcedStyleAlignWith: variable
|
26
|
+
Layout/FirstHashElementIndentation:
|
27
|
+
Enabled: false
|
28
|
+
Layout/MultilineAssignmentLayout:
|
29
|
+
EnforcedStyle: same_line
|
30
|
+
Layout/CaseIndentation:
|
31
|
+
EnforcedStyle: end
|
32
|
+
Lint/ConstantResolution:
|
33
|
+
Enabled: false
|
34
|
+
Metrics/ParameterLists:
|
35
|
+
Enabled: false
|
36
|
+
Metrics/BlockLength:
|
37
|
+
Exclude:
|
38
|
+
- 'spec/**/*_spec.rb'
|
39
|
+
Style/MethodCallWithArgsParentheses:
|
40
|
+
Enabled: false
|
41
|
+
Style/Copyright:
|
42
|
+
Enabled: false
|
43
|
+
Style/ClassVars:
|
44
|
+
Enabled: false
|
45
|
+
Style/MissingElse:
|
46
|
+
Enabled: false
|
47
|
+
Style/StringHashKeys:
|
48
|
+
Enabled: false
|
49
|
+
Style/ImplicitRuntimeError:
|
50
|
+
Enabled: false
|
51
|
+
Style/NumericLiterals:
|
52
|
+
Enabled: false
|
53
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
54
|
+
Enabled: false
|
55
|
+
Layout/MultilineHashKeyLineBreaks:
|
56
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,10 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
gem
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in vk_music.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :test, :development do
|
9
|
+
# Debugging console
|
10
|
+
gem 'pry'
|
11
|
+
|
12
|
+
# Another debugging console
|
13
|
+
gem 'byebug'
|
14
|
+
|
15
|
+
# The thing, forcing you to write good code
|
16
|
+
gem 'rubocop', require: false
|
17
|
+
|
18
|
+
# Rake tasks
|
19
|
+
gem 'rake', require: false
|
20
|
+
|
21
|
+
# Testing
|
22
|
+
gem 'rspec', require: false
|
23
|
+
|
24
|
+
# Docs
|
25
|
+
gem 'yard', require: false
|
26
|
+
|
27
|
+
# .env support
|
28
|
+
gem 'dotenv'
|
29
|
+
|
30
|
+
# Save web requests for fast and reliable testing
|
31
|
+
gem 'vcr'
|
32
|
+
|
33
|
+
# Stub web requests
|
34
|
+
gem 'webmock'
|
35
|
+
|
36
|
+
# Test coverage
|
37
|
+
gem 'simplecov', require: false, group: :test
|
38
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,70 +1,123 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
vk_music (
|
5
|
-
execjs (~> 2.7)
|
6
|
-
json (~> 2.
|
7
|
-
logger (~> 1.4)
|
8
|
-
mechanize (~> 2.7)
|
9
|
-
net-http-persistent (= 2.9.4)
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: https://rubygems.org/
|
13
|
-
specs:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vk_music (4.0.0)
|
5
|
+
execjs (~> 2.7)
|
6
|
+
json (~> 2.3)
|
7
|
+
logger (~> 1.4)
|
8
|
+
mechanize (~> 2.7)
|
9
|
+
net-http-persistent (= 2.9.4)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
addressable (2.7.0)
|
15
|
+
public_suffix (>= 2.0.2, < 5.0)
|
16
|
+
ast (2.4.1)
|
17
|
+
byebug (11.1.3)
|
18
|
+
coderay (1.1.3)
|
19
|
+
crack (0.4.4)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
docile (1.3.2)
|
22
|
+
domain_name (0.5.20190701)
|
23
|
+
unf (>= 0.0.5, < 1.0.0)
|
24
|
+
dotenv (2.7.6)
|
25
|
+
execjs (2.7.0)
|
26
|
+
hashdiff (1.0.1)
|
27
|
+
http-cookie (1.0.3)
|
28
|
+
domain_name (~> 0.5)
|
29
|
+
json (2.3.1)
|
30
|
+
logger (1.4.2)
|
31
|
+
mechanize (2.7.6)
|
32
|
+
domain_name (~> 0.5, >= 0.5.1)
|
33
|
+
http-cookie (~> 1.0)
|
34
|
+
mime-types (>= 1.17.2)
|
35
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
36
|
+
net-http-persistent (>= 2.5.2)
|
37
|
+
nokogiri (~> 1.6)
|
38
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
39
|
+
webrobots (>= 0.0.9, < 0.2)
|
40
|
+
method_source (1.0.0)
|
41
|
+
mime-types (3.3.1)
|
42
|
+
mime-types-data (~> 3.2015)
|
43
|
+
mime-types-data (3.2020.1104)
|
44
|
+
mini_portile2 (2.4.0)
|
45
|
+
net-http-digest_auth (1.4.1)
|
46
|
+
net-http-persistent (2.9.4)
|
47
|
+
nokogiri (1.10.10)
|
48
|
+
mini_portile2 (~> 2.4.0)
|
49
|
+
nokogiri (1.10.10-x64-mingw32)
|
50
|
+
mini_portile2 (~> 2.4.0)
|
51
|
+
ntlm-http (0.1.1)
|
52
|
+
parallel (1.19.2)
|
53
|
+
parser (2.7.2.0)
|
54
|
+
ast (~> 2.4.1)
|
55
|
+
pry (0.13.1)
|
56
|
+
coderay (~> 1.1)
|
57
|
+
method_source (~> 1.0)
|
58
|
+
public_suffix (4.0.6)
|
59
|
+
rainbow (3.0.0)
|
60
|
+
rake (13.0.1)
|
61
|
+
regexp_parser (1.8.2)
|
62
|
+
rexml (3.2.4)
|
63
|
+
rspec (3.10.0)
|
64
|
+
rspec-core (~> 3.10.0)
|
65
|
+
rspec-expectations (~> 3.10.0)
|
66
|
+
rspec-mocks (~> 3.10.0)
|
67
|
+
rspec-core (3.10.0)
|
68
|
+
rspec-support (~> 3.10.0)
|
69
|
+
rspec-expectations (3.10.0)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.10.0)
|
72
|
+
rspec-mocks (3.10.0)
|
73
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
+
rspec-support (~> 3.10.0)
|
75
|
+
rspec-support (3.10.0)
|
76
|
+
rubocop (1.2.0)
|
77
|
+
parallel (~> 1.10)
|
78
|
+
parser (>= 2.7.1.5)
|
79
|
+
rainbow (>= 2.2.2, < 4.0)
|
80
|
+
regexp_parser (>= 1.8)
|
81
|
+
rexml
|
82
|
+
rubocop-ast (>= 1.0.1)
|
83
|
+
ruby-progressbar (~> 1.7)
|
84
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
85
|
+
rubocop-ast (1.1.1)
|
86
|
+
parser (>= 2.7.1.5)
|
87
|
+
ruby-progressbar (1.10.1)
|
88
|
+
simplecov (0.19.1)
|
89
|
+
docile (~> 1.1)
|
90
|
+
simplecov-html (~> 0.11)
|
91
|
+
simplecov-html (0.12.3)
|
92
|
+
unf (0.1.4)
|
93
|
+
unf_ext
|
94
|
+
unf_ext (0.0.7.7)
|
95
|
+
unf_ext (0.0.7.7-x64-mingw32)
|
96
|
+
unicode-display_width (1.7.0)
|
97
|
+
vcr (6.0.0)
|
98
|
+
webmock (3.9.5)
|
99
|
+
addressable (>= 2.3.6)
|
100
|
+
crack (>= 0.3.2)
|
101
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
102
|
+
webrobots (0.1.2)
|
103
|
+
yard (0.9.25)
|
104
|
+
|
105
|
+
PLATFORMS
|
106
|
+
ruby
|
107
|
+
x64-mingw32
|
108
|
+
|
109
|
+
DEPENDENCIES
|
110
|
+
byebug
|
111
|
+
dotenv
|
112
|
+
pry
|
113
|
+
rake
|
114
|
+
rspec
|
115
|
+
rubocop
|
116
|
+
simplecov
|
117
|
+
vcr
|
118
|
+
vk_music!
|
119
|
+
webmock
|
120
|
+
yard
|
121
|
+
|
122
|
+
BUNDLED WITH
|
123
|
+
2.1.4
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,94 +1,111 @@
|
|
1
|
-
# VkMusic
|
2
|
-
|
3
|
-
*vk_music* gem is a library to work with audios on popular Russian social network
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'vk_music'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
client.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
You can load
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
playlist = client.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
You can
|
61
|
-
|
62
|
-
```ruby
|
63
|
-
|
64
|
-
```
|
65
|
-
|
66
|
-
###
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
```
|
73
|
-
|
74
|
-
###
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
1
|
+
# VkMusic
|
2
|
+
|
3
|
+
*vk_music* gem is a library to work with audios on popular Russian social network
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'vk_music'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
```
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
|
18
|
+
Or install it using `gem`:
|
19
|
+
|
20
|
+
```
|
21
|
+
$ gem install vk_music
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
You can take a look on documentation at [rubydoc](https://www.rubydoc.info/gems/vk_music/).
|
27
|
+
|
28
|
+
### Logging in
|
29
|
+
|
30
|
+
Firstly, it is required to create new `VkMusic::Client` instance and provide login credentials:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
client = VkMusic::Client.new(username: "+79991234567", password: "password")
|
34
|
+
```
|
35
|
+
|
36
|
+
### Search
|
37
|
+
|
38
|
+
You can search audios using `Client#find`:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
audios = client.find("Acid Spit - Mega Drive")
|
42
|
+
```
|
43
|
+
|
44
|
+
You can also search for playlists using same method:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
playlists = client.find("Jazz", type: :playlist)
|
48
|
+
```
|
49
|
+
|
50
|
+
### Playlists
|
51
|
+
|
52
|
+
You can load playlist audios with `Client#playlist`
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
playlist = client.playlist(url: "link")
|
56
|
+
```
|
57
|
+
|
58
|
+
### User or group audios
|
59
|
+
|
60
|
+
You can load profile audios with `Client#audios`
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
playlist = client.audios(owner_id: 8024985)
|
64
|
+
```
|
65
|
+
|
66
|
+
### Wall audios
|
67
|
+
|
68
|
+
You can load audios from profile wall with `Client#wall`
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
playlist = client.wall(owner_id: 8024985)
|
72
|
+
```
|
73
|
+
|
74
|
+
### Audios from post
|
75
|
+
|
76
|
+
You can load up to 10 audios attached to some post. Those audios will be returned as array:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
audios = client.post(url: "link")
|
80
|
+
```
|
81
|
+
|
82
|
+
### Getting audio URL
|
83
|
+
|
84
|
+
To get audio URL you should go through following chain:
|
85
|
+
1. Get audio ID
|
86
|
+
2. Get audio encrypted URL
|
87
|
+
3. Get audio decrypted URL
|
88
|
+
|
89
|
+
Usually most of audios already go with ID. Getting encrypted URL requires additional request to web, so it is performed with `Client#update_urls`, which will mutate provided array of audios:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
client.update_urls(audios_array)
|
93
|
+
```
|
94
|
+
|
95
|
+
After this you can get decrypted URL using `Audio#url`
|
96
|
+
|
97
|
+
## Development
|
98
|
+
|
99
|
+
Feel free to add features. However, please make sure all your code is covered with tests.
|
100
|
+
|
101
|
+
### Testing
|
102
|
+
|
103
|
+
This gem uses `rspec` and `vcr` for easy testing. *Be careful*, though, running `rspec` in clean repo may result in lot of requests to web and rate limiting or ban
|
104
|
+
|
105
|
+
## Contributing
|
106
|
+
|
107
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fizvlad/vk-music-rb/issues.
|
108
|
+
|
109
|
+
## License
|
110
|
+
|
111
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|