odesli.js 1.3.5 → 1.3.7
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/CHANGELOG.md +106 -0
- package/LICENSE +14 -14
- package/README.md +467 -91
- 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/index.d.ts +391 -363
- package/lib/rate-limiter.js +16 -15
- package/package.json +13 -1
package/lib/index.d.ts
CHANGED
|
@@ -3,264 +3,264 @@
|
|
|
3
3
|
// Definitions by: Mattr <https://github.com/MattrAus>
|
|
4
4
|
// TypeScript Version: 2.7
|
|
5
5
|
|
|
6
|
-
// Export the CountryCode type
|
|
6
|
+
// Export the CountryCode type with enhanced intellisense
|
|
7
7
|
type CountryCode =
|
|
8
|
-
| "AF"
|
|
9
|
-
| "AX"
|
|
10
|
-
| "AL"
|
|
11
|
-
| "DZ"
|
|
12
|
-
| "AS"
|
|
13
|
-
| "AD"
|
|
14
|
-
| "AO"
|
|
15
|
-
| "AI"
|
|
16
|
-
| "AQ"
|
|
17
|
-
| "AG"
|
|
18
|
-
| "AR"
|
|
19
|
-
| "AM"
|
|
20
|
-
| "AW"
|
|
21
|
-
| "AU"
|
|
22
|
-
| "AT"
|
|
23
|
-
| "AZ"
|
|
24
|
-
| "BS"
|
|
25
|
-
| "BH"
|
|
26
|
-
| "BD"
|
|
27
|
-
| "BB"
|
|
28
|
-
| "BY"
|
|
29
|
-
| "BE"
|
|
30
|
-
| "BZ"
|
|
31
|
-
| "BJ"
|
|
32
|
-
| "BM"
|
|
33
|
-
| "BT"
|
|
34
|
-
| "BO"
|
|
35
|
-
| "BQ"
|
|
36
|
-
| "BA"
|
|
37
|
-
| "BW"
|
|
38
|
-
| "BV"
|
|
39
|
-
| "BR"
|
|
40
|
-
| "IO"
|
|
41
|
-
| "BN"
|
|
42
|
-
| "BG"
|
|
43
|
-
| "BF"
|
|
44
|
-
| "BI"
|
|
45
|
-
| "KH"
|
|
46
|
-
| "CM"
|
|
47
|
-
| "CA"
|
|
48
|
-
| "CV"
|
|
49
|
-
| "KY"
|
|
50
|
-
| "CF"
|
|
51
|
-
| "TD"
|
|
52
|
-
| "CL"
|
|
53
|
-
| "CN"
|
|
54
|
-
| "CX"
|
|
55
|
-
| "CC"
|
|
56
|
-
| "CO"
|
|
57
|
-
| "KM"
|
|
58
|
-
| "CG"
|
|
59
|
-
| "CD"
|
|
60
|
-
| "CK"
|
|
61
|
-
| "CR"
|
|
62
|
-
| "CI"
|
|
63
|
-
| "HR"
|
|
64
|
-
| "CU"
|
|
65
|
-
| "CW"
|
|
66
|
-
| "CY"
|
|
67
|
-
| "CZ"
|
|
68
|
-
| "DK"
|
|
69
|
-
| "DJ"
|
|
70
|
-
| "DM"
|
|
71
|
-
| "DO"
|
|
72
|
-
| "EC"
|
|
73
|
-
| "EG"
|
|
74
|
-
| "SV"
|
|
75
|
-
| "GQ"
|
|
76
|
-
| "ER"
|
|
77
|
-
| "EE"
|
|
78
|
-
| "ET"
|
|
79
|
-
| "FK"
|
|
80
|
-
| "FO"
|
|
81
|
-
| "FJ"
|
|
82
|
-
| "FI"
|
|
83
|
-
| "FR"
|
|
84
|
-
| "GF"
|
|
85
|
-
| "PF"
|
|
86
|
-
| "TF"
|
|
87
|
-
| "GA"
|
|
88
|
-
| "GM"
|
|
89
|
-
| "GE"
|
|
90
|
-
| "DE"
|
|
91
|
-
| "GH"
|
|
92
|
-
| "GI"
|
|
93
|
-
| "GR"
|
|
94
|
-
| "GL"
|
|
95
|
-
| "GD"
|
|
96
|
-
| "GP"
|
|
97
|
-
| "GU"
|
|
98
|
-
| "GT"
|
|
99
|
-
| "GG"
|
|
100
|
-
| "GN"
|
|
101
|
-
| "GW"
|
|
102
|
-
| "GY"
|
|
103
|
-
| "HT"
|
|
104
|
-
| "HM"
|
|
105
|
-
| "VA"
|
|
106
|
-
| "HN"
|
|
107
|
-
| "HK"
|
|
108
|
-
| "HU"
|
|
109
|
-
| "IS"
|
|
110
|
-
| "IN"
|
|
111
|
-
| "ID"
|
|
112
|
-
| "IR"
|
|
113
|
-
| "IQ"
|
|
114
|
-
| "IE"
|
|
115
|
-
| "IM"
|
|
116
|
-
| "IL"
|
|
117
|
-
| "IT"
|
|
118
|
-
| "JM"
|
|
119
|
-
| "JP"
|
|
120
|
-
| "JE"
|
|
121
|
-
| "JO"
|
|
122
|
-
| "KZ"
|
|
123
|
-
| "KE"
|
|
124
|
-
| "KI"
|
|
125
|
-
| "KR"
|
|
126
|
-
| "KP"
|
|
127
|
-
| "KW"
|
|
128
|
-
| "KG"
|
|
129
|
-
| "LA"
|
|
130
|
-
| "LV"
|
|
131
|
-
| "LB"
|
|
132
|
-
| "LS"
|
|
133
|
-
| "LR"
|
|
134
|
-
| "LY"
|
|
135
|
-
| "LI"
|
|
136
|
-
| "LT"
|
|
137
|
-
| "LU"
|
|
138
|
-
| "MO"
|
|
139
|
-
| "MK"
|
|
140
|
-
| "MG"
|
|
141
|
-
| "MW"
|
|
142
|
-
| "MY"
|
|
143
|
-
| "MV"
|
|
144
|
-
| "ML"
|
|
145
|
-
| "MT"
|
|
146
|
-
| "MH"
|
|
147
|
-
| "MQ"
|
|
148
|
-
| "MR"
|
|
149
|
-
| "MU"
|
|
150
|
-
| "YT"
|
|
151
|
-
| "MX"
|
|
152
|
-
| "FM"
|
|
153
|
-
| "MD"
|
|
154
|
-
| "MC"
|
|
155
|
-
| "MN"
|
|
156
|
-
| "ME"
|
|
157
|
-
| "MS"
|
|
158
|
-
| "MA"
|
|
159
|
-
| "MZ"
|
|
160
|
-
| "MM"
|
|
161
|
-
| "NA"
|
|
162
|
-
| "NR"
|
|
163
|
-
| "NP"
|
|
164
|
-
| "NL"
|
|
165
|
-
| "NC"
|
|
166
|
-
| "NZ"
|
|
167
|
-
| "NI"
|
|
168
|
-
| "NE"
|
|
169
|
-
| "NG"
|
|
170
|
-
| "NU"
|
|
171
|
-
| "NF"
|
|
172
|
-
| "MP"
|
|
173
|
-
| "NO"
|
|
174
|
-
| "OM"
|
|
175
|
-
| "PK"
|
|
176
|
-
| "PW"
|
|
177
|
-
| "PS"
|
|
178
|
-
| "PA"
|
|
179
|
-
| "PG"
|
|
180
|
-
| "PY"
|
|
181
|
-
| "PE"
|
|
182
|
-
| "PH"
|
|
183
|
-
| "PN"
|
|
184
|
-
| "PL"
|
|
185
|
-
| "PT"
|
|
186
|
-
| "PR"
|
|
187
|
-
| "QA"
|
|
188
|
-
| "RE"
|
|
189
|
-
| "RO"
|
|
190
|
-
| "RU"
|
|
191
|
-
| "RW"
|
|
192
|
-
| "BL"
|
|
193
|
-
| "SH"
|
|
194
|
-
| "KN"
|
|
195
|
-
| "LC"
|
|
196
|
-
| "MF"
|
|
197
|
-
| "PM"
|
|
198
|
-
| "VC"
|
|
199
|
-
| "WS"
|
|
200
|
-
| "SM"
|
|
201
|
-
| "ST"
|
|
202
|
-
| "SA"
|
|
203
|
-
| "SN"
|
|
204
|
-
| "RS"
|
|
205
|
-
| "SC"
|
|
206
|
-
| "SL"
|
|
207
|
-
| "SG"
|
|
208
|
-
| "SX"
|
|
209
|
-
| "SK"
|
|
210
|
-
| "SI"
|
|
211
|
-
| "SB"
|
|
212
|
-
| "SO"
|
|
213
|
-
| "ZA"
|
|
214
|
-
| "GS"
|
|
215
|
-
| "SS"
|
|
216
|
-
| "ES"
|
|
217
|
-
| "LK"
|
|
218
|
-
| "SD"
|
|
219
|
-
| "SR"
|
|
220
|
-
| "SJ"
|
|
221
|
-
| "SZ"
|
|
222
|
-
| "SE"
|
|
223
|
-
| "CH"
|
|
224
|
-
| "SY"
|
|
225
|
-
| "TW"
|
|
226
|
-
| "TJ"
|
|
227
|
-
| "TZ"
|
|
228
|
-
| "TH"
|
|
229
|
-
| "TL"
|
|
230
|
-
| "TG"
|
|
231
|
-
| "TK"
|
|
232
|
-
| "TO"
|
|
233
|
-
| "TT"
|
|
234
|
-
| "TN"
|
|
235
|
-
| "TR"
|
|
236
|
-
| "TM"
|
|
237
|
-
| "TC"
|
|
238
|
-
| "TV"
|
|
239
|
-
| "UG"
|
|
240
|
-
| "UA"
|
|
241
|
-
| "AE"
|
|
242
|
-
| "GB"
|
|
243
|
-
| "US"
|
|
244
|
-
| "UM"
|
|
245
|
-
| "UY"
|
|
246
|
-
| "UZ"
|
|
247
|
-
| "VU"
|
|
248
|
-
| "VE"
|
|
249
|
-
| "VN"
|
|
250
|
-
| "VG"
|
|
251
|
-
| "VI"
|
|
252
|
-
| "WF"
|
|
253
|
-
| "EH"
|
|
254
|
-
| "YE"
|
|
255
|
-
| "ZM"
|
|
256
|
-
| "ZW";
|
|
8
|
+
| "AF" // Afghanistan
|
|
9
|
+
| "AX" // Aland Islands
|
|
10
|
+
| "AL" // Albania
|
|
11
|
+
| "DZ" // Algeria
|
|
12
|
+
| "AS" // American Samoa
|
|
13
|
+
| "AD" // Andorra
|
|
14
|
+
| "AO" // Angola
|
|
15
|
+
| "AI" // Anguilla
|
|
16
|
+
| "AQ" // Antarctica
|
|
17
|
+
| "AG" // Antigua and Barbuda
|
|
18
|
+
| "AR" // Argentina
|
|
19
|
+
| "AM" // Armenia
|
|
20
|
+
| "AW" // Aruba
|
|
21
|
+
| "AU" // Australia
|
|
22
|
+
| "AT" // Austria
|
|
23
|
+
| "AZ" // Azerbaijan
|
|
24
|
+
| "BS" // Bahamas
|
|
25
|
+
| "BH" // Bahrain
|
|
26
|
+
| "BD" // Bangladesh
|
|
27
|
+
| "BB" // Barbados
|
|
28
|
+
| "BY" // Belarus
|
|
29
|
+
| "BE" // Belgium
|
|
30
|
+
| "BZ" // Belize
|
|
31
|
+
| "BJ" // Benin
|
|
32
|
+
| "BM" // Bermuda
|
|
33
|
+
| "BT" // Bhutan
|
|
34
|
+
| "BO" // Bolivia
|
|
35
|
+
| "BQ" // Bonaire, Sint Eustatius and Saba
|
|
36
|
+
| "BA" // Bosnia and Herzegovina
|
|
37
|
+
| "BW" // Botswana
|
|
38
|
+
| "BV" // Bouvet Island
|
|
39
|
+
| "BR" // Brazil
|
|
40
|
+
| "IO" // British Indian Ocean Territory
|
|
41
|
+
| "BN" // Brunei Darussalam
|
|
42
|
+
| "BG" // Bulgaria
|
|
43
|
+
| "BF" // Burkina Faso
|
|
44
|
+
| "BI" // Burundi
|
|
45
|
+
| "KH" // Cambodia
|
|
46
|
+
| "CM" // Cameroon
|
|
47
|
+
| "CA" // Canada
|
|
48
|
+
| "CV" // Cape Verde
|
|
49
|
+
| "KY" // Cayman Islands
|
|
50
|
+
| "CF" // Central African Republic
|
|
51
|
+
| "TD" // Chad
|
|
52
|
+
| "CL" // Chile
|
|
53
|
+
| "CN" // China
|
|
54
|
+
| "CX" // Christmas Island
|
|
55
|
+
| "CC" // Cocos (Keeling) Islands
|
|
56
|
+
| "CO" // Colombia
|
|
57
|
+
| "KM" // Comoros
|
|
58
|
+
| "CG" // Congo
|
|
59
|
+
| "CD" // Congo, Democratic Republic
|
|
60
|
+
| "CK" // Cook Islands
|
|
61
|
+
| "CR" // Costa Rica
|
|
62
|
+
| "CI" // Cote d'Ivoire
|
|
63
|
+
| "HR" // Croatia
|
|
64
|
+
| "CU" // Cuba
|
|
65
|
+
| "CW" // Curaçao
|
|
66
|
+
| "CY" // Cyprus
|
|
67
|
+
| "CZ" // Czech Republic
|
|
68
|
+
| "DK" // Denmark
|
|
69
|
+
| "DJ" // Djibouti
|
|
70
|
+
| "DM" // Dominica
|
|
71
|
+
| "DO" // Dominican Republic
|
|
72
|
+
| "EC" // Ecuador
|
|
73
|
+
| "EG" // Egypt
|
|
74
|
+
| "SV" // El Salvador
|
|
75
|
+
| "GQ" // Equatorial Guinea
|
|
76
|
+
| "ER" // Eritrea
|
|
77
|
+
| "EE" // Estonia
|
|
78
|
+
| "ET" // Ethiopia
|
|
79
|
+
| "FK" // Falkland Islands
|
|
80
|
+
| "FO" // Faroe Islands
|
|
81
|
+
| "FJ" // Fiji
|
|
82
|
+
| "FI" // Finland
|
|
83
|
+
| "FR" // France
|
|
84
|
+
| "GF" // French Guiana
|
|
85
|
+
| "PF" // French Polynesia
|
|
86
|
+
| "TF" // French Southern Territories
|
|
87
|
+
| "GA" // Gabon
|
|
88
|
+
| "GM" // Gambia
|
|
89
|
+
| "GE" // Georgia
|
|
90
|
+
| "DE" // Germany
|
|
91
|
+
| "GH" // Ghana
|
|
92
|
+
| "GI" // Gibraltar
|
|
93
|
+
| "GR" // Greece
|
|
94
|
+
| "GL" // Greenland
|
|
95
|
+
| "GD" // Grenada
|
|
96
|
+
| "GP" // Guadeloupe
|
|
97
|
+
| "GU" // Guam
|
|
98
|
+
| "GT" // Guatemala
|
|
99
|
+
| "GG" // Guernsey
|
|
100
|
+
| "GN" // Guinea
|
|
101
|
+
| "GW" // Guinea-Bissau
|
|
102
|
+
| "GY" // Guyana
|
|
103
|
+
| "HT" // Haiti
|
|
104
|
+
| "HM" // Heard Island and McDonald Islands
|
|
105
|
+
| "VA" // Holy See (Vatican City State)
|
|
106
|
+
| "HN" // Honduras
|
|
107
|
+
| "HK" // Hong Kong
|
|
108
|
+
| "HU" // Hungary
|
|
109
|
+
| "IS" // Iceland
|
|
110
|
+
| "IN" // India
|
|
111
|
+
| "ID" // Indonesia
|
|
112
|
+
| "IR" // Iran
|
|
113
|
+
| "IQ" // Iraq
|
|
114
|
+
| "IE" // Ireland
|
|
115
|
+
| "IM" // Isle of Man
|
|
116
|
+
| "IL" // Israel
|
|
117
|
+
| "IT" // Italy
|
|
118
|
+
| "JM" // Jamaica
|
|
119
|
+
| "JP" // Japan
|
|
120
|
+
| "JE" // Jersey
|
|
121
|
+
| "JO" // Jordan
|
|
122
|
+
| "KZ" // Kazakhstan
|
|
123
|
+
| "KE" // Kenya
|
|
124
|
+
| "KI" // Kiribati
|
|
125
|
+
| "KR" // Korea
|
|
126
|
+
| "KP" // Korea, Democratic People's Republic
|
|
127
|
+
| "KW" // Kuwait
|
|
128
|
+
| "KG" // Kyrgyzstan
|
|
129
|
+
| "LA" // Lao People's Democratic Republic
|
|
130
|
+
| "LV" // Latvia
|
|
131
|
+
| "LB" // Lebanon
|
|
132
|
+
| "LS" // Lesotho
|
|
133
|
+
| "LR" // Liberia
|
|
134
|
+
| "LY" // Libyan Arab Jamahiriya
|
|
135
|
+
| "LI" // Liechtenstein
|
|
136
|
+
| "LT" // Lithuania
|
|
137
|
+
| "LU" // Luxembourg
|
|
138
|
+
| "MO" // Macao
|
|
139
|
+
| "MK" // Macedonia
|
|
140
|
+
| "MG" // Madagascar
|
|
141
|
+
| "MW" // Malawi
|
|
142
|
+
| "MY" // Malaysia
|
|
143
|
+
| "MV" // Maldives
|
|
144
|
+
| "ML" // Mali
|
|
145
|
+
| "MT" // Malta
|
|
146
|
+
| "MH" // Marshall Islands
|
|
147
|
+
| "MQ" // Martinique
|
|
148
|
+
| "MR" // Mauritania
|
|
149
|
+
| "MU" // Mauritius
|
|
150
|
+
| "YT" // Mayotte
|
|
151
|
+
| "MX" // Mexico
|
|
152
|
+
| "FM" // Micronesia
|
|
153
|
+
| "MD" // Moldova
|
|
154
|
+
| "MC" // Monaco
|
|
155
|
+
| "MN" // Mongolia
|
|
156
|
+
| "ME" // Montenegro
|
|
157
|
+
| "MS" // Montserrat
|
|
158
|
+
| "MA" // Morocco
|
|
159
|
+
| "MZ" // Mozambique
|
|
160
|
+
| "MM" // Myanmar
|
|
161
|
+
| "NA" // Namibia
|
|
162
|
+
| "NR" // Nauru
|
|
163
|
+
| "NP" // Nepal
|
|
164
|
+
| "NL" // Netherlands
|
|
165
|
+
| "NC" // New Caledonia
|
|
166
|
+
| "NZ" // New Zealand
|
|
167
|
+
| "NI" // Nicaragua
|
|
168
|
+
| "NE" // Niger
|
|
169
|
+
| "NG" // Nigeria
|
|
170
|
+
| "NU" // Niue
|
|
171
|
+
| "NF" // Norfolk Island
|
|
172
|
+
| "MP" // Northern Mariana Islands
|
|
173
|
+
| "NO" // Norway
|
|
174
|
+
| "OM" // Oman
|
|
175
|
+
| "PK" // Pakistan
|
|
176
|
+
| "PW" // Palau
|
|
177
|
+
| "PS" // Palestinian Territory
|
|
178
|
+
| "PA" // Panama
|
|
179
|
+
| "PG" // Papua New Guinea
|
|
180
|
+
| "PY" // Paraguay
|
|
181
|
+
| "PE" // Peru
|
|
182
|
+
| "PH" // Philippines
|
|
183
|
+
| "PN" // Pitcairn
|
|
184
|
+
| "PL" // Poland
|
|
185
|
+
| "PT" // Portugal
|
|
186
|
+
| "PR" // Puerto Rico
|
|
187
|
+
| "QA" // Qatar
|
|
188
|
+
| "RE" // Reunion
|
|
189
|
+
| "RO" // Romania
|
|
190
|
+
| "RU" // Russian Federation
|
|
191
|
+
| "RW" // Rwanda
|
|
192
|
+
| "BL" // Saint Barthelemy
|
|
193
|
+
| "SH" // Saint Helena
|
|
194
|
+
| "KN" // Saint Kitts and Nevis
|
|
195
|
+
| "LC" // Saint Lucia
|
|
196
|
+
| "MF" // Saint Martin
|
|
197
|
+
| "PM" // Saint Pierre and Miquelon
|
|
198
|
+
| "VC" // Saint Vincent and Grenadines
|
|
199
|
+
| "WS" // Samoa
|
|
200
|
+
| "SM" // San Marino
|
|
201
|
+
| "ST" // Sao Tome and Principe
|
|
202
|
+
| "SA" // Saudi Arabia
|
|
203
|
+
| "SN" // Senegal
|
|
204
|
+
| "RS" // Serbia
|
|
205
|
+
| "SC" // Seychelles
|
|
206
|
+
| "SL" // Sierra Leone
|
|
207
|
+
| "SG" // Singapore
|
|
208
|
+
| "SX" // Sint Maarten
|
|
209
|
+
| "SK" // Slovakia
|
|
210
|
+
| "SI" // Slovenia
|
|
211
|
+
| "SB" // Solomon Islands
|
|
212
|
+
| "SO" // Somalia
|
|
213
|
+
| "ZA" // South Africa
|
|
214
|
+
| "GS" // South Georgia and the South Sandwich Islands
|
|
215
|
+
| "SS" // South Sudan
|
|
216
|
+
| "ES" // Spain
|
|
217
|
+
| "LK" // Sri Lanka
|
|
218
|
+
| "SD" // Sudan
|
|
219
|
+
| "SR" // Suriname
|
|
220
|
+
| "SJ" // Svalbard and Jan Mayen
|
|
221
|
+
| "SZ" // Swaziland
|
|
222
|
+
| "SE" // Sweden
|
|
223
|
+
| "CH" // Switzerland
|
|
224
|
+
| "SY" // Syrian Arab Republic
|
|
225
|
+
| "TW" // Taiwan
|
|
226
|
+
| "TJ" // Tajikistan
|
|
227
|
+
| "TZ" // Tanzania
|
|
228
|
+
| "TH" // Thailand
|
|
229
|
+
| "TL" // Timor-Leste
|
|
230
|
+
| "TG" // Togo
|
|
231
|
+
| "TK" // Tokelau
|
|
232
|
+
| "TO" // Tonga
|
|
233
|
+
| "TT" // Trinidad and Tobago
|
|
234
|
+
| "TN" // Tunisia
|
|
235
|
+
| "TR" // Turkey
|
|
236
|
+
| "TM" // Turkmenistan
|
|
237
|
+
| "TC" // Turks and Caicos Islands
|
|
238
|
+
| "TV" // Tuvalu
|
|
239
|
+
| "UG" // Uganda
|
|
240
|
+
| "UA" // Ukraine
|
|
241
|
+
| "AE" // United Arab Emirates
|
|
242
|
+
| "GB" // United Kingdom
|
|
243
|
+
| "US" // United States
|
|
244
|
+
| "UM" // United States Outlying Islands
|
|
245
|
+
| "UY" // Uruguay
|
|
246
|
+
| "UZ" // Uzbekistan
|
|
247
|
+
| "VU" // Vanuatu
|
|
248
|
+
| "VE" // Venezuela
|
|
249
|
+
| "VN" // Vietnam
|
|
250
|
+
| "VG" // Virgin Islands, British
|
|
251
|
+
| "VI" // Virgin Islands, U.S.
|
|
252
|
+
| "WF" // Wallis and Futuna
|
|
253
|
+
| "EH" // Western Sahara
|
|
254
|
+
| "YE" // Yemen
|
|
255
|
+
| "ZM" // Zambia
|
|
256
|
+
| "ZW"; // Zimbabwe
|
|
257
257
|
|
|
258
258
|
// Core Odesli class
|
|
259
259
|
declare class Odesli {
|
|
260
260
|
constructor(options?: OdesliOptions);
|
|
261
261
|
|
|
262
262
|
// Core methods
|
|
263
|
-
fetch(urlOrUrls: string | string[], options?: FetchOptions): Promise<SongData | SongData[]>;
|
|
263
|
+
fetch(urlOrUrls: string | string[], options?: FetchOptions): Promise<SongData | SongData[] | BatchResult>;
|
|
264
264
|
getByParams(platform: string, type: string, id: string, options?: FetchOptions): Promise<SongData>;
|
|
265
265
|
getById(id: string, options?: FetchOptions): Promise<SongData>;
|
|
266
266
|
|
|
@@ -274,66 +274,93 @@ declare class Odesli {
|
|
|
274
274
|
clearCache(): void;
|
|
275
275
|
getCacheStats(): CacheStats;
|
|
276
276
|
|
|
277
|
+
// Metrics methods
|
|
278
|
+
getMetrics(): MetricsCollector;
|
|
279
|
+
|
|
277
280
|
// Static methods
|
|
278
281
|
static getCountryOptions(): Array<{ code: CountryCode; name: string }>;
|
|
279
282
|
}
|
|
280
283
|
|
|
281
|
-
// Configuration options
|
|
284
|
+
// Configuration options for Odesli client
|
|
282
285
|
interface OdesliOptions {
|
|
283
|
-
apiKey?: string;
|
|
284
|
-
version?: string;
|
|
285
|
-
cache?: boolean;
|
|
286
|
-
timeout?: number;
|
|
287
|
-
maxRetries?: number;
|
|
288
|
-
retryDelay?: number;
|
|
289
|
-
headers?: Record<string, string>;
|
|
290
|
-
baseUrl?: string;
|
|
291
|
-
validateParams?: boolean;
|
|
292
|
-
logger?: (message: string, level: string) => void;
|
|
286
|
+
apiKey?: string; // Optional API key for higher rate limits (10+ requests/minute)
|
|
287
|
+
version?: string; // API version to use (default: 'v1-alpha.1')
|
|
288
|
+
cache?: boolean; // Enable response caching with 5-minute TTL (default: true)
|
|
289
|
+
timeout?: number; // Request timeout in milliseconds (default: 10000)
|
|
290
|
+
maxRetries?: number; // Maximum number of retry attempts for failed requests (default: 3)
|
|
291
|
+
retryDelay?: number; // Base delay between retries in milliseconds, uses exponential backoff (default: 1000)
|
|
292
|
+
headers?: Record<string, string>; // Additional headers to include in requests
|
|
293
|
+
baseUrl?: string; // Base URL for API requests (default: 'https://api.song.link')
|
|
294
|
+
validateParams?: boolean; // Enable parameter validation (default: true)
|
|
295
|
+
logger?: (message: string, level: string) => void; // Optional logger function for debugging
|
|
296
|
+
metrics?: MetricsCollector | boolean; // Optional metrics collector instance or `false` to disable
|
|
293
297
|
}
|
|
294
298
|
|
|
295
|
-
//
|
|
299
|
+
// Options for fetch operations
|
|
296
300
|
interface FetchOptions {
|
|
297
|
-
country?: CountryCode;
|
|
298
|
-
skipCache?: boolean;
|
|
299
|
-
timeout?: number;
|
|
300
|
-
concurrency?: number;
|
|
301
|
+
country?: CountryCode; // ISO 3166-1 Alpha-2 country code for region-specific results (default: 'US')
|
|
302
|
+
skipCache?: boolean; // Skip cache for this request (default: false)
|
|
303
|
+
timeout?: number; // Override timeout for this request (default: uses instance timeout)
|
|
304
|
+
concurrency?: number; // Maximum concurrent requests for batch operations (default: 5)
|
|
301
305
|
}
|
|
302
306
|
|
|
303
|
-
//
|
|
307
|
+
// Batch result type for array of URLs
|
|
308
|
+
type BatchResult = Array<SongData | BatchError>;
|
|
309
|
+
|
|
310
|
+
// Error result for batch operations
|
|
311
|
+
interface BatchError {
|
|
312
|
+
success: false;
|
|
313
|
+
url: string;
|
|
314
|
+
error: string;
|
|
315
|
+
platform: string | null;
|
|
316
|
+
extractedId: string | null;
|
|
317
|
+
timestamp: string;
|
|
318
|
+
statusCode: number | null;
|
|
319
|
+
retryable: boolean;
|
|
320
|
+
errorType: 'BAD_REQUEST' | 'UNAUTHORIZED' | 'RATE_LIMITED' | 'NOT_FOUND' | 'TIMEOUT' | 'UNKNOWN';
|
|
321
|
+
suggestion: string;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Song/Album data structure returned by Odesli API
|
|
304
325
|
interface SongData {
|
|
305
|
-
entityUniqueId: string;
|
|
306
|
-
entitiesByUniqueId: Record<string, EntityData>;
|
|
307
|
-
linksByPlatform: Record<string, PlatformLink>;
|
|
308
|
-
id: string;
|
|
309
|
-
title: string;
|
|
310
|
-
artist: string[];
|
|
311
|
-
type: string;
|
|
312
|
-
thumbnail: string;
|
|
326
|
+
entityUniqueId: string; // Unique identifier for the main entity
|
|
327
|
+
entitiesByUniqueId: Record<string, EntityData>; // Collection of all related entities
|
|
328
|
+
linksByPlatform: Record<string, PlatformLink>; // Links to different streaming platforms
|
|
329
|
+
id: string; // Platform-specific ID for the main entity
|
|
330
|
+
title: string; // Title of the song or album
|
|
331
|
+
artist: string[]; // Array of artist names
|
|
332
|
+
type: string; // Type of content ('song' or 'album')
|
|
333
|
+
thumbnail: string; // URL to the thumbnail/cover art
|
|
334
|
+
success?: boolean; // Added for batch operations
|
|
313
335
|
}
|
|
314
336
|
|
|
315
337
|
interface EntityData {
|
|
316
|
-
id: string;
|
|
317
|
-
title: string;
|
|
318
|
-
artistName: string[];
|
|
319
|
-
type: string;
|
|
320
|
-
thumbnailUrl: string;
|
|
338
|
+
id: string; // Platform-specific entity ID
|
|
339
|
+
title: string; // Entity title
|
|
340
|
+
artistName: string[]; // Array of artist names
|
|
341
|
+
type: string; // Entity type ('song' or 'album')
|
|
342
|
+
thumbnailUrl: string; // URL to the thumbnail/cover art
|
|
343
|
+
thumbnailWidth?: number; // Coverart's width
|
|
344
|
+
thumbnailHeight?: number; // Coverart's height
|
|
345
|
+
apiProvider: APIProvider; // The API provider that powered this match
|
|
346
|
+
platforms: Platform[]; // Array of platforms "powered" by this entity
|
|
321
347
|
}
|
|
322
348
|
|
|
323
349
|
interface PlatformLink {
|
|
324
|
-
url: string;
|
|
325
|
-
nativeAppUriMobile?: string;
|
|
326
|
-
nativeAppUriDesktop?: string;
|
|
350
|
+
url: string; // Web URL to the content on the platform
|
|
351
|
+
nativeAppUriMobile?: string; // Deep link for mobile native app
|
|
352
|
+
nativeAppUriDesktop?: string; // Deep link for desktop native app
|
|
353
|
+
entityUniqueId: string; // Unique ID for this entity
|
|
327
354
|
}
|
|
328
355
|
|
|
329
|
-
// Cache statistics
|
|
356
|
+
// Cache statistics and performance metrics
|
|
330
357
|
interface CacheStats {
|
|
331
|
-
size: number;
|
|
332
|
-
ttl: number;
|
|
333
|
-
hitCount: number;
|
|
334
|
-
missCount: number;
|
|
335
|
-
hitRate: number;
|
|
336
|
-
totalRequests: number;
|
|
358
|
+
size: number; // Current number of cached items
|
|
359
|
+
ttl: number; // Time-to-live for cached items in milliseconds
|
|
360
|
+
hitCount: number; // Number of cache hits
|
|
361
|
+
missCount: number; // Number of cache misses
|
|
362
|
+
hitRate: number; // Cache hit rate as a percentage (0-100)
|
|
363
|
+
totalRequests: number; // Total number of requests made
|
|
337
364
|
}
|
|
338
365
|
|
|
339
366
|
// Rate Limiter
|
|
@@ -345,20 +372,20 @@ declare class RateLimiter {
|
|
|
345
372
|
}
|
|
346
373
|
|
|
347
374
|
interface RateLimiterOptions {
|
|
348
|
-
maxRequests?: number;
|
|
349
|
-
windowMs?: number;
|
|
350
|
-
strategy?: 'token-bucket' | 'leaky-bucket' | 'sliding-window';
|
|
351
|
-
retryAfterMs?: number;
|
|
375
|
+
maxRequests?: number; // Maximum number of requests allowed in the time window
|
|
376
|
+
windowMs?: number; // Time window in milliseconds for rate limiting
|
|
377
|
+
strategy?: 'token-bucket' | 'leaky-bucket' | 'sliding-window'; // Rate limiting algorithm: token-bucket (default), leaky-bucket, or sliding-window
|
|
378
|
+
retryAfterMs?: number; // Default retry delay in milliseconds when rate limited
|
|
352
379
|
}
|
|
353
380
|
|
|
354
381
|
interface RateLimiterStatus {
|
|
355
|
-
available?: number;
|
|
356
|
-
max?: number;
|
|
357
|
-
refillRate?: number;
|
|
358
|
-
used?: number;
|
|
359
|
-
windowMs?: number;
|
|
360
|
-
queued?: number;
|
|
361
|
-
processing?: boolean;
|
|
382
|
+
available?: number; // Number of available request slots
|
|
383
|
+
max?: number; // Maximum number of requests allowed
|
|
384
|
+
refillRate?: number; // Rate at which tokens are refilled (tokens per second)
|
|
385
|
+
used?: number; // Number of requests used in current window
|
|
386
|
+
windowMs?: number; // Time window in milliseconds
|
|
387
|
+
queued?: number; // Number of requests waiting in queue
|
|
388
|
+
processing?: boolean; // Whether rate limiter is currently processing requests
|
|
362
389
|
}
|
|
363
390
|
|
|
364
391
|
// Metrics Collector
|
|
@@ -383,23 +410,23 @@ declare class MetricsCollector {
|
|
|
383
410
|
}
|
|
384
411
|
|
|
385
412
|
interface MetricsOptions {
|
|
386
|
-
enabled?: boolean;
|
|
387
|
-
retentionMs?: number;
|
|
388
|
-
maxDataPoints?: number;
|
|
413
|
+
enabled?: boolean; // Enable metrics collection (default: true)
|
|
414
|
+
retentionMs?: number; // How long to retain metrics data in milliseconds (default: 24 hours)
|
|
415
|
+
maxDataPoints?: number; // Maximum number of data points to store (default: 1000)
|
|
389
416
|
}
|
|
390
417
|
|
|
391
418
|
interface RequestMetrics {
|
|
392
|
-
url: string;
|
|
393
|
-
method?: string;
|
|
394
|
-
startTime: number;
|
|
395
|
-
endTime?: number;
|
|
396
|
-
success?: boolean;
|
|
397
|
-
statusCode?: number;
|
|
398
|
-
error?: string;
|
|
399
|
-
responseTime?: number;
|
|
400
|
-
platform?: string;
|
|
401
|
-
country?: string;
|
|
402
|
-
cacheHit?: boolean;
|
|
419
|
+
url: string; // Request URL
|
|
420
|
+
method?: string; // HTTP method used (GET, POST, etc.)
|
|
421
|
+
startTime: number; // Request start time (timestamp in milliseconds)
|
|
422
|
+
endTime?: number; // Request end time (timestamp in milliseconds)
|
|
423
|
+
success?: boolean; // Whether the request was successful
|
|
424
|
+
statusCode?: number; // HTTP status code returned
|
|
425
|
+
error?: string; // Error message if request failed
|
|
426
|
+
responseTime?: number; // Response time in milliseconds
|
|
427
|
+
platform?: string; // Platform being queried
|
|
428
|
+
country?: string; // Country code used for the request
|
|
429
|
+
cacheHit?: boolean; // Whether the response came from cache
|
|
403
430
|
}
|
|
404
431
|
|
|
405
432
|
interface MetricsSummary {
|
|
@@ -434,9 +461,9 @@ interface MetricsSummary {
|
|
|
434
461
|
}
|
|
435
462
|
|
|
436
463
|
interface DetailedMetricsOptions {
|
|
437
|
-
startTime?: number;
|
|
438
|
-
endTime?: number;
|
|
439
|
-
groupBy?: 'hour' | 'minute' | 'platform' | 'country';
|
|
464
|
+
startTime?: number; // Start time for metrics query (timestamp in milliseconds)
|
|
465
|
+
endTime?: number; // End time for metrics query (timestamp in milliseconds)
|
|
466
|
+
groupBy?: 'hour' | 'minute' | 'platform' | 'country'; // Group metrics by time (hour/minute) or by dimension (platform/country)
|
|
440
467
|
}
|
|
441
468
|
|
|
442
469
|
// Plugin System
|
|
@@ -456,23 +483,23 @@ declare class PluginSystem {
|
|
|
456
483
|
}
|
|
457
484
|
|
|
458
485
|
interface Plugin {
|
|
459
|
-
name?: string;
|
|
460
|
-
version?: string;
|
|
461
|
-
description?: string;
|
|
462
|
-
init?: () => void;
|
|
463
|
-
cleanup?: () => void;
|
|
464
|
-
hooks?: Record<string, (context: any) => Promise<void> | void>;
|
|
465
|
-
middleware?: (context: any, next: () => Promise<any>) => Promise<any>;
|
|
466
|
-
transformers?: Record<string, (data: any, context: any) => Promise<any> | any>;
|
|
486
|
+
name?: string; // Plugin name for identification
|
|
487
|
+
version?: string; // Plugin version
|
|
488
|
+
description?: string; // Plugin description
|
|
489
|
+
init?: () => void; // Initialization function called when plugin is registered
|
|
490
|
+
cleanup?: () => void; // Cleanup function called when plugin is unregistered
|
|
491
|
+
hooks?: Record<string, (context: any) => Promise<void> | void>; // Event hooks for plugin lifecycle
|
|
492
|
+
middleware?: (context: any, next: () => Promise<any>) => Promise<any>; // Middleware function for request processing
|
|
493
|
+
transformers?: Record<string, (data: any, context: any) => Promise<any> | any>; // Data transformation functions
|
|
467
494
|
}
|
|
468
495
|
|
|
469
496
|
interface PluginInfo {
|
|
470
|
-
name: string;
|
|
471
|
-
hooks: string[];
|
|
472
|
-
hasMiddleware: boolean;
|
|
473
|
-
hasTransformers: boolean;
|
|
474
|
-
version?: string;
|
|
475
|
-
description?: string;
|
|
497
|
+
name: string; // Plugin name
|
|
498
|
+
hooks: string[]; // List of registered hook names
|
|
499
|
+
hasMiddleware: boolean; // Whether the plugin has middleware function
|
|
500
|
+
hasTransformers: boolean; // Whether the plugin has transformer functions
|
|
501
|
+
version?: string; // Plugin version
|
|
502
|
+
description?: string; // Plugin description
|
|
476
503
|
}
|
|
477
504
|
|
|
478
505
|
// Built-in plugins
|
|
@@ -481,6 +508,7 @@ declare const cachingPlugin: Plugin;
|
|
|
481
508
|
declare const analyticsPlugin: Plugin;
|
|
482
509
|
declare const responseTransformerPlugin: Plugin;
|
|
483
510
|
|
|
511
|
+
// Legacy Page namespace for backward compatibility
|
|
484
512
|
declare namespace Page {
|
|
485
513
|
interface Response {
|
|
486
514
|
/**
|
|
@@ -624,40 +652,40 @@ declare namespace Page {
|
|
|
624
652
|
}
|
|
625
653
|
|
|
626
654
|
type Platform =
|
|
627
|
-
| 'spotify'
|
|
628
|
-
| 'itunes'
|
|
629
|
-
| 'appleMusic'
|
|
630
|
-
| 'youtube'
|
|
631
|
-
| 'youtubeMusic'
|
|
632
|
-
| 'google'
|
|
633
|
-
| 'googleStore'
|
|
634
|
-
| 'pandora'
|
|
635
|
-
| 'deezer'
|
|
636
|
-
| 'tidal'
|
|
637
|
-
| 'amazonStore'
|
|
638
|
-
| 'amazonMusic'
|
|
639
|
-
| 'soundcloud'
|
|
640
|
-
| 'napster'
|
|
641
|
-
| 'yandex'
|
|
642
|
-
| 'spinrilla';
|
|
655
|
+
| 'spotify' // Spotify - Music streaming platform
|
|
656
|
+
| 'itunes' // iTunes Store - Apple's digital media store
|
|
657
|
+
| 'appleMusic' // Apple Music - Apple's music streaming service
|
|
658
|
+
| 'youtube' // YouTube - Video platform with music content
|
|
659
|
+
| 'youtubeMusic' // YouTube Music - YouTube's dedicated music service
|
|
660
|
+
| 'google' // Google Play Music - Google's music service (discontinued)
|
|
661
|
+
| 'googleStore' // Google Play Store - Android app store
|
|
662
|
+
| 'pandora' // Pandora - Internet radio service
|
|
663
|
+
| 'deezer' // Deezer - French music streaming service
|
|
664
|
+
| 'tidal' // Tidal - High-fidelity music streaming service
|
|
665
|
+
| 'amazonStore' // Amazon Music Store - Amazon's digital music store
|
|
666
|
+
| 'amazonMusic' // Amazon Music - Amazon's music streaming service
|
|
667
|
+
| 'soundcloud' // SoundCloud - Audio distribution platform
|
|
668
|
+
| 'napster' // Napster - Music streaming service
|
|
669
|
+
| 'yandex' // Yandex Music - Russian music streaming service
|
|
670
|
+
| 'spinrilla'; // Spinrilla - Mixtape and hip-hop music platform
|
|
643
671
|
|
|
644
672
|
type APIProvider =
|
|
645
|
-
| 'spotify'
|
|
646
|
-
| 'itunes'
|
|
647
|
-
| 'youtube'
|
|
648
|
-
| 'google'
|
|
649
|
-
| 'pandora'
|
|
650
|
-
| 'deezer'
|
|
651
|
-
| 'tidal'
|
|
652
|
-
| 'amazon'
|
|
653
|
-
| 'soundcloud'
|
|
654
|
-
| 'napster'
|
|
655
|
-
| 'yandex'
|
|
656
|
-
| 'spinrilla';
|
|
673
|
+
| 'spotify' // Spotify Web API
|
|
674
|
+
| 'itunes' // iTunes Search API
|
|
675
|
+
| 'youtube' // YouTube Data API
|
|
676
|
+
| 'google' // Google Play Music API (discontinued)
|
|
677
|
+
| 'pandora' // Pandora API
|
|
678
|
+
| 'deezer' // Deezer API
|
|
679
|
+
| 'tidal' // Tidal API
|
|
680
|
+
| 'amazon' // Amazon Music API
|
|
681
|
+
| 'soundcloud' // SoundCloud API
|
|
682
|
+
| 'napster' // Napster API
|
|
683
|
+
| 'yandex' // Yandex Music API
|
|
684
|
+
| 'spinrilla'; // Spinrilla API
|
|
657
685
|
|
|
658
686
|
type entityType =
|
|
659
|
-
| 'song'
|
|
660
|
-
| 'album'
|
|
687
|
+
| 'song' // Individual track/song
|
|
688
|
+
| 'album'; // Complete album or compilation
|
|
661
689
|
|
|
662
690
|
// Export the main class
|
|
663
691
|
export = Odesli;
|