songstats-api 1.1.0 → 1.3.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: 9d8df26fc2d79b94ae28d7c834c6d6d05faf8b48e7eeca5b66fb0c0c3916cab6
4
- data.tar.gz: 0db44faaaea2e1738aaf0bb31a0c498ec840e2d9dca342aecc540807803f28ff
3
+ metadata.gz: abef0db83768f11fbe5b7b4065be17b37314ba7ae09838218fb679e1ed6ce609
4
+ data.tar.gz: e727fe9aa96d85f7cbeca6340453f931c214c3654b0ced5be3ce378f29e4017b
5
5
  SHA512:
6
- metadata.gz: 23ffaa30f77ef53d95556ce21a7f702f1c225c7d91b9a1dd217d2956b6a9efcf387bde7550ec3ba263605820c04c8081be63421686f36edd6176c367465cc9eb
7
- data.tar.gz: 6613a579154f5b7e718909a0f417884619cd159dd6073644960056bcf0c522f89e31c45fed0c51a5c4c53f9b9604af344041868c7ee5b583b60a260c1c7fd83d
6
+ metadata.gz: '0058d84c8f6b1af15782760e7d97ecf9e2afbc58735c07c4950902d51abbb470056068016b7a9ec6edf2338635af3eebe150599ae7ece7c7b245d01db365df16'
7
+ data.tar.gz: 0a8e2720669bd876f5b5572146aef63d9a9e041fbc04e77b4875b09b095aa38502992da63611bec54eaf00e1762cab1cfa3a0786988771d9d7bde329c6da9af2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- songstats-api (1.1.0)
4
+ songstats-api (1.3.0)
5
5
  httparty
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -24,7 +24,24 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- TODO: Write usage instructions here
27
+ To use this gem ensure that `SONGSTATS_API_KEY` is set as an env variarble.
28
+
29
+ This is a wrapper around Song Stats API - [you can find their docs here](https://docs.songstats.com/docs/api/e80265bb8b01b-songstats-api).
30
+
31
+
32
+ ### Artist
33
+ ```ruby
34
+ artist = Songstats::Api::Artist.new
35
+ artist.search "elton john", {"limit": "1"}
36
+ artist.info "22wbnEMDvgVIAGdFeek6ET"
37
+ ```
38
+
39
+ ### Track
40
+ ```ruby
41
+ track = Songstats::Api::Track.new
42
+ track.search "rocket man", {"limit": "1"}
43
+ track.info "12341234"
44
+ ```
28
45
 
29
46
  ## Development
30
47
 
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "singleton"
4
-
5
3
  module Songstats
6
4
  module Api
7
5
  # Artist class for the Songstats API
8
6
  class Artist < Base
9
- include Singleton
10
-
11
7
  def initialize
12
8
  super
13
9
  @type = "artist"
@@ -77,6 +73,24 @@ module Songstats
77
73
  # https://docs.songstats.com/docs/api/dc58c858fdbb6-delete-artist-link
78
74
  delete path(id, "/artists/link_request", link: link)
79
75
  end
76
+
77
+ def add_track(id, track_id)
78
+ # https://docs.songstats.com/docs/api/aux8fvg3g9sv7-add-artist-track
79
+ options = {}
80
+ options[:isrc] = track_id if track_id.size == ISRC_LENGTH
81
+ options[:spotify_track_id] = track_id if track_id.size > ISRC_LENGTH && !url?(track_id)
82
+ options[:link] = track_id if url? track_id
83
+ post path(id, "/artists/track_request", options)
84
+ end
85
+
86
+ def delete_track(id, track_id)
87
+ # https://docs.songstats.com/docs/api/sijd2vkvgwpdj-remove-artist-track
88
+ options = {}
89
+ options[:isrc] = track_id if track_id.size == ISRC_LENGTH
90
+ options[:songstats_track_id] = track_id if track_id.size == SONG_STATS_ID_LENGTH
91
+ options[:spotify_track_id] = track_id if track_id.size > ISRC_LENGTH
92
+ delete path(id, "/artists/track_request", options)
93
+ end
80
94
  end
81
95
  end
82
96
  end
@@ -21,6 +21,11 @@ module Songstats
21
21
 
22
22
  private
23
23
 
24
+ def url?(str)
25
+ url_regex = /\A#{URI::DEFAULT_PARSER.make_regexp(%w[http https])}\z/
26
+ str =~ url_regex ? true : false
27
+ end
28
+
24
29
  def query_string(id)
25
30
  return "isrc=#{id}" if id.size == ISRC_LENGTH
26
31
 
@@ -4,8 +4,6 @@ module Songstats
4
4
  module Api
5
5
  # Label class for the Songstats API
6
6
  class Label < Base
7
- include Singleton
8
-
9
7
  # override because the label id is either songstats_label_id or beatport_label_id
10
8
  def query_string(id)
11
9
  return "songstats_label_id=#{id}" if id.size == SONG_STATS_ID_LENGTH
@@ -80,6 +78,24 @@ module Songstats
80
78
  # https://docs.songstats.com/docs/api/f684183faa3b9-delete-label-link
81
79
  delete path(id, "/labels/link_request", link: link)
82
80
  end
81
+
82
+ def add_track(id, track_id)
83
+ # https://docs.songstats.com/docs/api/sf9lrzr189m48-add-label-track
84
+ options = {}
85
+ options[:isrc] = track_id if track_id.size == ISRC_LENGTH
86
+ options[:spotify_track_id] = track_id if track_id.size > ISRC_LENGTH && !url?(track_id)
87
+ options[:link] = track_id if url? track_id
88
+ post path(id, "/labels/track_request", options)
89
+ end
90
+
91
+ def delete_track(id, track_id)
92
+ # https://docs.songstats.com/docs/api/l0xhrjijnktgf-remove-label-link
93
+ options = {}
94
+ options[:isrc] = track_id if track_id.size == ISRC_LENGTH
95
+ options[:songstats_track_id] = track_id if track_id.size == SONG_STATS_ID_LENGTH
96
+ options[:spotify_track_id] = track_id if track_id.size > ISRC_LENGTH
97
+ delete path(id, "/labels/track_request", options)
98
+ end
83
99
  end
84
100
  end
85
101
  end
@@ -4,8 +4,6 @@ module Songstats
4
4
  module Api
5
5
  # Track class for the Songstats API
6
6
  class Track < Base
7
- include Singleton
8
-
9
7
  def initialize
10
8
  super
11
9
  @type = "track"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Songstats
4
4
  module Api
5
- VERSION = "1.1.0"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songstats-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daryl Findlay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-12 00:00:00.000000000 Z
11
+ date: 2024-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty