discogs-marketplace-api-nodejs 1.16.5 → 1.16.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.
@@ -47,7 +47,7 @@ function extractLegacy() {
47
47
  * @param context Parent element to query from
48
48
  * @returns Cleaned text content or an empty string
49
49
  */
50
- const getTextContent = (selector, context = document) => context.querySelector(selector)?.textContent?.trim() ?? '';
50
+ const getTextContent = (selector, context = document) => context.querySelector(selector)?.textContent.trim() ?? '';
51
51
  const total = safeParseInt(getTextContent('.pagination_total')
52
52
  .split(' ')
53
53
  .filter(x => x)
@@ -88,7 +88,7 @@ function extractLegacy() {
88
88
  labels: [...el.querySelectorAll(".label_and_cat a[href^='https://www.discogs.com/']")]
89
89
  .map(x => ({
90
90
  id: safeParseInt(x.getAttribute('href')?.split('label/').pop()?.split('-').shift()),
91
- name: x.textContent?.trim() ?? '',
91
+ name: x.textContent.trim(),
92
92
  url: `https://www.discogs.com${x.getAttribute('href') ?? ''}`,
93
93
  }))
94
94
  .filter((value, index, self) => self.findIndex(v => v.name === value.name) === index),
@@ -64,11 +64,14 @@ async function scrape({ currencies, genres, formats, formatDescriptions, conditi
64
64
  ].filter(([, p]) => !!p)).toString(),
65
65
  ].join('?');
66
66
  const browserPage = await browserContext.newPage();
67
+ await browserPage.goto('https://www.discogs.com/shop/mywants', { waitUntil: 'commit' });
67
68
  await browserPage.setExtraHTTPHeaders({
68
69
  'User-Agent': 'Discogs',
69
- 'Content-Type': 'application/json',
70
+ Accept: 'application/json',
71
+ 'Accept-Language': 'en-US,en;q=0.9,fr-FR;q=0.8',
72
+ Referer: 'https://www.discogs.com/shop/mywants',
70
73
  });
71
- const response = await browserPage.goto(urlGenerated);
74
+ const response = await browserPage.goto(urlGenerated, { waitUntil: 'domcontentloaded' });
72
75
  if (!response?.ok()) {
73
76
  const message = response?.headers()['content-type']?.includes('application/json')
74
77
  ? (await response.json())?.detail
@@ -83,6 +86,19 @@ async function scrape({ currencies, genres, formats, formatDescriptions, conditi
83
86
  headers: {
84
87
  'User-Agent': 'Discogs',
85
88
  'Content-Type': 'application/json',
89
+ Host: 'www.discogs.com',
90
+ Accept: '*/*',
91
+ 'Accept-Language': 'en-US,en;q=0.9,fr-FR;q=0.8',
92
+ 'Accept-Encoding': 'gzip, deflate, br, zstd',
93
+ Referer: 'https://www.discogs.com/shop/mywants',
94
+ Origin: 'https://www.discogs.com',
95
+ 'Alt-Used': 'www.discogs.com',
96
+ Connection: 'keep-alive',
97
+ 'Sec-Fetch-Dest': 'empty',
98
+ 'Sec-Fetch-Mode': 'cors',
99
+ 'Sec-Fetch-Site': 'same-origin',
100
+ Priority: 'u=4',
101
+ TE: 'trailers',
86
102
  },
87
103
  body: JSON.stringify({
88
104
  // eslint-disable-next-line max-len
@@ -19,16 +19,23 @@ async function scrapeWantlist(searchParams, browserContext) {
19
19
  * @returns Links and total items found
20
20
  */
21
21
  const getPageContent = async (pageNumber) => {
22
- const browserPage = await browserContext.newPage();
23
- await browserPage.route('**/*', route => (route.request().resourceType() === 'document' ? route.continue() : route.abort()));
24
- const response = await browserPage.goto(`https://www.discogs.com/wantlist?${new URLSearchParams({
22
+ const url = `https://www.discogs.com/wantlist?${new URLSearchParams({
25
23
  page: pageNumber.toString(),
26
24
  limit: PER_PAGE.toString(),
27
25
  user: searchParams.wantlist ?? '',
28
26
  layout: 'sm',
29
- }).toString()}`);
27
+ }).toString()}`;
28
+ const browserPage = await browserContext.newPage();
29
+ await browserPage.setExtraHTTPHeaders({
30
+ 'User-Agent': 'Discogs',
31
+ Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
32
+ 'Accept-Language': 'en-US,en;q=0.7,fr-FR;q=0.8',
33
+ Referer: url,
34
+ });
35
+ await browserPage.route('**/*', route => (route.request().resourceType() === 'document' ? route.continue() : route.abort()));
36
+ const response = await browserPage.goto(url, { waitUntil: 'domcontentloaded' });
30
37
  const [total, ids] = await Promise.all([
31
- browserPage.evaluate(() => +(document.querySelector('.pagination_total')?.textContent?.split(' of ').pop()?.replace(',', '') ?? '0')),
38
+ browserPage.evaluate(() => +(document.querySelector('.pagination_total')?.textContent.split(' of ').pop()?.replace(',', '') ?? '0')),
32
39
  browserPage.evaluate(() => {
33
40
  /** Extract the links to the items in the wantlist, if there's no link it's not for sale */
34
41
  const links = [...document.querySelectorAll('.marketplace_for_sale_count a')];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discogs-marketplace-api-nodejs",
3
- "version": "1.16.5",
3
+ "version": "1.16.7",
4
4
  "description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
5
5
  "keywords": [
6
6
  "discogs",
@@ -40,30 +40,30 @@
40
40
  }
41
41
  ],
42
42
  "dependencies": {
43
- "playwright-chromium": "^1.57.0",
43
+ "playwright-chromium": "^1.58.2",
44
44
  "playwright-extra": "^4.3.6",
45
45
  "puppeteer-extra-plugin-stealth": "^2.11.2"
46
46
  },
47
47
  "devDependencies": {
48
- "@eslint/js": "^9.31.0",
49
- "@types/node": "^20.19.8",
50
- "@typescript-eslint/eslint-plugin": "^8.29.1",
51
- "@typescript-eslint/parser": "^8.29.1",
52
- "cspell": "^9.1.5",
53
- "eslint": "^9.31.0",
54
- "eslint-config-prettier": "^10.1.5",
48
+ "@eslint/js": "^9.39.2",
49
+ "@types/node": "^22.19.11",
50
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
51
+ "@typescript-eslint/parser": "^8.55.0",
52
+ "cspell": "^9.6.4",
53
+ "eslint": "^9.39.2",
54
+ "eslint-config-prettier": "^10.1.8",
55
55
  "eslint-import-resolver-typescript": "^4.4.4",
56
56
  "eslint-plugin-import": "^2.32.0",
57
- "eslint-plugin-jsdoc": "^51.4.1",
58
- "globals": "^16.3.0",
57
+ "eslint-plugin-jsdoc": "^62.5.5",
58
+ "globals": "^17.3.0",
59
59
  "husky": "^9.1.7",
60
- "knip": "^5.61.3",
61
- "lint-staged": "^16.1.2",
62
- "prettier": "^3.6.2",
63
- "rimraf": "^6.0.1",
60
+ "knip": "^5.83.1",
61
+ "lint-staged": "^16.2.7",
62
+ "prettier": "^3.8.1",
63
+ "rimraf": "^6.1.2",
64
64
  "tsc-alias": "^1.8.16",
65
- "tsx": "^4.20.3",
66
- "typescript": "^5.8.3",
67
- "typescript-eslint": "^8.37.0"
65
+ "tsx": "^4.21.0",
66
+ "typescript": "^5.9.3",
67
+ "typescript-eslint": "^8.55.0"
68
68
  }
69
69
  }