discogs-marketplace-api-nodejs 1.3.5 → 1.3.8
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/README.MD +27 -1
- package/dist/enum/ECurrency.d.ts +2 -1
- package/dist/enum/ECurrency.js +2 -1
- package/dist/enum/iso/translate/EDiscogsCurrencyToIsoCode.d.ts +14 -1
- package/dist/enum/iso/translate/EDiscogsCurrencyToIsoCode.js +14 -1
- package/dist/marketplace.d.ts +2 -2
- package/dist/marketplace.js +13 -7
- package/package.json +13 -14
package/README.MD
CHANGED
|
@@ -202,9 +202,33 @@ interface IOutputError {
|
|
|
202
202
|
}
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
## How to contribute
|
|
206
|
+
|
|
207
|
+
There is a devcontainer on that project already configured, feel free to use it.
|
|
208
|
+
|
|
209
|
+
You can install dependecies with:
|
|
210
|
+
|
|
211
|
+
```sh
|
|
212
|
+
npm i
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
And then create a new file that import `DiscogsMarketplace` and run query to try your updates.
|
|
216
|
+
|
|
217
|
+
Finally, you can open a pull request with your new additions.
|
|
218
|
+
|
|
205
219
|
## Know issues
|
|
206
220
|
|
|
207
|
-
|
|
221
|
+
### Playwright
|
|
222
|
+
|
|
223
|
+
Try this if chrome wasn't installed with `npm i`:
|
|
224
|
+
|
|
225
|
+
```sh
|
|
226
|
+
npx playwright install
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Linkedom
|
|
230
|
+
|
|
231
|
+
If you are using this librairy on a Typescript project, you might encounter issues with `linkedom`.
|
|
208
232
|
|
|
209
233
|
To fix it, use this in command line: `--skipLibCheck` or add that in you `tsconfig.json`:
|
|
210
234
|
|
|
@@ -215,3 +239,5 @@ To fix it, use this in command line: `--skipLibCheck` or add that in you `tsconf
|
|
|
215
239
|
}
|
|
216
240
|
}
|
|
217
241
|
```
|
|
242
|
+
|
|
243
|
+
If you found another problem, feel free to open an issue.
|
package/dist/enum/ECurrency.d.ts
CHANGED
package/dist/enum/ECurrency.js
CHANGED
|
@@ -14,8 +14,9 @@ var ECurrency;
|
|
|
14
14
|
ECurrency["JPY"] = "JPY";
|
|
15
15
|
ECurrency["SEK"] = "SEK";
|
|
16
16
|
ECurrency["BRL"] = "BRL";
|
|
17
|
-
ECurrency["NZD"] = "NZD";
|
|
18
17
|
ECurrency["MXN"] = "MXN";
|
|
18
|
+
ECurrency["NZD"] = "NZD";
|
|
19
|
+
ECurrency["DKK"] = "DKK";
|
|
19
20
|
ECurrency["ZAR"] = "ZAR";
|
|
20
21
|
})(ECurrency || (ECurrency = {}));
|
|
21
22
|
exports.default = ECurrency;
|
|
@@ -3,18 +3,31 @@
|
|
|
3
3
|
*/
|
|
4
4
|
declare enum EDiscogsCurrencyToIsoCode {
|
|
5
5
|
$US = "USD",
|
|
6
|
+
US$ = "USD",
|
|
7
|
+
USD = "USD",
|
|
6
8
|
'£GB' = "GBP",
|
|
9
|
+
GBP = "GBP",
|
|
7
10
|
$CA = "CAD",
|
|
11
|
+
CA$ = "CAD",
|
|
12
|
+
CAD = "CAD",
|
|
8
13
|
$AU = "AUD",
|
|
14
|
+
AU$ = "AUD",
|
|
15
|
+
AUD = "AUD",
|
|
9
16
|
JPY = "JPY",
|
|
10
17
|
CHF = "CHF",
|
|
11
18
|
MX$ = "MXN",
|
|
19
|
+
$MX = "MXN",
|
|
20
|
+
MXN = "MXN",
|
|
12
21
|
$NZ = "NZD",
|
|
22
|
+
NZ$ = "NZD",
|
|
23
|
+
NZD = "NZD",
|
|
13
24
|
SEK = "SEK",
|
|
14
25
|
ZAR = "ZAR",
|
|
15
|
-
|
|
26
|
+
BRL = "BRL",
|
|
27
|
+
DKK = "DKK",
|
|
16
28
|
A$ = "AUD",
|
|
17
29
|
R$ = "BRL",
|
|
30
|
+
EUR = "EUR",
|
|
18
31
|
'€' = "EUR",
|
|
19
32
|
$ = "USD",
|
|
20
33
|
'£' = "GBP",
|
|
@@ -6,18 +6,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
var EDiscogsCurrencyToIsoCode;
|
|
7
7
|
(function (EDiscogsCurrencyToIsoCode) {
|
|
8
8
|
EDiscogsCurrencyToIsoCode["$US"] = "USD";
|
|
9
|
+
EDiscogsCurrencyToIsoCode["US$"] = "USD";
|
|
10
|
+
EDiscogsCurrencyToIsoCode["USD"] = "USD";
|
|
9
11
|
EDiscogsCurrencyToIsoCode["\u00A3GB"] = "GBP";
|
|
12
|
+
EDiscogsCurrencyToIsoCode["GBP"] = "GBP";
|
|
10
13
|
EDiscogsCurrencyToIsoCode["$CA"] = "CAD";
|
|
14
|
+
EDiscogsCurrencyToIsoCode["CA$"] = "CAD";
|
|
15
|
+
EDiscogsCurrencyToIsoCode["CAD"] = "CAD";
|
|
11
16
|
EDiscogsCurrencyToIsoCode["$AU"] = "AUD";
|
|
17
|
+
EDiscogsCurrencyToIsoCode["AU$"] = "AUD";
|
|
18
|
+
EDiscogsCurrencyToIsoCode["AUD"] = "AUD";
|
|
12
19
|
EDiscogsCurrencyToIsoCode["JPY"] = "JPY";
|
|
13
20
|
EDiscogsCurrencyToIsoCode["CHF"] = "CHF";
|
|
14
21
|
EDiscogsCurrencyToIsoCode["MX$"] = "MXN";
|
|
22
|
+
EDiscogsCurrencyToIsoCode["$MX"] = "MXN";
|
|
23
|
+
EDiscogsCurrencyToIsoCode["MXN"] = "MXN";
|
|
15
24
|
EDiscogsCurrencyToIsoCode["$NZ"] = "NZD";
|
|
25
|
+
EDiscogsCurrencyToIsoCode["NZ$"] = "NZD";
|
|
26
|
+
EDiscogsCurrencyToIsoCode["NZD"] = "NZD";
|
|
16
27
|
EDiscogsCurrencyToIsoCode["SEK"] = "SEK";
|
|
17
28
|
EDiscogsCurrencyToIsoCode["ZAR"] = "ZAR";
|
|
18
|
-
EDiscogsCurrencyToIsoCode["
|
|
29
|
+
EDiscogsCurrencyToIsoCode["BRL"] = "BRL";
|
|
30
|
+
EDiscogsCurrencyToIsoCode["DKK"] = "DKK";
|
|
19
31
|
EDiscogsCurrencyToIsoCode["A$"] = "AUD";
|
|
20
32
|
EDiscogsCurrencyToIsoCode["R$"] = "BRL";
|
|
33
|
+
EDiscogsCurrencyToIsoCode["EUR"] = "EUR";
|
|
21
34
|
EDiscogsCurrencyToIsoCode["\u20AC"] = "EUR";
|
|
22
35
|
EDiscogsCurrencyToIsoCode["$"] = "USD";
|
|
23
36
|
EDiscogsCurrencyToIsoCode["\u00A3"] = "GBP";
|
package/dist/marketplace.d.ts
CHANGED
|
@@ -42,11 +42,11 @@ export default class Marketplace {
|
|
|
42
42
|
*/
|
|
43
43
|
private serializeParams;
|
|
44
44
|
/**
|
|
45
|
-
* Function to convert
|
|
45
|
+
* Function to convert currency to ISO name
|
|
46
46
|
* @param str String to clean
|
|
47
47
|
* @returns Cleanup string
|
|
48
48
|
*/
|
|
49
|
-
private
|
|
49
|
+
private convertCurrency;
|
|
50
50
|
/**
|
|
51
51
|
* Parse HTML to clean result
|
|
52
52
|
* @param document Document to parse
|
package/dist/marketplace.js
CHANGED
|
@@ -113,7 +113,7 @@ class Marketplace {
|
|
|
113
113
|
/** Get url */
|
|
114
114
|
this.url = page.url();
|
|
115
115
|
/** Get HTML */
|
|
116
|
-
const bodyHTML = yield page.evaluate(() => { var _a; return (_a = document.
|
|
116
|
+
const bodyHTML = yield page.evaluate(() => { var _a; return (_a = document.getElementById('page_content')) === null || _a === void 0 ? void 0 : _a.outerHTML; });
|
|
117
117
|
/** Close browser */
|
|
118
118
|
yield browser.close();
|
|
119
119
|
/** If error, reject */
|
|
@@ -131,7 +131,7 @@ class Marketplace {
|
|
|
131
131
|
};
|
|
132
132
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
133
133
|
throw {
|
|
134
|
-
message: 'An error occured',
|
|
134
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || 'An error occured',
|
|
135
135
|
code: 500,
|
|
136
136
|
};
|
|
137
137
|
}
|
|
@@ -180,19 +180,25 @@ class Marketplace {
|
|
|
180
180
|
return param.join('&');
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
* Function to convert
|
|
183
|
+
* Function to convert currency to ISO name
|
|
184
184
|
* @param str String to clean
|
|
185
185
|
* @returns Cleanup string
|
|
186
186
|
*/
|
|
187
187
|
// eslint-disable-next-line class-methods-use-this
|
|
188
|
-
|
|
188
|
+
convertCurrency(value) {
|
|
189
189
|
var _a;
|
|
190
190
|
if (!value)
|
|
191
191
|
return value;
|
|
192
192
|
const currency = (_a = Object.keys(EDiscogsCurrencyToIsoCode_1.default).find(key => value.includes(key))) !== null && _a !== void 0 ? _a : '';
|
|
193
193
|
if (!currency)
|
|
194
194
|
return value;
|
|
195
|
-
|
|
195
|
+
const currencyClean = EDiscogsCurrencyToIsoCode_1.default[currency];
|
|
196
|
+
const amount = value
|
|
197
|
+
.replace(currencyClean !== ECurrency_1.default.JPY ? /[.](?=.*[.])/g : /\./g, '') // Remove all dot but last, except if JPY
|
|
198
|
+
.replace(currency, '') // Remove original currency
|
|
199
|
+
.replace(/\s/g, ''); // Remove spaces
|
|
200
|
+
return `${amount} ${currencyClean}`
|
|
201
|
+
.replace(/\s\s+/g, ' '); // Remove useless spaces
|
|
196
202
|
}
|
|
197
203
|
/**
|
|
198
204
|
* Parse HTML to clean result
|
|
@@ -205,7 +211,7 @@ class Marketplace {
|
|
|
205
211
|
return {
|
|
206
212
|
items: ((_e = [...document.querySelectorAll('table.table_block tbody tr')]) === null || _e === void 0 ? void 0 : _e.map(el => {
|
|
207
213
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59;
|
|
208
|
-
const shipping = this.
|
|
214
|
+
const shipping = this.convertCurrency((_g = (_f = (_e = (_d = (_c = (_b = (_a = el.querySelector('.item_shipping')) === null || _a === void 0 ? void 0 : _a.childNodes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.replace(/(\s+|\+)/g, ' ')) === null || _e === void 0 ? void 0 : _e.trim()) === null || _f === void 0 ? void 0 : _f.replace(',', '.')) !== null && _g !== void 0 ? _g : '');
|
|
209
215
|
const have = Number.parseInt((_j = (_h = el.querySelector('.community_summary .community_result:nth-child(1) .community_number')) === null || _h === void 0 ? void 0 : _h.textContent) !== null && _j !== void 0 ? _j : '', 10);
|
|
210
216
|
const want = Number.parseInt((_l = (_k = el.querySelector('.community_summary .community_result:nth-child(2) .community_number')) === null || _k === void 0 ? void 0 : _k.textContent) !== null && _l !== void 0 ? _l : '', 10);
|
|
211
217
|
const countryName = (_q = (_p = (_o = (_m = el.querySelector('.seller_info li:nth-child(3)')) === null || _m === void 0 ? void 0 : _m.textContent) === null || _o === void 0 ? void 0 : _o.split(':')) === null || _p === void 0 ? void 0 : _p[1]) !== null && _q !== void 0 ? _q : '';
|
|
@@ -253,7 +259,7 @@ class Marketplace {
|
|
|
253
259
|
notes: Number.isNaN(notes) ? 0 : notes,
|
|
254
260
|
},
|
|
255
261
|
price: {
|
|
256
|
-
base: this.
|
|
262
|
+
base: this.convertCurrency((_57 = (_56 = (_55 = (_54 = el.querySelector('.price')) === null || _54 === void 0 ? void 0 : _54.textContent) === null || _55 === void 0 ? void 0 : _55.replace(/\s+/g, ' ')) === null || _56 === void 0 ? void 0 : _56.replace(/,/, '.')) !== null && _57 !== void 0 ? _57 : ''),
|
|
257
263
|
shipping: Number.isNaN(parseFloat(shipping)) ? null : shipping,
|
|
258
264
|
},
|
|
259
265
|
from: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "Another (better ?) NodeJs library to fetch data from Discog's marketplace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discogs",
|
|
@@ -26,27 +26,26 @@
|
|
|
26
26
|
"main": "dist/index.js",
|
|
27
27
|
"types": "dist/index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"linkedom": "^0.
|
|
30
|
-
"playwright-chromium": "^1.
|
|
31
|
-
"ts-node": "^10.
|
|
29
|
+
"linkedom": "^0.14.2",
|
|
30
|
+
"playwright-chromium": "^1.19.2",
|
|
31
|
+
"ts-node": "^10.5.0",
|
|
32
32
|
"tsconfig-paths": "^3.12.0",
|
|
33
|
-
"user-agents": "^1.0.
|
|
33
|
+
"user-agents": "^1.0.940"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/jest": "^27.4.
|
|
37
|
-
"@types/node": "^17.0.
|
|
38
|
-
"@types/puppeteer": "^5.4.4",
|
|
36
|
+
"@types/jest": "^27.4.1",
|
|
37
|
+
"@types/node": "^17.0.21",
|
|
39
38
|
"@types/user-agents": "^1.0.2",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
41
|
-
"@typescript-eslint/parser": "^5.
|
|
42
|
-
"eslint": "^8.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
40
|
+
"@typescript-eslint/parser": "^5.12.1",
|
|
41
|
+
"eslint": "^8.10.0",
|
|
43
42
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
44
43
|
"eslint-config-airbnb-typescript": "^16.1.0",
|
|
45
44
|
"eslint-plugin-import": "^2.25.4",
|
|
46
|
-
"jest": "^27.
|
|
47
|
-
"ts-jest": "^27.1.
|
|
45
|
+
"jest": "^27.5.1",
|
|
46
|
+
"ts-jest": "^27.1.3",
|
|
48
47
|
"ttypescript": "^1.5.13",
|
|
49
|
-
"typescript": "^4.5.
|
|
48
|
+
"typescript": "^4.5.5",
|
|
50
49
|
"typescript-transform-paths": "^3.3.1"
|
|
51
50
|
}
|
|
52
51
|
}
|