songstats-api 0.1.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/songstats/api/artist.rb +2 -2
- data/lib/songstats/api/base.rb +21 -10
- data/lib/songstats/api/label.rb +8 -6
- data/lib/songstats/api/track.rb +2 -2
- data/lib/songstats/api/version.rb +1 -1
- data/songstats-api.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d8df26fc2d79b94ae28d7c834c6d6d05faf8b48e7eeca5b66fb0c0c3916cab6
|
4
|
+
data.tar.gz: 0db44faaaea2e1738aaf0bb31a0c498ec840e2d9dca342aecc540807803f28ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ffaa30f77ef53d95556ce21a7f702f1c225c7d91b9a1dd217d2956b6a9efcf387bde7550ec3ba263605820c04c8081be63421686f36edd6176c367465cc9eb
|
7
|
+
data.tar.gz: 6613a579154f5b7e718909a0f417884619cd159dd6073644960056bcf0c522f89e31c45fed0c51a5c4c53f9b9604af344041868c7ee5b583b60a260c1c7fd83d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Songstats::Api
|
2
2
|
|
3
|
+
[![Ruby](https://github.com/songtradr/songstats-api/actions/workflows/main.yml/badge.svg)](https://github.com/songtradr/songstats-api/actions/workflows/main.yml)
|
4
|
+
|
3
5
|
The Songstats API Gem is a lightweight tool for developers to interact with the Songstats REST API. With this gem, you can integrate Songstats' music data into your Ruby applications, making it easy to access information about tracks, artists, and more.
|
4
6
|
|
5
7
|
To experiment with that code, run `bin/console` for an interactive prompt.
|
data/lib/songstats/api/artist.rb
CHANGED
@@ -62,10 +62,10 @@ module Songstats
|
|
62
62
|
fetch path(id, "/artists/top_playlists", options)
|
63
63
|
end
|
64
64
|
|
65
|
-
def search(
|
65
|
+
def search(query, options = {})
|
66
66
|
# https://docs.songstats.com/docs/api/d761545339f09-search-artist
|
67
67
|
options[:q] = query
|
68
|
-
fetch path(
|
68
|
+
fetch path("", "/artists/search", options)
|
69
69
|
end
|
70
70
|
|
71
71
|
def add_link(id, link)
|
data/lib/songstats/api/base.rb
CHANGED
@@ -21,17 +21,28 @@ module Songstats
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
+
def query_string(id)
|
25
|
+
return "isrc=#{id}" if id.size == ISRC_LENGTH
|
26
|
+
|
27
|
+
return "songstats_#{@type}_id=#{id}" if id.size == SONG_STATS_ID_LENGTH
|
28
|
+
|
29
|
+
return "" if id.size.zero?
|
30
|
+
|
31
|
+
"spotify_#{@type}_id=#{id}"
|
32
|
+
end
|
33
|
+
|
24
34
|
def path(id, path, options = {})
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
query_params = options.map { |key, value| "#{key}=#{value}" }.join("&")
|
36
|
+
|
37
|
+
query_string = query_string(id)
|
38
|
+
|
39
|
+
if query_string.empty?
|
40
|
+
"#{path}?#{query_params}"
|
41
|
+
else
|
42
|
+
return "#{path}?#{query_string}" if query_params.empty?
|
43
|
+
|
44
|
+
"#{path}?#{query_string}&#{query_params}"
|
45
|
+
end
|
35
46
|
end
|
36
47
|
|
37
48
|
def fetch(path)
|
data/lib/songstats/api/label.rb
CHANGED
@@ -7,10 +7,12 @@ module Songstats
|
|
7
7
|
include Singleton
|
8
8
|
|
9
9
|
# override because the label id is either songstats_label_id or beatport_label_id
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def query_string(id)
|
11
|
+
return "songstats_label_id=#{id}" if id.size == SONG_STATS_ID_LENGTH
|
12
|
+
|
13
|
+
return "" if id.size.zero?
|
14
|
+
|
15
|
+
"beatport_label_id=#{id}"
|
14
16
|
end
|
15
17
|
|
16
18
|
def info(id)
|
@@ -63,10 +65,10 @@ module Songstats
|
|
63
65
|
fetch path(id, "/labels/top_playlists", options)
|
64
66
|
end
|
65
67
|
|
66
|
-
def search(
|
68
|
+
def search(query, options = {})
|
67
69
|
# https://docs.songstats.com/docs/api/c934a2909ba0f-search-label
|
68
70
|
options[:q] = query
|
69
|
-
fetch path(
|
71
|
+
fetch path("", "/labels/search", options)
|
70
72
|
end
|
71
73
|
|
72
74
|
def add_link(id, link)
|
data/lib/songstats/api/track.rb
CHANGED
@@ -34,10 +34,10 @@ module Songstats
|
|
34
34
|
fetch path(id, "/tracks/historic_stats", options)
|
35
35
|
end
|
36
36
|
|
37
|
-
def search(
|
37
|
+
def search(query, options = {})
|
38
38
|
# https://docs.songstats.com/docs/api/1f2e4f9b3b1d1-search-track
|
39
39
|
options[:q] = query
|
40
|
-
fetch path(
|
40
|
+
fetch path("", "/tracks/search", options)
|
41
41
|
end
|
42
42
|
|
43
43
|
def add_link(id, link)
|
data/songstats-api.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "A simple API wrapper for the Songstats API"
|
13
13
|
spec.homepage = "https://github.com/songtradr/songstats-api"
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
15
|
-
spec.licenses
|
15
|
+
spec.licenses = ["MIT"]
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/songtradr"
|
18
18
|
|