nehm 1.3.1.1 → 1.3.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/CHANGELOG.md +4 -0
- data/lib/nehm/user.rb +21 -5
- data/lib/nehm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95154a08e75bc3f3d979e6b9b2b8eaea43a1dcbc
|
4
|
+
data.tar.gz: b99a099bde117d9aeb37e0a126556fe868ae0174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e080dd9062495fe1e086804c0427a5948210d27de8c86925dc6356df4dafbf160d3be6b0e74edb7f01f64acc2366915de3c68456a05c2fcf20d41c5acc0fcea7
|
7
|
+
data.tar.gz: 692221be13b3ef4380ed2c73a27c736d488c93664c3b76952a2cd1fe8ce85a9861267b3a221e0d3036a44635bda6f76d350556fa9b6852f577a130bec61879df
|
data/CHANGELOG.md
CHANGED
data/lib/nehm/user.rb
CHANGED
@@ -7,27 +7,43 @@ class User
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def likes(count)
|
10
|
-
|
10
|
+
# Method to_i return 0, if there aren't any numbers in string
|
11
|
+
if count == 0
|
11
12
|
puts Paint['Invalid number of likes!', :red]
|
12
13
|
exit
|
13
14
|
end
|
14
15
|
|
15
16
|
likes = Client.get("/users/#{@id}/favorites?limit=#{count}")
|
17
|
+
|
18
|
+
if likes.empty?
|
19
|
+
puts Paint["There are no likes yet :(", :red]
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
16
23
|
likes.map { |hash| Track.new(hash) }
|
17
24
|
end
|
18
25
|
|
19
|
-
# Post is last track
|
26
|
+
# Post is last track/repost in profile
|
20
27
|
def posts(count)
|
21
|
-
|
28
|
+
# Method to_i return 0, if there aren't any numbers in string
|
29
|
+
if count == 0
|
22
30
|
puts Paint['Invalid number of posts!', :red]
|
23
31
|
exit
|
24
32
|
end
|
25
33
|
|
34
|
+
# Official SC API wrapper doesn't support for posts
|
35
|
+
# So I should get posts by HTTP requests
|
26
36
|
conn = Faraday.new(url: 'https://api-v2.soundcloud.com/')
|
27
37
|
response = conn.get("/profile/soundcloud:users:#{@id}?limit=#{count}&offset=0")
|
28
38
|
|
29
39
|
parsed = JSON.parse(response.body)
|
30
|
-
|
31
|
-
|
40
|
+
posts = parsed['collection']
|
41
|
+
|
42
|
+
if posts.empty?
|
43
|
+
puts Paint["There are no posts yet :(", :red]
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
posts.map { |hash| Track.new(hash['track']) }
|
32
48
|
end
|
33
49
|
end
|
data/lib/nehm/version.rb
CHANGED