tidal 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +164 -9
  3. data/Rakefile +9 -0
  4. data/docs/README_md.html +299 -0
  5. data/docs/Tidal/ClientV1.html +721 -0
  6. data/docs/Tidal/Error.html +97 -0
  7. data/docs/Tidal.html +100 -0
  8. data/docs/created.rid +5 -0
  9. data/docs/css/fonts.css +167 -0
  10. data/docs/css/rdoc.css +687 -0
  11. data/docs/fonts/Lato-Light.ttf +0 -0
  12. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  13. data/docs/fonts/Lato-Regular.ttf +0 -0
  14. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  15. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  16. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  17. data/docs/images/add.png +0 -0
  18. data/docs/images/arrow_up.png +0 -0
  19. data/docs/images/brick.png +0 -0
  20. data/docs/images/brick_link.png +0 -0
  21. data/docs/images/bug.png +0 -0
  22. data/docs/images/bullet_black.png +0 -0
  23. data/docs/images/bullet_toggle_minus.png +0 -0
  24. data/docs/images/bullet_toggle_plus.png +0 -0
  25. data/docs/images/date.png +0 -0
  26. data/docs/images/delete.png +0 -0
  27. data/docs/images/find.png +0 -0
  28. data/docs/images/loadingAnimation.gif +0 -0
  29. data/docs/images/macFFBgHack.png +0 -0
  30. data/docs/images/package.png +0 -0
  31. data/docs/images/page_green.png +0 -0
  32. data/docs/images/page_white_text.png +0 -0
  33. data/docs/images/page_white_width.png +0 -0
  34. data/docs/images/plugin.png +0 -0
  35. data/docs/images/ruby.png +0 -0
  36. data/docs/images/tag_blue.png +0 -0
  37. data/docs/images/tag_green.png +0 -0
  38. data/docs/images/transparent.png +0 -0
  39. data/docs/images/wrench.png +0 -0
  40. data/docs/images/wrench_orange.png +0 -0
  41. data/docs/images/zoom.png +0 -0
  42. data/docs/index.html +259 -0
  43. data/docs/js/darkfish.js +97 -0
  44. data/docs/js/navigation.js +105 -0
  45. data/docs/js/navigation.js.gz +0 -0
  46. data/docs/js/search.js +110 -0
  47. data/docs/js/search_index.js +1 -0
  48. data/docs/js/search_index.js.gz +0 -0
  49. data/docs/js/searcher.js +229 -0
  50. data/docs/js/searcher.js.gz +0 -0
  51. data/docs/table_of_contents.html +176 -0
  52. data/lib/tidal/client_v1.rb +111 -1
  53. data/lib/tidal/version.rb +1 -1
  54. metadata +63 -1
@@ -0,0 +1,229 @@
1
+ Searcher = function(data) {
2
+ this.data = data;
3
+ this.handlers = [];
4
+ }
5
+
6
+ Searcher.prototype = new function() {
7
+ // search is performed in chunks of 1000 for non-blocking user input
8
+ var CHUNK_SIZE = 1000;
9
+ // do not try to find more than 100 results
10
+ var MAX_RESULTS = 100;
11
+ var huid = 1;
12
+ var suid = 1;
13
+ var runs = 0;
14
+
15
+ this.find = function(query) {
16
+ var queries = splitQuery(query);
17
+ var regexps = buildRegexps(queries);
18
+ var highlighters = buildHilighters(queries);
19
+ var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
20
+ var _this = this;
21
+
22
+ this.currentSuid = state.n;
23
+
24
+ if (!query) return;
25
+
26
+ var run = function() {
27
+ // stop current search thread if new search started
28
+ if (state.n != _this.currentSuid) return;
29
+
30
+ var results =
31
+ performSearch(_this.data, regexps, queries, highlighters, state);
32
+ var hasMore = (state.limit > 0 && state.pass < 4);
33
+
34
+ triggerResults.call(_this, results, !hasMore);
35
+ if (hasMore) {
36
+ setTimeout(run, 2);
37
+ }
38
+ runs++;
39
+ };
40
+ runs = 0;
41
+
42
+ // start search thread
43
+ run();
44
+ }
45
+
46
+ /* ----- Events ------ */
47
+ this.ready = function(fn) {
48
+ fn.huid = huid;
49
+ this.handlers.push(fn);
50
+ }
51
+
52
+ /* ----- Utilities ------ */
53
+ function splitQuery(query) {
54
+ return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
55
+ return string.match(/\S/);
56
+ });
57
+ }
58
+
59
+ function buildRegexps(queries) {
60
+ return queries.map(function(query) {
61
+ return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
62
+ });
63
+ }
64
+
65
+ function buildHilighters(queries) {
66
+ return queries.map(function(query) {
67
+ return query.split('').map(function(l, i) {
68
+ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
69
+ }).join('');
70
+ });
71
+ }
72
+
73
+ // function longMatchRegexp(index, longIndex, regexps) {
74
+ // for (var i = regexps.length - 1; i >= 0; i--){
75
+ // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
76
+ // };
77
+ // return true;
78
+ // }
79
+
80
+
81
+ /* ----- Mathchers ------ */
82
+
83
+ /*
84
+ * This record matches if the index starts with queries[0] and the record
85
+ * matches all of the regexps
86
+ */
87
+ function matchPassBeginning(index, longIndex, queries, regexps) {
88
+ if (index.indexOf(queries[0]) != 0) return false;
89
+ for (var i=1, l = regexps.length; i < l; i++) {
90
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
91
+ return false;
92
+ };
93
+ return true;
94
+ }
95
+
96
+ /*
97
+ * This record matches if the longIndex starts with queries[0] and the
98
+ * longIndex matches all of the regexps
99
+ */
100
+ function matchPassLongIndex(index, longIndex, queries, regexps) {
101
+ if (longIndex.indexOf(queries[0]) != 0) return false;
102
+ for (var i=1, l = regexps.length; i < l; i++) {
103
+ if (!longIndex.match(regexps[i]))
104
+ return false;
105
+ };
106
+ return true;
107
+ }
108
+
109
+ /*
110
+ * This record matches if the index contains queries[0] and the record
111
+ * matches all of the regexps
112
+ */
113
+ function matchPassContains(index, longIndex, queries, regexps) {
114
+ if (index.indexOf(queries[0]) == -1) return false;
115
+ for (var i=1, l = regexps.length; i < l; i++) {
116
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
117
+ return false;
118
+ };
119
+ return true;
120
+ }
121
+
122
+ /*
123
+ * This record matches if regexps[0] matches the index and the record
124
+ * matches all of the regexps
125
+ */
126
+ function matchPassRegexp(index, longIndex, queries, regexps) {
127
+ if (!index.match(regexps[0])) return false;
128
+ for (var i=1, l = regexps.length; i < l; i++) {
129
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
130
+ return false;
131
+ };
132
+ return true;
133
+ }
134
+
135
+
136
+ /* ----- Highlighters ------ */
137
+ function highlightRegexp(info, queries, regexps, highlighters) {
138
+ var result = createResult(info);
139
+ for (var i=0, l = regexps.length; i < l; i++) {
140
+ result.title = result.title.replace(regexps[i], highlighters[i]);
141
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
142
+ };
143
+ return result;
144
+ }
145
+
146
+ function hltSubstring(string, pos, length) {
147
+ return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
148
+ }
149
+
150
+ function highlightQuery(info, queries, regexps, highlighters) {
151
+ var result = createResult(info);
152
+ var pos = 0;
153
+ var lcTitle = result.title.toLowerCase();
154
+
155
+ pos = lcTitle.indexOf(queries[0]);
156
+ if (pos != -1) {
157
+ result.title = hltSubstring(result.title, pos, queries[0].length);
158
+ }
159
+
160
+ result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
161
+ for (var i=1, l = regexps.length; i < l; i++) {
162
+ result.title = result.title.replace(regexps[i], highlighters[i]);
163
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
164
+ };
165
+ return result;
166
+ }
167
+
168
+ function createResult(info) {
169
+ var result = {};
170
+ result.title = info[0];
171
+ result.namespace = info[1];
172
+ result.path = info[2];
173
+ result.params = info[3];
174
+ result.snippet = info[4];
175
+ result.badge = info[6];
176
+ return result;
177
+ }
178
+
179
+ /* ----- Searching ------ */
180
+ function performSearch(data, regexps, queries, highlighters, state) {
181
+ var searchIndex = data.searchIndex;
182
+ var longSearchIndex = data.longSearchIndex;
183
+ var info = data.info;
184
+ var result = [];
185
+ var i = state.from;
186
+ var l = searchIndex.length;
187
+ var togo = CHUNK_SIZE;
188
+ var matchFunc, hltFunc;
189
+
190
+ while (state.pass < 4 && state.limit > 0 && togo > 0) {
191
+ if (state.pass == 0) {
192
+ matchFunc = matchPassBeginning;
193
+ hltFunc = highlightQuery;
194
+ } else if (state.pass == 1) {
195
+ matchFunc = matchPassLongIndex;
196
+ hltFunc = highlightQuery;
197
+ } else if (state.pass == 2) {
198
+ matchFunc = matchPassContains;
199
+ hltFunc = highlightQuery;
200
+ } else if (state.pass == 3) {
201
+ matchFunc = matchPassRegexp;
202
+ hltFunc = highlightRegexp;
203
+ }
204
+
205
+ for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
206
+ if (info[i].n == state.n) continue;
207
+ if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
208
+ info[i].n = state.n;
209
+ result.push(hltFunc(info[i], queries, regexps, highlighters));
210
+ state.limit--;
211
+ }
212
+ };
213
+ if (searchIndex.length <= i) {
214
+ state.pass++;
215
+ i = state.from = 0;
216
+ } else {
217
+ state.from = i;
218
+ }
219
+ }
220
+ return result;
221
+ }
222
+
223
+ function triggerResults(results, isLast) {
224
+ this.handlers.forEach(function(fn) {
225
+ fn.call(this, results, isLast)
226
+ });
227
+ }
228
+ }
229
+
Binary file
@@ -0,0 +1,176 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>Table of Contents - Tidal API Client Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" class="table-of-contents">
25
+ <main role="main">
26
+ <h1 class="class">Table of Contents - Tidal API Client Documentation</h1>
27
+
28
+ <h2 id="pages">Pages</h2>
29
+ <ul>
30
+ <li class="file">
31
+ <a href="README_md.html">README</a>
32
+
33
+ <ul>
34
+ <li><a href="README_md.html#label-Tidal">Tidal</a>
35
+ <li><a href="README_md.html#label-Installation">Installation</a>
36
+ <li><a href="README_md.html#label-Usage">Usage</a>
37
+ <li><a href="README_md.html#label-Configuration">Configuration</a>
38
+ <li><a href="README_md.html#label-Fetch+Albums+by+Barcode+ID">Fetch Albums by Barcode ID</a>
39
+ <li><a href="README_md.html#label-Fetch+Multiple+Albums+by+IDs">Fetch Multiple Albums by IDs</a>
40
+ <li><a href="README_md.html#label-Fetch+Album+Items">Fetch Album Items</a>
41
+ <li><a href="README_md.html#label-Fetch+Similar+Albums">Fetch Similar Albums</a>
42
+ <li><a href="README_md.html#label-Fetch+Single+Album">Fetch Single Album</a>
43
+ <li><a href="README_md.html#label-Fetch+Albums+by+Artist">Fetch Albums by Artist</a>
44
+ <li><a href="README_md.html#label-Fetch+Multiple+Artists+by+IDs">Fetch Multiple Artists by IDs</a>
45
+ <li><a href="README_md.html#label-Fetch+Similar+Artists">Fetch Similar Artists</a>
46
+ <li><a href="README_md.html#label-Fetch+Single+Artist">Fetch Single Artist</a>
47
+ <li><a href="README_md.html#label-Fetch+Tracks+by+Artist">Fetch Tracks by Artist</a>
48
+ <li><a href="README_md.html#label-Fetch+Multiple+Tracks+by+IDs">Fetch Multiple Tracks by IDs</a>
49
+ <li><a href="README_md.html#label-Fetch+Tracks+by+ISRC">Fetch Tracks by ISRC</a>
50
+ <li><a href="README_md.html#label-Fetch+Single+Track">Fetch Single Track</a>
51
+ <li><a href="README_md.html#label-Fetch+Similar+Tracks">Fetch Similar Tracks</a>
52
+ <li><a href="README_md.html#label-Fetch+Multiple+Videos+by+IDs">Fetch Multiple Videos by IDs</a>
53
+ <li><a href="README_md.html#label-Fetch+Single+Video">Fetch Single Video</a>
54
+ <li><a href="README_md.html#label-Search">Search</a>
55
+ <li><a href="README_md.html#label-Development">Development</a>
56
+ <li><a href="README_md.html#label-Contributing">Contributing</a>
57
+ <li><a href="README_md.html#label-License">License</a>
58
+ </ul>
59
+ </li>
60
+ </ul>
61
+
62
+ <h2 id="classes">Classes and Modules</h2>
63
+ <ul>
64
+ <li class="module">
65
+ <a href="Tidal.html">Tidal</a>
66
+ </li>
67
+ <li class="class">
68
+ <a href="Tidal/ClientV1.html">Tidal::ClientV1</a>
69
+ </li>
70
+ <li class="class">
71
+ <a href="Tidal/Error.html">Tidal::Error</a>
72
+ </li>
73
+ </ul>
74
+
75
+ <h2 id="methods">Methods</h2>
76
+ <ul>
77
+
78
+ <li class="method">
79
+ <a href="Tidal/ClientV1.html#method-c-new">::new</a>
80
+ &mdash;
81
+ <span class="container">Tidal::ClientV1</span>
82
+
83
+ <li class="method">
84
+ <a href="Tidal/ClientV1.html#method-i-get_album_items">#get_album_items</a>
85
+ &mdash;
86
+ <span class="container">Tidal::ClientV1</span>
87
+
88
+ <li class="method">
89
+ <a href="Tidal/ClientV1.html#method-i-get_albums_by_artist">#get_albums_by_artist</a>
90
+ &mdash;
91
+ <span class="container">Tidal::ClientV1</span>
92
+
93
+ <li class="method">
94
+ <a href="Tidal/ClientV1.html#method-i-get_albums_by_barcode_id">#get_albums_by_barcode_id</a>
95
+ &mdash;
96
+ <span class="container">Tidal::ClientV1</span>
97
+
98
+ <li class="method">
99
+ <a href="Tidal/ClientV1.html#method-i-get_multiple_albums">#get_multiple_albums</a>
100
+ &mdash;
101
+ <span class="container">Tidal::ClientV1</span>
102
+
103
+ <li class="method">
104
+ <a href="Tidal/ClientV1.html#method-i-get_multiple_artists">#get_multiple_artists</a>
105
+ &mdash;
106
+ <span class="container">Tidal::ClientV1</span>
107
+
108
+ <li class="method">
109
+ <a href="Tidal/ClientV1.html#method-i-get_multiple_tracks">#get_multiple_tracks</a>
110
+ &mdash;
111
+ <span class="container">Tidal::ClientV1</span>
112
+
113
+ <li class="method">
114
+ <a href="Tidal/ClientV1.html#method-i-get_multiple_videos">#get_multiple_videos</a>
115
+ &mdash;
116
+ <span class="container">Tidal::ClientV1</span>
117
+
118
+ <li class="method">
119
+ <a href="Tidal/ClientV1.html#method-i-get_search">#get_search</a>
120
+ &mdash;
121
+ <span class="container">Tidal::ClientV1</span>
122
+
123
+ <li class="method">
124
+ <a href="Tidal/ClientV1.html#method-i-get_similar_albums">#get_similar_albums</a>
125
+ &mdash;
126
+ <span class="container">Tidal::ClientV1</span>
127
+
128
+ <li class="method">
129
+ <a href="Tidal/ClientV1.html#method-i-get_similar_artists">#get_similar_artists</a>
130
+ &mdash;
131
+ <span class="container">Tidal::ClientV1</span>
132
+
133
+ <li class="method">
134
+ <a href="Tidal/ClientV1.html#method-i-get_similar_tracks">#get_similar_tracks</a>
135
+ &mdash;
136
+ <span class="container">Tidal::ClientV1</span>
137
+
138
+ <li class="method">
139
+ <a href="Tidal/ClientV1.html#method-i-get_single_album">#get_single_album</a>
140
+ &mdash;
141
+ <span class="container">Tidal::ClientV1</span>
142
+
143
+ <li class="method">
144
+ <a href="Tidal/ClientV1.html#method-i-get_single_artist">#get_single_artist</a>
145
+ &mdash;
146
+ <span class="container">Tidal::ClientV1</span>
147
+
148
+ <li class="method">
149
+ <a href="Tidal/ClientV1.html#method-i-get_single_track">#get_single_track</a>
150
+ &mdash;
151
+ <span class="container">Tidal::ClientV1</span>
152
+
153
+ <li class="method">
154
+ <a href="Tidal/ClientV1.html#method-i-get_single_video">#get_single_video</a>
155
+ &mdash;
156
+ <span class="container">Tidal::ClientV1</span>
157
+
158
+ <li class="method">
159
+ <a href="Tidal/ClientV1.html#method-i-get_tracks_by_artist">#get_tracks_by_artist</a>
160
+ &mdash;
161
+ <span class="container">Tidal::ClientV1</span>
162
+
163
+ <li class="method">
164
+ <a href="Tidal/ClientV1.html#method-i-get_tracks_by_isrc">#get_tracks_by_isrc</a>
165
+ &mdash;
166
+ <span class="container">Tidal::ClientV1</span>
167
+ </ul>
168
+ </main>
169
+
170
+
171
+ <footer id="validator-badges" role="contentinfo">
172
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
173
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
174
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
175
+ </footer>
176
+
@@ -8,6 +8,10 @@ module Tidal
8
8
 
9
9
  attr_reader :access_token
10
10
 
11
+ # Initialize the Tidal client
12
+ #
13
+ # @param client_id [String] The client ID for the Tidal API
14
+ # @param client_secret [String] The client secret for the Tidal API
11
15
  def initialize(client_id, client_secret)
12
16
  @client_id = client_id
13
17
  @client_secret = client_secret
@@ -15,6 +19,11 @@ module Tidal
15
19
  @access_token = @client.client_credentials.get_token.token
16
20
  end
17
21
 
22
+ # Get albums by barcode ID
23
+ #
24
+ # @param barcode_id [String] The barcode ID
25
+ # @param country_code [String] The country code
26
+ # @return [Array] The list of albums
18
27
  def get_albums_by_barcode_id(barcode_id, country_code)
19
28
  uri = URI("#{BASE_URL}/albums/byBarcodeId")
20
29
  params = { barcodeId: barcode_id, countryCode: country_code }
@@ -24,6 +33,11 @@ module Tidal
24
33
  JSON.parse(response.body)
25
34
  end
26
35
 
36
+ # Get multiple albums
37
+ #
38
+ # @param ids [Array] The array of album IDs
39
+ # @param country_code [String] The country code
40
+ # @return [Array] The list of albums
27
41
  def get_multiple_albums(ids, country_code)
28
42
  uri = URI("#{BASE_URL}/albums/byIds")
29
43
  params = { ids: ids.join(','), countryCode: country_code }
@@ -33,7 +47,13 @@ module Tidal
33
47
  JSON.parse(response.body)
34
48
  end
35
49
 
36
-
50
+ # Get album items
51
+ #
52
+ # @param album_id [String] The album ID
53
+ # @param country_code [String] The country code
54
+ # @param offset [Integer, nil] The offset for pagination
55
+ # @param limit [Integer, nil] The limit for pagination
56
+ # @return [Array] The list of album items
37
57
  def get_album_items(album_id, country_code, offset = nil, limit = nil)
38
58
  uri = URI("#{BASE_URL}/albums/#{album_id}/items")
39
59
  params = { countryCode: country_code }
@@ -45,6 +65,13 @@ module Tidal
45
65
  JSON.parse(response.body)
46
66
  end
47
67
 
68
+ # Get similar albums
69
+ #
70
+ # @param album_id [String] The album ID
71
+ # @param country_code [String] The country code
72
+ # @param offset [Integer, nil] The offset for pagination
73
+ # @param limit [Integer, nil] The limit for pagination
74
+ # @return [Array] The list of similar albums
48
75
  def get_similar_albums(album_id, country_code, offset = nil, limit = nil)
49
76
  uri = URI("#{BASE_URL}/albums/#{album_id}/similar")
50
77
  params = { countryCode: country_code }
@@ -56,6 +83,11 @@ module Tidal
56
83
  JSON.parse(response.body)
57
84
  end
58
85
 
86
+ # Get a single album
87
+ #
88
+ # @param album_id [String] The album ID
89
+ # @param country_code [String] The country code
90
+ # @return [Hash] The album data
59
91
  def get_single_album(album_id, country_code)
60
92
  uri = URI("#{BASE_URL}/albums/#{album_id}")
61
93
  params = { countryCode: country_code }
@@ -65,6 +97,13 @@ module Tidal
65
97
  JSON.parse(response.body)
66
98
  end
67
99
 
100
+ # Get albums by artist
101
+ #
102
+ # @param artist_id [String] The artist ID
103
+ # @param country_code [String] The country code
104
+ # @param offset [Integer, nil] The offset for pagination
105
+ # @param limit [Integer, nil] The limit for pagination
106
+ # @return [Array] The list of albums by the artist
68
107
  def get_albums_by_artist(artist_id, country_code, offset = nil, limit = nil)
69
108
  uri = URI("#{BASE_URL}/artists/#{artist_id}/albums")
70
109
  params = { countryCode: country_code }
@@ -76,6 +115,11 @@ module Tidal
76
115
  JSON.parse(response.body)
77
116
  end
78
117
 
118
+ # Get multiple artists
119
+ #
120
+ # @param ids [Array] The array of artist IDs
121
+ # @param country_code [String] The country code
122
+ # @return [Array] The list of artists
79
123
  def get_multiple_artists(ids, country_code)
80
124
  uri = URI("#{BASE_URL}/artists")
81
125
  params = { ids: ids.join(','), countryCode: country_code }
@@ -85,6 +129,13 @@ module Tidal
85
129
  JSON.parse(response.body)
86
130
  end
87
131
 
132
+ # Get similar artists
133
+ #
134
+ # @param artist_id [String] The artist ID
135
+ # @param country_code [String] The country code
136
+ # @param offset [Integer, nil] The offset for pagination
137
+ # @param limit [Integer, nil] The limit for pagination
138
+ # @return [Array] The list of similar artists
88
139
  def get_similar_artists(artist_id, country_code, offset = nil, limit = nil)
89
140
  uri = URI("#{BASE_URL}/artists/#{artist_id}/similar")
90
141
  params = { countryCode: country_code }
@@ -96,6 +147,11 @@ module Tidal
96
147
  JSON.parse(response.body)
97
148
  end
98
149
 
150
+ # Get a single artist
151
+ #
152
+ # @param artist_id [String] The artist ID
153
+ # @param country_code [String] The country code
154
+ # @return [Hash] The artist data
99
155
  def get_single_artist(artist_id, country_code)
100
156
  uri = URI("#{BASE_URL}/artists/#{artist_id}")
101
157
  params = { countryCode: country_code }
@@ -105,6 +161,14 @@ module Tidal
105
161
  JSON.parse(response.body)
106
162
  end
107
163
 
164
+ # Get tracks by artist
165
+ #
166
+ # @param artist_id [String] The artist ID
167
+ # @param country_code [String] The country code
168
+ # @param collapse_by [String, nil] The collapse criteria
169
+ # @param offset [Integer, nil] The offset for pagination
170
+ # @param limit [Integer, nil] The limit for pagination
171
+ # @return [Array] The list of tracks by the artist
108
172
  def get_tracks_by_artist(artist_id, country_code, collapse_by = nil, offset = nil, limit = nil)
109
173
  uri = URI("#{BASE_URL}/artists/#{artist_id}/tracks")
110
174
  params = { countryCode: country_code }
@@ -117,6 +181,11 @@ module Tidal
117
181
  JSON.parse(response.body)
118
182
  end
119
183
 
184
+ # Get multiple tracks
185
+ #
186
+ # @param ids [Array] The array of track IDs
187
+ # @param country_code [String] The country code
188
+ # @return [Array] The list of tracks
120
189
  def get_multiple_tracks(ids, country_code)
121
190
  uri = URI("#{BASE_URL}/tracks")
122
191
  params = { ids: ids.join(','), countryCode: country_code }
@@ -126,6 +195,13 @@ module Tidal
126
195
  JSON.parse(response.body)
127
196
  end
128
197
 
198
+ # Get tracks by ISRC
199
+ #
200
+ # @param isrc [String] The ISRC code
201
+ # @param country_code [String] The country code
202
+ # @param offset [Integer, nil] The offset for pagination
203
+ # @param limit [Integer, nil] The limit for pagination
204
+ # @return [Array] The list of tracks by ISRC
129
205
  def get_tracks_by_isrc(isrc, country_code, offset = nil, limit = nil)
130
206
  uri = URI("#{BASE_URL}/tracks/byIsrc")
131
207
  params = { isrc: isrc, countryCode: country_code }
@@ -137,6 +213,11 @@ module Tidal
137
213
  JSON.parse(response.body)
138
214
  end
139
215
 
216
+ # Get a single track
217
+ #
218
+ # @param artist_id [String] The artist ID
219
+ # @param country_code [String] The country code
220
+ # @return [Hash] The track data
140
221
  def get_single_track(artist_id, country_code)
141
222
  uri = URI("#{BASE_URL}/tracks/#{artist_id}")
142
223
  params = { countryCode: country_code }
@@ -146,6 +227,13 @@ module Tidal
146
227
  JSON.parse(response.body)
147
228
  end
148
229
 
230
+ # Get similar tracks
231
+ #
232
+ # @param track_id [String] The track ID
233
+ # @param country_code [String] The country code
234
+ # @param offset [Integer, nil] The offset for pagination
235
+ # @param limit [Integer, nil] The limit for pagination
236
+ # @return [Array] The list of similar tracks
149
237
  def get_similar_tracks(track_id, country_code, offset = nil, limit = nil)
150
238
  uri = URI("#{BASE_URL}/tracks/#{track_id}/similar")
151
239
  params = { countryCode: country_code }
@@ -157,6 +245,11 @@ module Tidal
157
245
  JSON.parse(response.body)
158
246
  end
159
247
 
248
+ # Get multiple videos
249
+ #
250
+ # @param ids [Array] The array of video IDs
251
+ # @param country_code [String] The country code
252
+ # @return [Array] The list of videos
160
253
  def get_multiple_videos(ids, country_code)
161
254
  uri = URI("#{BASE_URL}/videos")
162
255
  params = { ids: ids.join(','), countryCode: country_code }
@@ -166,6 +259,11 @@ module Tidal
166
259
  JSON.parse(response.body)
167
260
  end
168
261
 
262
+ # Get a single video
263
+ #
264
+ # @param video_id [String] The video ID
265
+ # @param country_code [String] The country code
266
+ # @return [Hash] The video data
169
267
  def get_single_video(video_id, country_code)
170
268
  uri = URI("#{BASE_URL}/videos/#{video_id}")
171
269
  params = { countryCode: country_code }
@@ -175,6 +273,15 @@ module Tidal
175
273
  JSON.parse(response.body)
176
274
  end
177
275
 
276
+ # Search for content
277
+ #
278
+ # @param query [String] The search query
279
+ # @param country_code [String] The country code
280
+ # @param type [String, nil] The type of content to search for
281
+ # @param popularity [String, nil] The popularity filter
282
+ # @param offset [Integer, nil] The offset for pagination
283
+ # @param limit [Integer, nil] The limit for pagination
284
+ # @return [Hash] The search results
178
285
  def get_search(query, country_code, type = nil, popularity = nil, offset = nil, limit = nil)
179
286
  uri = URI("#{BASE_URL}/search")
180
287
  params = { query: query, countryCode: country_code }
@@ -190,6 +297,9 @@ module Tidal
190
297
 
191
298
  private
192
299
 
300
+ # Default headers for requests
301
+ #
302
+ # @return [Hash] The default headers
193
303
  def default_headers
194
304
  {
195
305
  'accept' => "application/vnd.tidal.v1+json",
data/lib/tidal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tidal
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end