odesli.js 1.3.5 → 1.3.6
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.
- package/.prettierignore +30 -30
- package/API_IMPROVEMENTS.md +16 -16
- package/LICENSE +14 -14
- package/README.md +465 -82
- package/RELEASE_NOTES_1.1.0.md +1 -1
- package/examples/README.md +281 -60
- package/examples/advanced-features-example.js +4 -4
- package/examples/advanced-usage.js +3 -3
- package/examples/basic-usage.js +4 -9
- package/examples/cache-test.js +1 -1
- package/examples/rate-limiter-strategies.js +83 -0
- package/examples/test-apple-music-extraction.js +1 -1
- package/examples/user-agent-example.js +1 -1
- package/lib/rate-limiter.js +16 -15
- package/package.json +13 -1
package/.prettierignore
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
|
|
4
|
-
# Build outputs
|
|
5
|
-
lib/
|
|
6
|
-
dist/
|
|
7
|
-
build/
|
|
8
|
-
|
|
9
|
-
# Coverage reports
|
|
10
|
-
coverage/
|
|
11
|
-
|
|
12
|
-
# Logs
|
|
13
|
-
*.log
|
|
14
|
-
|
|
15
|
-
# Environment files
|
|
16
|
-
.env*
|
|
17
|
-
|
|
18
|
-
# Package files
|
|
19
|
-
package-lock.json
|
|
20
|
-
yarn.lock
|
|
21
|
-
|
|
22
|
-
# Git
|
|
23
|
-
.git/
|
|
24
|
-
|
|
25
|
-
# IDE
|
|
26
|
-
.vscode/
|
|
27
|
-
.idea/
|
|
28
|
-
|
|
29
|
-
# OS
|
|
30
|
-
.DS_Store
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build outputs
|
|
5
|
+
lib/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
|
|
9
|
+
# Coverage reports
|
|
10
|
+
coverage/
|
|
11
|
+
|
|
12
|
+
# Logs
|
|
13
|
+
*.log
|
|
14
|
+
|
|
15
|
+
# Environment files
|
|
16
|
+
.env*
|
|
17
|
+
|
|
18
|
+
# Package files
|
|
19
|
+
package-lock.json
|
|
20
|
+
yarn.lock
|
|
21
|
+
|
|
22
|
+
# Git
|
|
23
|
+
.git/
|
|
24
|
+
|
|
25
|
+
# IDE
|
|
26
|
+
.vscode/
|
|
27
|
+
.idea/
|
|
28
|
+
|
|
29
|
+
# OS
|
|
30
|
+
.DS_Store
|
|
31
31
|
Thumbs.db
|
package/API_IMPROVEMENTS.md
CHANGED
|
@@ -8,7 +8,7 @@ This document outlines the comprehensive improvements made to the Odesli API cli
|
|
|
8
8
|
|
|
9
9
|
The constructor now accepts a comprehensive options object with the following parameters:
|
|
10
10
|
|
|
11
|
-
```
|
|
11
|
+
```js
|
|
12
12
|
const odesli = new Odesli({
|
|
13
13
|
// Core options
|
|
14
14
|
apiKey: 'your-api-key', // Optional API key for higher rate limits
|
|
@@ -38,7 +38,7 @@ All methods now support both backward-compatible string parameters and new optio
|
|
|
38
38
|
|
|
39
39
|
#### `fetch(url, options)`
|
|
40
40
|
|
|
41
|
-
```
|
|
41
|
+
```js
|
|
42
42
|
// Backward compatible
|
|
43
43
|
const song = await odesli.fetch(url, 'GB');
|
|
44
44
|
|
|
@@ -52,7 +52,7 @@ const song = await odesli.fetch(url, {
|
|
|
52
52
|
|
|
53
53
|
#### `getByParams(platform, type, id, options)`
|
|
54
54
|
|
|
55
|
-
```
|
|
55
|
+
```js
|
|
56
56
|
// Backward compatible
|
|
57
57
|
const song = await odesli.getByParams('spotify', 'song', '123', 'GB');
|
|
58
58
|
|
|
@@ -66,7 +66,7 @@ const song = await odesli.getByParams('spotify', 'song', '123', {
|
|
|
66
66
|
|
|
67
67
|
#### `getById(id, options)`
|
|
68
68
|
|
|
69
|
-
```
|
|
69
|
+
```js
|
|
70
70
|
// Backward compatible
|
|
71
71
|
const song = await odesli.getById('SPOTIFY_SONG::123', 'GB');
|
|
72
72
|
|
|
@@ -82,7 +82,7 @@ const song = await odesli.getById('SPOTIFY_SONG::123', {
|
|
|
82
82
|
|
|
83
83
|
### Batch Operations
|
|
84
84
|
|
|
85
|
-
```
|
|
85
|
+
```js
|
|
86
86
|
// Fetch multiple songs with concurrency control
|
|
87
87
|
const urls = [
|
|
88
88
|
'https://open.spotify.com/track/123',
|
|
@@ -99,7 +99,7 @@ const results = await odesli.fetchBatch(urls, {
|
|
|
99
99
|
|
|
100
100
|
### Platform Detection
|
|
101
101
|
|
|
102
|
-
```
|
|
102
|
+
```js
|
|
103
103
|
// Detect platform from URL
|
|
104
104
|
const platform = odesli.detectPlatform('https://open.spotify.com/track/123');
|
|
105
105
|
console.log(platform); // 'spotify'
|
|
@@ -113,7 +113,7 @@ console.log(id); // '4Km5HrUvYTaSUfiSGPJeQR'
|
|
|
113
113
|
|
|
114
114
|
### Platform Information
|
|
115
115
|
|
|
116
|
-
```
|
|
116
|
+
```js
|
|
117
117
|
// Get list of supported platforms
|
|
118
118
|
const platforms = odesli.getSupportedPlatforms();
|
|
119
119
|
console.log(platforms); // ['spotify', 'appleMusic', 'youtube', ...]
|
|
@@ -121,7 +121,7 @@ console.log(platforms); // ['spotify', 'appleMusic', 'youtube', ...]
|
|
|
121
121
|
|
|
122
122
|
### Enhanced Cache Statistics
|
|
123
123
|
|
|
124
|
-
```
|
|
124
|
+
```js
|
|
125
125
|
// Get detailed cache statistics
|
|
126
126
|
const stats = odesli.getCacheStats();
|
|
127
127
|
console.log(`Cache size: ${stats.size}`);
|
|
@@ -146,7 +146,7 @@ console.log(`Total requests: ${stats.totalRequests}`);
|
|
|
146
146
|
|
|
147
147
|
### Enhanced Error Messages
|
|
148
148
|
|
|
149
|
-
```
|
|
149
|
+
```js
|
|
150
150
|
// Clear, descriptive error messages
|
|
151
151
|
try {
|
|
152
152
|
await odesli.fetch('invalid-url');
|
|
@@ -165,7 +165,7 @@ try {
|
|
|
165
165
|
|
|
166
166
|
All existing code continues to work without modification:
|
|
167
167
|
|
|
168
|
-
```
|
|
168
|
+
```js
|
|
169
169
|
// These all still work exactly as before
|
|
170
170
|
const song1 = await odesli.fetch('https://open.spotify.com/track/123');
|
|
171
171
|
const song2 = await odesli.fetch('https://open.spotify.com/track/123', 'GB');
|
|
@@ -199,7 +199,7 @@ const song6 = await odesli.getById('SPOTIFY_SONG::123', 'GB');
|
|
|
199
199
|
|
|
200
200
|
### Logging Support
|
|
201
201
|
|
|
202
|
-
```
|
|
202
|
+
```js
|
|
203
203
|
const odesli = new Odesli({
|
|
204
204
|
logger: (message, level) => {
|
|
205
205
|
console.log(`[${level.toUpperCase()}] ${message}`);
|
|
@@ -209,7 +209,7 @@ const odesli = new Odesli({
|
|
|
209
209
|
|
|
210
210
|
### Validation Control
|
|
211
211
|
|
|
212
|
-
```
|
|
212
|
+
```js
|
|
213
213
|
// Disable validation for performance
|
|
214
214
|
const odesli = new Odesli({
|
|
215
215
|
validateParams: false,
|
|
@@ -228,7 +228,7 @@ const odesli = new Odesli({
|
|
|
228
228
|
|
|
229
229
|
### Production Applications
|
|
230
230
|
|
|
231
|
-
```
|
|
231
|
+
```js
|
|
232
232
|
const odesli = new Odesli({
|
|
233
233
|
apiKey: process.env.ODESLI_API_KEY,
|
|
234
234
|
maxRetries: 3,
|
|
@@ -245,7 +245,7 @@ const odesli = new Odesli({
|
|
|
245
245
|
|
|
246
246
|
### Development & Testing
|
|
247
247
|
|
|
248
|
-
```
|
|
248
|
+
```js
|
|
249
249
|
const odesli = new Odesli({
|
|
250
250
|
cache: false,
|
|
251
251
|
validateParams: true,
|
|
@@ -256,7 +256,7 @@ const odesli = new Odesli({
|
|
|
256
256
|
|
|
257
257
|
### High-Volume Processing
|
|
258
258
|
|
|
259
|
-
```
|
|
259
|
+
```js
|
|
260
260
|
const odesli = new Odesli({
|
|
261
261
|
apiKey: process.env.ODESLI_API_KEY,
|
|
262
262
|
maxRetries: 5,
|
|
@@ -291,7 +291,7 @@ No migration required! All existing code continues to work unchanged.
|
|
|
291
291
|
|
|
292
292
|
Use the new options objects for enhanced functionality:
|
|
293
293
|
|
|
294
|
-
```
|
|
294
|
+
```js
|
|
295
295
|
// Old way (still works)
|
|
296
296
|
const song = await odesli.fetch(url, 'GB');
|
|
297
297
|
|
package/LICENSE
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024, Mattr
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Mattr
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
15
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|