discogs-marketplace-api-nodejs 1.9.0 → 1.9.1
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 +1 -1
- package/dist/data/countries.data.js +3 -3
- package/dist/marketplace.js +32 -30
- package/package.json +22 -19
package/README.MD
CHANGED
|
@@ -4,7 +4,7 @@ Another (better ?) NodeJs library to fetch data from Discogs marketplace. 💿
|
|
|
4
4
|
|
|
5
5
|
## 📂 Installation (with npm)
|
|
6
6
|
|
|
7
|
-
This library works with two different `strategies` to scrape data: with a classic HTTP fetch request (Axios) or by creating a new instance of a browser (Playwright). Take a look at the "[About strategies](
|
|
7
|
+
This library works with two different `strategies` to scrape data: with a classic HTTP fetch request (Axios) or by creating a new instance of a browser (Playwright). Take a look at the "[About strategies](#-about-strategies)" chapter to learn more.
|
|
8
8
|
|
|
9
9
|
Run the following command in your project:
|
|
10
10
|
|
|
@@ -291,12 +291,12 @@ const COUNTRIES_DISCOGS = {
|
|
|
291
291
|
Macedonia: 'MK',
|
|
292
292
|
'Martinique (French)': 'MQ',
|
|
293
293
|
Micronesia: 'FM',
|
|
294
|
-
'Netherlands Antilles': 'CW',
|
|
294
|
+
'Netherlands Antilles': 'CW', // Or SX
|
|
295
295
|
'Neutral Zone': '',
|
|
296
296
|
'New Caledonia (French)': 'NC',
|
|
297
297
|
'Pitcairn Island': 'PN',
|
|
298
298
|
'Polynesia (French)': 'PF',
|
|
299
|
-
'Reunion (French)': 'RE',
|
|
299
|
+
'Reunion (French)': 'RE', //
|
|
300
300
|
'S. Georgia & S. Sandwich Isls.': 'GS',
|
|
301
301
|
'Saint Helena': 'SH',
|
|
302
302
|
'Saint Kitts & Nevis Anguilla': 'KN',
|
|
@@ -304,7 +304,7 @@ const COUNTRIES_DISCOGS = {
|
|
|
304
304
|
'Saint Vincent & Grenadines': 'VC',
|
|
305
305
|
'Slovak Republic': 'SK',
|
|
306
306
|
'South Korea': 'KR',
|
|
307
|
-
'Spain (Canary Islands)': 'IC',
|
|
307
|
+
'Spain (Canary Islands)': 'IC', //
|
|
308
308
|
'Svalbard and Jan Mayen Islands': 'SJ',
|
|
309
309
|
Swaziland: 'SZ',
|
|
310
310
|
Syria: 'SY',
|
package/dist/marketplace.js
CHANGED
|
@@ -255,7 +255,7 @@ class Marketplace {
|
|
|
255
255
|
.querySelector('.pagination_total')) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.split(' ')) === null || _c === void 0 ? void 0 : _c.filter(x => x).pop()) === null || _d === void 0 ? void 0 : _d.replace(/(,|\.|\s)/g, '')) || '0');
|
|
256
256
|
return {
|
|
257
257
|
items: ((_e = [...document.querySelectorAll('table.table_block tbody tr')]) === null || _e === void 0 ? void 0 : _e.map(el => {
|
|
258
|
-
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;
|
|
258
|
+
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;
|
|
259
259
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
260
|
const shipping = convertCurrency((_g = (_f = (_e = (_d = (_c = (_b = (_a = el
|
|
261
261
|
.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 : '');
|
|
@@ -263,54 +263,56 @@ class Marketplace {
|
|
|
263
263
|
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);
|
|
264
264
|
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.pop()) !== null && _q !== void 0 ? _q : '';
|
|
265
265
|
const countryCode = COUNTRIES[countryName];
|
|
266
|
-
const releaseId = Number.parseInt((_v = (_u = (_t = (_s = (_r = el
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
const
|
|
266
|
+
const releaseId = Number.parseInt((_w = (_v = (_u = (_t = (_s = (_r = el
|
|
267
|
+
.querySelector('a.item_release_link')) === null || _r === void 0 ? void 0 : _r.getAttribute('href')) === null || _s === void 0 ? void 0 : _s.split('release/')) === null || _t === void 0 ? void 0 : _t.pop()) === null || _u === void 0 ? void 0 : _u.split('-')) === null || _v === void 0 ? void 0 : _v.shift()) !== null && _w !== void 0 ? _w : '0', 10);
|
|
268
|
+
const itemId = Number.parseInt((_z = (_y = (_x = el.querySelector('a.item_description_title')) === null || _x === void 0 ? void 0 : _x.getAttribute('href')) === null || _y === void 0 ? void 0 : _y.split('/').pop()) !== null && _z !== void 0 ? _z : '0', 10);
|
|
269
|
+
const notes = Number.parseInt((_6 = (_5 = (_4 = (_3 = (_2 = (_1 = (_0 = el
|
|
270
|
+
.querySelector('.seller_info li:nth-child(2) .section_link')) === null || _0 === void 0 ? void 0 : _0.textContent) === null || _1 === void 0 ? void 0 : _1.replace(/\s+/g, ' ')) === null || _2 === void 0 ? void 0 : _2.trim()) === null || _3 === void 0 ? void 0 : _3.split(' ')) === null || _4 === void 0 ? void 0 : _4[0]) === null || _5 === void 0 ? void 0 : _5.replace(/,/g, '')) !== null && _6 !== void 0 ? _6 : '', 10);
|
|
271
|
+
const originalTitle = (_7 = el.querySelector('a.item_description_title')) === null || _7 === void 0 ? void 0 : _7.textContent;
|
|
272
|
+
const firstIndexOfDash = (_8 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.indexOf(' - ')) !== null && _8 !== void 0 ? _8 : -1;
|
|
273
|
+
const lastIndexOfParenthesis = (_9 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.lastIndexOf(' (')) !== null && _9 !== void 0 ? _9 : -1;
|
|
273
274
|
return {
|
|
274
275
|
id: Number.isNaN(itemId) ? 0 : itemId,
|
|
275
276
|
title: {
|
|
276
277
|
original: originalTitle !== null && originalTitle !== void 0 ? originalTitle : '',
|
|
277
|
-
artist: (
|
|
278
|
+
artist: (_10 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.substring(0, firstIndexOfDash)) !== null && _10 !== void 0 ? _10 : '',
|
|
278
279
|
item: firstIndexOfDash > -1 && lastIndexOfParenthesis > -1
|
|
279
|
-
? (
|
|
280
|
+
? (_11 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.substring(firstIndexOfDash + 3, lastIndexOfParenthesis)) !== null && _11 !== void 0 ? _11 : ''
|
|
280
281
|
: '',
|
|
281
282
|
formats: lastIndexOfParenthesis > -1
|
|
282
|
-
? (
|
|
283
|
+
? (_13 = (_12 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.substring(lastIndexOfParenthesis + 2, originalTitle.length - 1)) === null || _12 === void 0 ? void 0 : _12.split(', ')) !== null && _13 !== void 0 ? _13 : []
|
|
283
284
|
: [],
|
|
284
285
|
},
|
|
285
|
-
url: `https://www.discogs.com${(
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
url: `https://www.discogs.com${(_14 = el
|
|
287
|
+
.querySelector('a.item_description_title')) === null || _14 === void 0 ? void 0 : _14.getAttribute('href')}`,
|
|
288
|
+
labels: (_16 = (_15 = [...el.querySelectorAll(".label_and_cat a[href^='https://www.discogs.com/']")]) === null || _15 === void 0 ? void 0 : _15.map(x => { var _a; return (_a = x === null || x === void 0 ? void 0 : x.textContent) !== null && _a !== void 0 ? _a : ''; })) === null || _16 === void 0 ? void 0 : _16.filter((value, index, self) => self.indexOf(value) === index),
|
|
289
|
+
catnos: (_21 = (_20 = (_19 = (_18 = (_17 = el
|
|
288
290
|
// cspell: disable-next-line
|
|
289
|
-
.querySelector('.label_and_cat .item_catno')) === null ||
|
|
290
|
-
imageUrl: (
|
|
291
|
-
description: (_27 = (_26 = (_25 = (_24 =
|
|
292
|
-
isAcceptingOffer: ((
|
|
293
|
-
isAvailable: !((
|
|
291
|
+
.querySelector('.label_and_cat .item_catno')) === null || _17 === void 0 ? void 0 : _17.textContent) === null || _18 === void 0 ? void 0 : _18.replace(/\s+/g, ' ')) === null || _19 === void 0 ? void 0 : _19.split(', ')) === null || _20 === void 0 ? void 0 : _20.filter(x => x !== 'none')) !== null && _21 !== void 0 ? _21 : [],
|
|
292
|
+
imageUrl: (_23 = (_22 = el.querySelector('.marketplace_image')) === null || _22 === void 0 ? void 0 : _22.getAttribute('data-src')) !== null && _23 !== void 0 ? _23 : '',
|
|
293
|
+
description: (_28 = (_27 = (_26 = (_25 = (_24 = el.querySelector('.item_condition')) === null || _24 === void 0 ? void 0 : _24.nextElementSibling) === null || _25 === void 0 ? void 0 : _25.textContent) === null || _26 === void 0 ? void 0 : _26.replace(/\s+/g, ' ')) === null || _27 === void 0 ? void 0 : _27.trim()) !== null && _28 !== void 0 ? _28 : '',
|
|
294
|
+
isAcceptingOffer: ((_32 = (_31 = (_30 = (_29 = el.querySelector('.item_add_to_cart p a strong')) === null || _29 === void 0 ? void 0 : _29.textContent) === null || _30 === void 0 ? void 0 : _30.split('/')) === null || _31 === void 0 ? void 0 : _31.length) !== null && _32 !== void 0 ? _32 : 0) > 1,
|
|
295
|
+
isAvailable: !((_33 = el.classList) === null || _33 === void 0 ? void 0 : _33.contains('unavailable')),
|
|
294
296
|
condition: {
|
|
295
297
|
media: {
|
|
296
|
-
full: (
|
|
297
|
-
short: (_42 = (_41 = (_40 = (_39 = (_38 =
|
|
298
|
-
.querySelector('.item_condition span:nth-child(3)')) === null ||
|
|
298
|
+
full: (_37 = (_36 = (_35 = (_34 = el.querySelector('.item_condition span:nth-child(3)')) === null || _34 === void 0 ? void 0 : _34.textContent) === null || _35 === void 0 ? void 0 : _35.replace(/\s+/g, ' ')) === null || _36 === void 0 ? void 0 : _36.trim()) !== null && _37 !== void 0 ? _37 : '',
|
|
299
|
+
short: (_43 = (_42 = (_41 = (_40 = (_39 = (_38 = el
|
|
300
|
+
.querySelector('.item_condition span:nth-child(3)')) === null || _38 === void 0 ? void 0 : _38.textContent) === null || _39 === void 0 ? void 0 : _39.replace(/\s+/g, ' ')) === null || _40 === void 0 ? void 0 : _40.trim()) === null || _41 === void 0 ? void 0 : _41.match(/\(([^)]+)\)/)) === null || _42 === void 0 ? void 0 : _42[1]) !== null && _43 !== void 0 ? _43 : '',
|
|
299
301
|
},
|
|
300
302
|
sleeve: {
|
|
301
|
-
full: (
|
|
302
|
-
short: (
|
|
303
|
-
.querySelector('.item_condition span.item_sleeve_condition')) === null ||
|
|
303
|
+
full: (_45 = (_44 = el.querySelector('.item_condition span.item_sleeve_condition')) === null || _44 === void 0 ? void 0 : _44.textContent) !== null && _45 !== void 0 ? _45 : '',
|
|
304
|
+
short: (_49 = (_48 = (_47 = (_46 = el
|
|
305
|
+
.querySelector('.item_condition span.item_sleeve_condition')) === null || _46 === void 0 ? void 0 : _46.textContent) === null || _47 === void 0 ? void 0 : _47.match(/\(([^)]+)\)/)) === null || _48 === void 0 ? void 0 : _48[1]) !== null && _49 !== void 0 ? _49 : '',
|
|
304
306
|
},
|
|
305
307
|
},
|
|
306
308
|
seller: {
|
|
307
|
-
name: (
|
|
308
|
-
url: `https://www.discogs.com${(
|
|
309
|
-
score: (
|
|
309
|
+
name: (_51 = (_50 = el.querySelector('.seller_info a')) === null || _50 === void 0 ? void 0 : _50.textContent) !== null && _51 !== void 0 ? _51 : '',
|
|
310
|
+
url: `https://www.discogs.com${(_52 = el.querySelector('.seller_info a')) === null || _52 === void 0 ? void 0 : _52.getAttribute('href')}`,
|
|
311
|
+
score: (_54 = (_53 = el.querySelector('.seller_info li:nth-child(2) strong')) === null || _53 === void 0 ? void 0 : _53.textContent) !== null && _54 !== void 0 ? _54 : '',
|
|
310
312
|
notes: Number.isNaN(notes) ? 0 : notes,
|
|
311
313
|
},
|
|
312
314
|
price: {
|
|
313
|
-
base: convertCurrency((
|
|
315
|
+
base: convertCurrency((_58 = (_57 = (_56 = (_55 = el.querySelector('.price')) === null || _55 === void 0 ? void 0 : _55.textContent) === null || _56 === void 0 ? void 0 : _56.replace(/\s+/g, ' ')) === null || _57 === void 0 ? void 0 : _57.replace(/,/, '.')) !== null && _58 !== void 0 ? _58 : ''),
|
|
314
316
|
shipping: Number.isNaN(parseFloat(shipping)) ? null : shipping,
|
|
315
317
|
},
|
|
316
318
|
country: {
|
|
@@ -323,7 +325,7 @@ class Marketplace {
|
|
|
323
325
|
},
|
|
324
326
|
release: {
|
|
325
327
|
id: Number.isNaN(releaseId) ? 0 : releaseId,
|
|
326
|
-
url: `https://www.discogs.com${(
|
|
328
|
+
url: `https://www.discogs.com${(_59 = el.querySelector('a.item_release_link')) === null || _59 === void 0 ? void 0 : _59.getAttribute('href')}`,
|
|
327
329
|
},
|
|
328
330
|
};
|
|
329
331
|
})) || [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discogs",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"eslint": "eslint src test --ext .ts,.js",
|
|
26
26
|
"prettier": "prettier --check .",
|
|
27
27
|
"prettier:fix": "prettier --write .",
|
|
28
|
-
"cspell": "npx cspell ./ --no-progress"
|
|
28
|
+
"cspell": "npx cspell ./ --no-progress",
|
|
29
|
+
"knip": "knip"
|
|
29
30
|
},
|
|
30
31
|
"main": "dist/index.js",
|
|
31
32
|
"types": "dist/index.d.ts",
|
|
@@ -33,33 +34,35 @@
|
|
|
33
34
|
"node": ">=14.0.0"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"axios": "^1.6.
|
|
37
|
-
"linkedom": "^0.16.
|
|
38
|
-
"playwright-chromium": "^1.40.
|
|
39
|
-
"user-agents": "^1.1.
|
|
37
|
+
"axios": "^1.6.5",
|
|
38
|
+
"linkedom": "^0.16.6",
|
|
39
|
+
"playwright-chromium": "^1.40.1",
|
|
40
|
+
"user-agents": "^1.1.75"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@types/jest": "^29.5.
|
|
43
|
-
"@types/node": "^18.
|
|
43
|
+
"@types/jest": "^29.5.11",
|
|
44
|
+
"@types/node": "^18.19.4",
|
|
44
45
|
"@types/user-agents": "^1.0.4",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
46
|
-
"@typescript-eslint/parser": "^6.
|
|
47
|
-
"cspell": "^8.
|
|
48
|
-
"eslint": "^8.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
47
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
48
|
+
"cspell": "^8.3.2",
|
|
49
|
+
"eslint": "^8.56.0",
|
|
49
50
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
50
51
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
51
|
-
"eslint-config-prettier": "^9.
|
|
52
|
+
"eslint-config-prettier": "^9.1.0",
|
|
52
53
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
53
|
-
"eslint-plugin-import": "^2.29.
|
|
54
|
-
"eslint-plugin-jsdoc": "^
|
|
54
|
+
"eslint-plugin-import": "^2.29.1",
|
|
55
|
+
"eslint-plugin-jsdoc": "^48.0.2",
|
|
55
56
|
"husky": "^8.0.3",
|
|
56
57
|
"jest": "^29.7.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
58
|
+
"knip": "^3.12.0",
|
|
59
|
+
"lint-staged": "^15.2.0",
|
|
60
|
+
"nodemon": "^3.0.2",
|
|
61
|
+
"prettier": "^3.1.1",
|
|
62
|
+
"rimraf": "^5.0.5",
|
|
59
63
|
"ts-jest": "^29.1.1",
|
|
60
|
-
"ts-node": "^10.9.1",
|
|
61
64
|
"tsc-alias": "^1.8.8",
|
|
62
65
|
"tsconfig-paths": "^4.2.0",
|
|
63
|
-
"typescript": "^5.
|
|
66
|
+
"typescript": "^5.3.3"
|
|
64
67
|
}
|
|
65
68
|
}
|