vk_music 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vk_music.rb +7 -7
- data/lib/vk_music/client.rb +11 -8
- data/test/test_playlist.rb +6 -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: 25c3df47d7b4d786a9ee10b0eb5c899f572c58d4bc9a634cbbf70d46c93a8c36
|
|
4
|
+
data.tar.gz: e55054576e38c23768e31646d2ca8217f60abd85256ea0d6dd2ea9d25eee73d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcc72c7b4e438ba08072b48d4deb7e63d69fb624487b9fada6444b087dc9d6aa3af8ed29e27ffe449573bf0929e78b31e2b6b0daf2321d59583f4a1d0aa071cd
|
|
7
|
+
data.tar.gz: 54066b7c151a1d3f2b29c166d67b5ba6a33a43c8824d0bdcdefd104d2f8f6efd447d94671be7d72b892721b84e0bd93d88ac89ff027298d27181209568bccc3a
|
data/lib/vk_music.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require_relative
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
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"
|
data/lib/vk_music/client.rb
CHANGED
|
@@ -28,13 +28,14 @@ module VkMusic
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def get_playlist(url, up_to = nil)
|
|
31
|
-
|
|
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.
|
|
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
|
|
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]
|
data/test/test_playlist.rb
CHANGED
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.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.
|
|
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-
|
|
11
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mechanize
|