vk_music 0.2.0 → 1.0.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: b0b18a8dbb2f4a9e836fc86c32261f0b7dbbb73df81a1b04ff7fc14f8e6fa7d4
4
- data.tar.gz: dd21f748dcee7334a481f909c39e699d13b3747370088c9dc6be4d0c86d6ffcf
3
+ metadata.gz: 1ba9c791d5fde4a7bdf268db7e2f436487169479813ffb0db72ea64bdbcf7400
4
+ data.tar.gz: 90a882a7a21772ee05dadd26fe10bb08bc2a08c204db74c76e9c93834029a50e
5
5
  SHA512:
6
- metadata.gz: 045f170226ffa593f6ad0cc73f3b5995b93e1a4d885214870c24b03ffdefb21f4b45e580617354b8e17c11017e9a7ff2439ea3cb4ae213db97da2c18d95306a2
7
- data.tar.gz: 8875c652bf92ffc471badb3f11f910c288b90b6e36cbc4a643a10a2b9b3b1c5f3f2be764c0af6aa33fa82b2ce758b04ecd0adcaec5b4f49e4af1d0c53f266d37
6
+ metadata.gz: 2aef4871bb1f3ee3254dd86b46b38ea47b741cbe3f6c6c8a8e0e57f06f0bb1b85247cc83dceb911c6da63b91c388be4d7f059ed532f17fb9db0051c410f6a31d
7
+ data.tar.gz: ecb177ae3537bc845528421b5cb602b09a03ea8e2a7a77ae18a7879dab0099b5e3b741bf9753211d3e40472742164891ef58bf3cacfe70e013ca2a952068979e
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- require "io/console"
2
-
3
1
  desc "Build gem file"
4
2
  task :build do
5
3
  puts `gem build vk_music.gemspec`
@@ -7,17 +5,17 @@ end
7
5
 
8
6
  desc "Run tests"
9
7
  task :test do
10
- puts "Running tests require login credetionals"
8
+ puts "Running tests require login credetionals (NOTICE: they won't be hidden in anyway)"
11
9
 
12
10
  print "Login: "
13
11
  username = STDIN.gets.chomp
14
12
 
15
13
  print "Password: "
16
- password = STDIN.noecho(&:gets).chomp
14
+ password = STDIN.gets.chomp
17
15
  puts
18
16
 
19
17
  Dir[ "test/test*.rb" ].each do |file|
20
18
  puts "\n\nRunning #{file}:"
21
- puts `ruby -w #{file} '#{username}' '#{password}'`
19
+ ruby "-w #{file} '#{username}' '#{password}'"
22
20
  end
23
21
  end
@@ -1,94 +1,93 @@
1
- require "duktape"
1
+ require "execjs"
2
2
 
3
3
  module VkMusic
4
4
 
5
5
  # Setting up decoding context
6
- @@js_context = Duktape::Context.new
7
- js_code = <<END_OF_STRING
8
- function vk_unmask_link(link, vk_id) {
6
+ js_code = <<~HEREDOC
7
+ function vk_unmask_link(link, vk_id) {
9
8
 
10
- // Utility functions to unmask
9
+ // Utility functions to unmask
11
10
 
12
- var audioUnmaskSource = function (encrypted) {
13
- if (encrypted.indexOf('audio_api_unavailable') != -1) {
14
- var parts = encrypted.split('?extra=')[1].split('#');
11
+ var audioUnmaskSource = function (encrypted) {
12
+ if (encrypted.indexOf('audio_api_unavailable') != -1) {
13
+ var parts = encrypted.split('?extra=')[1].split('#');
15
14
 
16
- var handled_anchor = '' === parts[1] ? '' : handler(parts[1]);
15
+ var handled_anchor = '' === parts[1] ? '' : handler(parts[1]);
17
16
 
18
- var handled_part = handler(parts[0]);
17
+ var handled_part = handler(parts[0]);
19
18
 
20
- if (typeof handled_anchor != 'string' || !handled_part) {
21
- // if (typeof handled_anchor != 'string') console.warn('Handled_anchor type: ' + typeof handled_anchor);
22
- // if (!handled_part) console.warn('Handled_part: ' + handled_part);
23
- return encrypted;
24
- }
19
+ if (typeof handled_anchor != 'string' || !handled_part) {
20
+ // if (typeof handled_anchor != 'string') console.warn('Handled_anchor type: ' + typeof handled_anchor);
21
+ // if (!handled_part) console.warn('Handled_part: ' + handled_part);
22
+ return encrypted;
23
+ }
25
24
 
26
- handled_anchor = handled_anchor ? handled_anchor.split(String.fromCharCode(9)) : [];
25
+ handled_anchor = handled_anchor ? handled_anchor.split(String.fromCharCode(9)) : [];
27
26
 
28
- for (var func_key, splited_anchor, l = handled_anchor.length; l--;) {
29
- splited_anchor = handled_anchor[l].split(String.fromCharCode(11));
30
- func_key = splited_anchor.splice(0, 1, handled_part)[0];
31
- if (!utility_object[func_key]) {
32
- // console.warn('Was unable to find key: ' + func_key);
33
- return encrypted;
27
+ for (var func_key, splited_anchor, l = handled_anchor.length; l--;) {
28
+ splited_anchor = handled_anchor[l].split(String.fromCharCode(11));
29
+ func_key = splited_anchor.splice(0, 1, handled_part)[0];
30
+ if (!utility_object[func_key]) {
31
+ // console.warn('Was unable to find key: ' + func_key);
32
+ return encrypted;
33
+ }
34
+ handled_part = utility_object[func_key].apply(null, splited_anchor)
34
35
  }
35
- handled_part = utility_object[func_key].apply(null, splited_anchor)
36
- }
37
36
 
38
- if (handled_part && 'http' === handled_part.substr(0, 4)) return handled_part;
39
- // else console.warn('Failed unmasking: ' + handled_part);
40
- } else {
41
- // console.warn('Bad link: ' + encrypted);
37
+ if (handled_part && 'http' === handled_part.substr(0, 4)) return handled_part;
38
+ // else console.warn('Failed unmasking: ' + handled_part);
39
+ } else {
40
+ // console.warn('Bad link: ' + encrypted);
41
+ }
42
+ return encrypted;
42
43
  }
43
- return encrypted;
44
- }
45
44
 
46
- var handler = function (part) {
47
- if (!part || part.length % 4 == 1) return !1;
48
- for (var t, i, o = 0, s = 0, a = ''; i = part.charAt(s++);) {
49
- i = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/='.indexOf(i)
50
- ~i && (t = o % 4 ? 64 * t + i : i, o++ % 4) && (a += String.fromCharCode(255 & t >> (-2 * o & 6)));
45
+ var handler = function (part) {
46
+ if (!part || part.length % 4 == 1) return !1;
47
+ for (var t, i, o = 0, s = 0, a = ''; i = part.charAt(s++);) {
48
+ i = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/='.indexOf(i)
49
+ ~i && (t = o % 4 ? 64 * t + i : i, o++ % 4) && (a += String.fromCharCode(255 & t >> (-2 * o & 6)));
50
+ }
51
+ return a;
51
52
  }
52
- return a;
53
- }
54
53
 
55
- var utility_object = {
56
- i: function(e, t) {
57
- return utility_object.s(e, t ^ vk_id);
58
- },
59
- s: function(e, t) {
60
- var n = e.length;
54
+ var utility_object = {
55
+ i: function(e, t) {
56
+ return utility_object.s(e, t ^ vk_id);
57
+ },
58
+ s: function(e, t) {
59
+ var n = e.length;
60
+ if (n) {
61
+ var i = r_func(e, t),
62
+ o = 0;
63
+ for (e = e.split(''); ++o < n;)
64
+ e[o] = e.splice(i[n - 1 - o], 1, e[o])[0];
65
+ e = e.join('')
66
+ }
67
+ return e;
68
+ }
69
+ };
70
+
71
+ var r_func = function (e, t) {
72
+ var n = e.length,
73
+ i = [];
61
74
  if (n) {
62
- var i = r_func(e, t),
63
- o = 0;
64
- for (e = e.split(''); ++o < n;)
65
- e[o] = e.splice(i[n - 1 - o], 1, e[o])[0];
66
- e = e.join('')
75
+ var o = n;
76
+ for (t = Math.abs(t); o--;)
77
+ t = (n * (o + 1) ^ t + o) % n,
78
+ i[o] = t;
67
79
  }
68
- return e;
80
+ return i;
69
81
  }
70
- };
71
82
 
72
- var r_func = function (e, t) {
73
- var n = e.length,
74
- i = [];
75
- if (n) {
76
- var o = n;
77
- for (t = Math.abs(t); o--;)
78
- t = (n * (o + 1) ^ t + o) % n,
79
- i[o] = t;
80
- }
81
- return i;
83
+ return audioUnmaskSource(link);
82
84
  }
85
+ HEREDOC
83
86
 
84
- return audioUnmaskSource(link);
85
- }
86
- END_OF_STRING
87
- @@js_context.exec_string js_code
87
+ @@js_context = ExecJS.compile(js_code)
88
88
 
89
-
90
89
  def self.unmask_link(link, client_id)
91
- @@js_context.call_prop("vk_unmask_link", link.to_s, client_id.to_i)
90
+ @@js_context.call("vk_unmask_link", link.to_s, client_id.to_i)
92
91
  end
93
92
 
94
93
  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 = "0.2.0"
5
+ s.version = "1.0.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"
@@ -10,10 +10,10 @@ Gem::Specification.new do |s|
10
10
  s.required_ruby_version = ">=2.3.1"
11
11
  s.files = Dir[ "lib/**/**", "test/**/**", "LICENSE", "Rakefile", "README.md", "vk_music.gemspec" ]
12
12
  s.test_files = Dir[ "test/test*.rb" ]
13
- s.has_rdoc = false
14
13
  s.license = "MIT"
15
14
 
16
15
  s.add_runtime_dependency "mechanize", "~>2.7"
17
- s.add_runtime_dependency "duktape", "~>2.3"
16
+ s.add_runtime_dependency "execjs", "~>2.7"
18
17
  s.add_runtime_dependency "json", "~>2.0"
18
+ s.add_runtime_dependency "rake", "~>12.3"
19
19
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vk_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuznetsov Vladislav
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
11
+ date: 2019-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: mechanize
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: '2.7'
20
- type: :runtime
19
+ name: mechanize
21
20
  prerelease: false
21
+ type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.7'
27
27
  - !ruby/object:Gem::Dependency
28
- name: duktape
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '2.3'
34
- type: :runtime
32
+ version: '2.7'
33
+ name: execjs
35
34
  prerelease: false
35
+ type: :runtime
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.3'
40
+ version: '2.7'
41
41
  - !ruby/object:Gem::Dependency
42
- name: json
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
46
  version: '2.0'
48
- type: :runtime
47
+ name: json
49
48
  prerelease: false
49
+ type: :runtime
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '12.3'
61
+ name: rake
62
+ prerelease: false
63
+ type: :runtime
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.3'
55
69
  description: Library to work with audios on popular Russian social network vk.com.
56
70
  VK disabled their public API for audios, so it is now necessary to use parsers instead.
57
71
  email: fizvlad@mail.ru
@@ -80,7 +94,7 @@ homepage: https://github.com/fizvlad/vk-music-rb
80
94
  licenses:
81
95
  - MIT
82
96
  metadata: {}
83
- post_install_message:
97
+ post_install_message:
84
98
  rdoc_options: []
85
99
  require_paths:
86
100
  - lib
@@ -95,9 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.7.6.2
100
- signing_key:
112
+ rubyforge_project:
113
+ rubygems_version: 2.7.9
114
+ signing_key:
101
115
  specification_version: 4
102
116
  summary: Provides interface to work with VK music via HTTP requests
103
117
  test_files: