discogs-marketplace-api-nodejs 1.13.0 → 1.14.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.
@@ -6,35 +6,62 @@ import type { From } from '../types/from.type.js';
6
6
  import type { Genre } from '../types/genre.type.js';
7
7
  import type { Lang } from '../types/lang.type.js';
8
8
  import type { Limit } from '../types/limit.type.js';
9
- import type { Search } from '../types/search-type.type.js';
9
+ import type { Api } from '../types/api.type.js';
10
10
  import type { Sort } from '../types/sort.type.js';
11
11
  import type { Style } from '../types/style.type.js';
12
- /**
13
- * Parameters used to search listings on the Discogs Marketplace.
14
- */
15
- export default interface SearchParams {
12
+ interface SearchParamsBase {
16
13
  /**
17
- * The type of element to search.
18
- * | Value | Description |
19
- * |-------------|--------------------------------|
20
- * | `q` | Basic query search |
21
- * | `master_id` | Search within a master release |
22
- * | `release_id`| Search within a release |
23
- * | `label_id` | Search within a label |
24
- * | `artist_id` | Search by artist |
25
- * | `user` | Search a user's wantlist |
26
- * @default 'q'
14
+ * List of formats.
15
+ * @example ['Vinyl', 'CD']
27
16
  */
28
- searchType: Search;
17
+ formats?: Array<Format>;
29
18
  /**
30
- * The search value corresponding to the selected `searchType`.
19
+ * List of format descriptions.
20
+ * @example ['Limited Edition', 'Numbered']
31
21
  */
32
- searchValue?: string | number;
22
+ formatDescriptions?: Array<FormatDescription>;
23
+ /**
24
+ * Range of years.
25
+ */
26
+ years?: {
27
+ /** Minimum year */
28
+ min: number;
29
+ /** Maximum year */
30
+ max: number;
31
+ };
32
+ /**
33
+ * If true, only listings that accept offers are returned.
34
+ * @default false
35
+ */
36
+ isMakeAnOfferOnly?: boolean;
37
+ /**
38
+ * Page number of results.
39
+ * Must be less than 401 to avoid Discogs 404 errors.
40
+ * @default 1
41
+ */
42
+ page?: number;
43
+ }
44
+ interface SearchParamsLegacyBase extends SearchParamsBase {
45
+ /**
46
+ * Api version to use.
47
+ *
48
+ * Choose `legacy` for the legacy API that scrapes HTML page. Required if you want to search on master or label.
49
+ */
50
+ api: Extract<Api, 'legacy'>;
51
+ /**
52
+ * Query string to filter.
53
+ */
54
+ query?: string;
33
55
  /**
34
56
  * Currency code for price filtering.
35
57
  * @example 'USD'
36
58
  */
37
59
  currency?: Currency;
60
+ /**
61
+ * Media conditions.
62
+ * @example 'Mint (M)'
63
+ */
64
+ condition?: Condition;
38
65
  /**
39
66
  * Genre filter.
40
67
  * @example 'Rock'
@@ -44,79 +71,158 @@ export default interface SearchParams {
44
71
  * List of styles.
45
72
  * @example ['Death Metal', 'Heavy Metal']
46
73
  */
47
- style?: Array<Style>;
74
+ styles?: Array<Style>;
48
75
  /**
49
- * List of formats.
50
- * @example ['Vinyl', 'CD']
76
+ * Expedition country filter.
77
+ * @example 'France'
51
78
  */
52
- format?: Array<Format>;
79
+ from?: From;
53
80
  /**
54
- * List of format descriptions.
55
- * @example ['Limited Edition', 'Numbered']
81
+ * Sort order for the results.
82
+ * @default 'listed,desc'
56
83
  */
57
- formatDescription?: Array<FormatDescription>;
84
+ sort?: Sort;
58
85
  /**
59
- * List of media conditions.
60
- * @example ['Mint (M)', 'Very Good Plus (VG+)']
86
+ * Number of results to return per page.
87
+ * Allowed values: 25, 50, 100, 250.
88
+ * @default 25
61
89
  */
62
- condition?: Array<Condition>;
90
+ limit?: Limit;
63
91
  /**
64
- * Release year.
65
- * Do not use together with `years`.
92
+ * Seller's name.
66
93
  */
67
- year?: number;
94
+ seller?: string;
68
95
  /**
69
- * Range of years.
70
- * Do not use together with `year`.
96
+ * User's name.
71
97
  */
72
- years?: {
73
- /** Minimum year */
74
- min: number;
75
- /** Maximum year */
76
- max: number;
77
- };
98
+ user?: string;
78
99
  /**
79
- * If true, only listings that accept offers are returned.
80
- * @default false
100
+ * Language code for Discogs interface.
101
+ * @default 'en'
81
102
  */
82
- isMakeAnOfferOnly?: boolean;
103
+ lang?: Lang;
104
+ }
105
+ /**
106
+ * Parameters used to search listings on the Discogs Marketplace via new old HTML Scraping.
107
+ */
108
+ export type SearchParamsLegacy = ({
109
+ /** Master release ID. */
110
+ masterId?: number;
111
+ labelId?: never;
112
+ releaseId?: never;
113
+ artistId?: never;
114
+ } | {
115
+ masterId?: never;
116
+ /** Label ID. */
117
+ labelId?: number;
118
+ releaseId?: never;
119
+ artistId?: never;
120
+ } | {
121
+ masterId?: never;
122
+ labelId?: never;
123
+ /** Release ID. */
124
+ releaseId?: number;
125
+ artistId?: never;
126
+ } | {
127
+ masterId?: never;
128
+ labelId?: never;
129
+ releaseId?: never;
130
+ /** Artist ID. */
131
+ artistId?: number;
132
+ }) & SearchParamsLegacyBase;
133
+ interface SearchParamsModernBase extends SearchParamsBase {
134
+ /**
135
+ * Api version to use.
136
+ *
137
+ * Choose `v2` for the modern API that uses JSON (used in the `https://www.discogs.com/shop/mywants` page).
138
+ */
139
+ api: Extract<Api, 'v2'>;
140
+ /**
141
+ * List of currency codes for price filtering.
142
+ * @example ['USD']
143
+ */
144
+ currencies?: Array<Currency>;
83
145
  /**
84
- * Expedition country filter (2-letter country code).
85
- * @example 'US'
146
+ * List of media conditions.
147
+ * @example ['Mint (M)', 'Very Good Plus (VG+)']
86
148
  */
87
- from?: From;
149
+ conditions?: Array<Condition>;
88
150
  /**
89
- * Seller's username filter.
151
+ * List of genres.
152
+ * @example ['Rock']
90
153
  */
91
- seller?: string;
154
+ genres?: Array<Genre>;
155
+ /**
156
+ * Expedition country filter.
157
+ * @example 'France'
158
+ */
159
+ from?: Array<From>;
92
160
  /**
93
161
  * Sort order for the results.
94
162
  * @default 'listed,desc'
95
163
  */
96
- sort?: Sort;
164
+ sort?: Exclude<Sort, 'label,asc' | 'label,desc'>;
97
165
  /**
98
166
  * Number of results to return per page.
99
- * Allowed values: 25, 50, 100, 250.
100
167
  * @default 25
101
168
  */
102
- limit?: Limit;
169
+ limit?: number;
103
170
  /**
104
- * Page number of results.
105
- * Must be less than 401 to avoid Discogs 404 errors.
106
- * @default 1
171
+ * List of artist IDs.
107
172
  */
108
- page?: number;
173
+ artistIds?: Array<number>;
109
174
  /**
110
- * Language code for Discogs interface.
111
- * @default 'en'
175
+ * List of seller IDs.
176
+ *
177
+ * You can easily find someone's ID via the Discogs API: https://api.discogs.com/users/{seller_name}
112
178
  */
113
- lang?: Lang;
179
+ sellerIds?: Array<number>;
180
+ /**
181
+ * Price range filter.
182
+ */
183
+ priceRange?: {
184
+ /** Minimum price */
185
+ min: number;
186
+ /** Maximum price */
187
+ max: number;
188
+ };
189
+ /**
190
+ * Minimum seller rating, from 0 to 100.
191
+ * @default 0
192
+ */
193
+ sellerRatingMin?: number;
194
+ /**
195
+ * Include generic sleeves.
196
+ * @default true
197
+ */
198
+ includeGenericSleeves?: boolean;
199
+ /**
200
+ * Include sleeveless media.
201
+ * @default true
202
+ */
203
+ includeSleevelessMedia?: boolean;
204
+ /**
205
+ * Show unavailable items.
206
+ * @default true
207
+ */
208
+ showUnavailable?: boolean;
209
+ /**
210
+ * Minimum seller rating count.
211
+ * @default 0
212
+ */
213
+ sellerRatingCountMin?: number;
114
214
  }
115
- export type SearchParamsDefaulted = SearchParams & {
116
- searchType: NonNullable<SearchParams['searchType']>;
117
- isMakeAnOfferOnly: NonNullable<SearchParams['isMakeAnOfferOnly']>;
118
- sort: NonNullable<SearchParams['sort']>;
119
- limit: NonNullable<SearchParams['limit']>;
120
- page: NonNullable<SearchParams['page']>;
121
- lang: NonNullable<SearchParams['lang']>;
122
- };
215
+ /**
216
+ * Parameters used to search listings on the Discogs Marketplace via new new modern API.
217
+ */
218
+ export type SearchParamsModern = ({
219
+ /** User's wantlist name. */
220
+ wantlist?: string;
221
+ releaseIds?: never;
222
+ } | {
223
+ wantlist?: never;
224
+ /** List of release IDs. */
225
+ releaseIds?: Array<number>;
226
+ }) & SearchParamsModernBase;
227
+ export type SearchParams = SearchParamsLegacy | SearchParamsModern;
228
+ export {};
@@ -8,29 +8,47 @@ export default interface SearchResult {
8
8
  items: Array<{
9
9
  /** Unique identifier for the listing */
10
10
  id: number;
11
- /** Title details */
12
- title: {
13
- /** Full original title */
14
- original: string;
11
+ /** Full title of the listing */
12
+ title: string;
13
+ /** Artists details */
14
+ artists: Array<{
15
+ /** Artist ID */
16
+ id: number | null;
15
17
  /** Artist name */
16
- artist: string;
17
- /** Item description */
18
- item: string;
19
- /** Array of format names */
20
- formats: Array<string>;
18
+ name: string;
19
+ /** Artist URL */
20
+ url: string | null;
21
+ }>;
22
+ /** Release details */
23
+ release: {
24
+ /** Release ID */
25
+ id: number;
26
+ /** Release name */
27
+ name: string;
28
+ /** Release URL */
29
+ url: string;
21
30
  };
31
+ /** List of formats */
32
+ formats: Array<string>;
33
+ /** labels */
34
+ labels: Array<{
35
+ /** Label ID */
36
+ id: number;
37
+ /** Label name */
38
+ name: string;
39
+ /** Label URL */
40
+ url: string;
41
+ }>;
22
42
  /** URL to the listing on Discogs */
23
43
  url: string;
24
44
  /** Date the item was listed */
25
45
  listedAt: Date | null;
26
- /** Array of label names */
27
- labels: Array<string>;
28
46
  /** Array of catalog numbers */
29
47
  catnos: Array<string>;
30
48
  /** URL to the item's image */
31
- imageUrl: string;
49
+ imageUrl: string | null;
32
50
  /** Text description of the item */
33
- description: string;
51
+ description: string | null;
34
52
  /** Indicates if offers are accepted */
35
53
  isAcceptingOffer: boolean;
36
54
  /** Availability status of the item */
@@ -47,9 +65,9 @@ export default interface SearchResult {
47
65
  /** Sleeve condition */
48
66
  sleeve: {
49
67
  /** Full description */
50
- full: string;
68
+ full: string | null;
51
69
  /** Short code */
52
- short: string;
70
+ short: string | null;
53
71
  };
54
72
  };
55
73
  /** Seller information */
@@ -59,9 +77,9 @@ export default interface SearchResult {
59
77
  /** Seller's profile URL */
60
78
  url: string;
61
79
  /** Seller rating/score */
62
- score: string;
80
+ score: string | null;
63
81
  /** Number of notes/reviews */
64
- notes: number;
82
+ notes: number | null;
65
83
  };
66
84
  /** Pricing details */
67
85
  price: {
@@ -69,12 +87,12 @@ export default interface SearchResult {
69
87
  * Base price as a string combining amount and currency.
70
88
  * @example '12.34 USD'
71
89
  */
72
- base: `${number} ${CurrencyValues}` | '';
90
+ base: `${number} ${CurrencyValues}`;
73
91
  /**
74
92
  * Shipping cost as a string combining amount and currency.
75
93
  * @example '5.67 USD'
76
94
  */
77
- shipping: `${number} ${CurrencyValues}` | '';
95
+ shipping: `${number} ${CurrencyValues}` | null;
78
96
  };
79
97
  /** Shipping origin country */
80
98
  country: {
@@ -93,13 +111,6 @@ export default interface SearchResult {
93
111
  /** Number of users who want this item */
94
112
  want: number;
95
113
  };
96
- /** Release details */
97
- release: {
98
- /** Release ID */
99
- id: number;
100
- /** Release URL */
101
- url: string;
102
- };
103
114
  }>;
104
115
  /** Pagination information */
105
116
  page: {
@@ -1,11 +1,11 @@
1
1
  import type SearchResult from '../interfaces/search-result.interface.js';
2
- import type { SearchParamsDefaulted } from '../interfaces/search-params.interface.js';
2
+ import type { SearchParamsLegacy } from '../interfaces/search-params.interface.js';
3
3
  /**
4
4
  * Parses the page and returns the items found.
5
5
  * @param url Url to scrape
6
6
  * @returns Items found and total
7
7
  */
8
- export default function scrapeLegacy({ searchType, searchValue, currency, genre, style, format, formatDescription, condition, year, years, isMakeAnOfferOnly, from, seller, sort, limit, page, lang, }: SearchParamsDefaulted): Promise<Pick<SearchResult, 'items' | 'urlGenerated'> & {
8
+ export default function scrapeLegacy({ currency, genre, styles, formats, formatDescriptions, condition, years, isMakeAnOfferOnly, from, sort, limit, page, seller, lang, masterId, labelId, artistId, releaseId, user, query, }: SearchParamsLegacy): Promise<Pick<SearchResult, 'items' | 'urlGenerated'> & {
9
9
  /** Total items found */
10
10
  total: SearchResult['result']['total'];
11
11
  }>;
@@ -7,39 +7,21 @@ exports.default = scrapeLegacy;
7
7
  const linkedom_1 = require("linkedom");
8
8
  const currency_data_1 = __importDefault(require("../data/currency.data.js"));
9
9
  const country_data_1 = __importDefault(require("../data/country.data.js"));
10
+ const search_1 = require("../search.js");
10
11
  /**
11
12
  * Generate URL to be parsed
12
13
  * @returns Url
13
14
  */
14
- function generateUrl({ searchType, seller, lang, }) {
15
+ function generateUrl({ seller, lang, user, }) {
15
16
  const baseUrl = `https://www.discogs.com/${lang}`;
16
17
  if (seller) {
17
- const path = searchType === 'user' ? 'mywants' : 'profile';
18
+ const path = user ? 'mywants' : 'profile';
18
19
  return `${baseUrl}/seller/${seller}/${path}`;
19
20
  }
20
21
  else {
21
- const path = searchType === 'user' ? 'mywants' : 'list';
22
- return `${baseUrl}/sell/${path}`;
22
+ return `${baseUrl}/sell/list`;
23
23
  }
24
24
  }
25
- /**
26
- * Serialize params URL
27
- * @param params Object of GET parameters
28
- * @returns Url
29
- */
30
- function serializeParams(params) {
31
- return Object.entries(params)
32
- .flatMap(([key, value]) => {
33
- if (value === undefined || value === null) {
34
- return [];
35
- }
36
- if (Array.isArray(value)) {
37
- return value.map(v => `${key}=${encodeURIComponent(v)}`);
38
- }
39
- return [`${key}=${encodeURIComponent(value)}`];
40
- })
41
- .join('&');
42
- }
43
25
  /**
44
26
  * Converts a currency string to a standardized format.
45
27
  * @param value String to clean
@@ -47,22 +29,22 @@ function serializeParams(params) {
47
29
  */
48
30
  function convertCurrency(value) {
49
31
  if (!value) {
50
- return '';
32
+ return null;
51
33
  }
52
34
  const currencyFound = Object.keys(currency_data_1.default).find(key => value.includes(key));
53
35
  if (!currencyFound) {
54
- return '';
36
+ return null;
55
37
  }
56
38
  const currencyClean = currency_data_1.default[currencyFound];
57
39
  const amount = value
58
40
  .replace(currencyClean !== 'JPY' ? /[.](?=.*[.])/g : /\./g, '') // Remove all dots but the last, except for JPY
59
41
  .replace(currencyFound, '') // Remove original currency
60
42
  .replace(/\s\s+/g, ''); // Remove spaces
61
- const amountParsed = Number.parseFloat(amount);
43
+ const amountParsed = currencyClean === 'JPY' ? Number.parseInt(amount) : Number.parseFloat(amount);
62
44
  if (Number.isNaN(amountParsed)) {
63
- return '';
45
+ return null;
64
46
  }
65
- return `${amountParsed} ${currencyClean}`;
47
+ return currencyClean === 'JPY' ? `${amountParsed} ${currencyClean}` : `${amountParsed.toFixed(2)} ${currencyClean}`;
66
48
  }
67
49
  /**
68
50
  * Safely parses a number from a string.
@@ -78,34 +60,42 @@ function safeParseInt(value) {
78
60
  * @param url Url to scrape
79
61
  * @returns Items found and total
80
62
  */
81
- async function scrapeLegacy({ searchType, searchValue, currency, genre, style, format, formatDescription, condition, year, years, isMakeAnOfferOnly, from, seller, sort, limit, page, lang, }) {
63
+ async function scrapeLegacy({ currency, genre, styles, formats, formatDescriptions, condition, years, isMakeAnOfferOnly = false, from, sort = search_1.DEFAULT_SORT, limit = search_1.DEFAULT_LIMIT, page = search_1.DEFAULT_PAGE, seller, lang = 'en', masterId, labelId, artistId, releaseId, user, query, }) {
82
64
  /** Url to be called by the browser */
83
65
  const urlGenerated = [
84
- generateUrl({ searchType, seller, lang }),
85
- serializeParams({
86
- [searchType]: searchValue,
87
- currency,
88
- genre,
89
- style: style?.length ? style : null,
90
- format: format?.length ? format : null,
91
- format_desc: formatDescription?.length ? formatDescription : null,
92
- condition: condition?.length ? condition : null,
93
- year: year && !years ? year : null,
94
- year1: years?.min && !year ? years.min : null,
95
- year2: years?.max && !year ? years.max : null,
96
- offers: isMakeAnOfferOnly ? 1 : null,
97
- ships_from: from,
98
- limit,
99
- page,
100
- sort,
101
- }),
66
+ generateUrl({ seller, lang, user }),
67
+ new URLSearchParams([
68
+ ['master_id', masterId?.toString() ?? ''],
69
+ ['label_id', labelId?.toString() ?? ''],
70
+ ['artist_id', artistId?.toString() ?? ''],
71
+ ['release_id', releaseId?.toString() ?? ''],
72
+ ['user', user?.toString() ?? ''],
73
+ ['q', query ?? ''],
74
+ ['currency', currency ?? ''],
75
+ ['genre', genre ?? ''],
76
+ ...(styles?.map(s => ['style', s]) ?? []),
77
+ ...(formats?.map(f => ['format', f]) ?? []),
78
+ ...(formatDescriptions?.map(fd => ['format_desc', fd]) ?? []),
79
+ ['condition', condition ?? ''],
80
+ ['year1', years?.min ? years.min.toString() : ''],
81
+ ['year2', years?.max ? years.max.toString() : ''],
82
+ ['offers', isMakeAnOfferOnly ? '1' : ''],
83
+ ['ships_from', Object.keys(country_data_1.default).find(key => from === country_data_1.default[key]) ?? ''],
84
+ ['limit', limit.toString()],
85
+ ['page', page.toString()],
86
+ ['sort', sort],
87
+ ].filter(([, p]) => !!p)).toString(),
102
88
  ].join('?');
89
+ const headers = new Headers({
90
+ 'User-Agent': 'Discogs',
91
+ 'Content-Type': 'application/json',
92
+ });
93
+ // If there a seller and user, we cannot use PJAX otherwise 404 error
94
+ if (!(seller && user)) {
95
+ headers.set('X-PJAX', 'true');
96
+ }
103
97
  const response = await globalThis.fetch(urlGenerated, {
104
- headers: {
105
- 'User-Agent': 'Discogs',
106
- 'Content-Type': 'application/json',
107
- 'X-PJAX': 'true',
108
- },
98
+ headers,
109
99
  referrer: 'https://discogs.com',
110
100
  });
111
101
  const content = await response.text();
@@ -139,26 +129,38 @@ async function scrapeLegacy({ searchType, searchValue, currency, genre, style, f
139
129
  const releaseHref = el.querySelector('a.item_release_link')?.getAttribute('href') ?? '';
140
130
  return {
141
131
  id: safeParseInt(itemHref.split('/').pop()),
142
- title: {
143
- original: originalTitle,
144
- artist: firstIndexOfDash > -1 ? originalTitle.substring(0, firstIndexOfDash) : '',
145
- item: firstIndexOfDash > -1 && lastIndexOfParenthesis > -1
132
+ title: originalTitle,
133
+ artists: [
134
+ {
135
+ id: null,
136
+ name: firstIndexOfDash > -1 ? originalTitle.substring(0, firstIndexOfDash) : '',
137
+ url: null,
138
+ },
139
+ ],
140
+ release: {
141
+ id: safeParseInt(releaseHref.split('release/').pop()?.split('-').shift()),
142
+ name: firstIndexOfDash > -1 && lastIndexOfParenthesis > -1
146
143
  ? originalTitle.substring(firstIndexOfDash + 3, lastIndexOfParenthesis)
147
144
  : '',
148
- formats: lastIndexOfParenthesis > -1
149
- ? originalTitle.substring(lastIndexOfParenthesis + 2, originalTitle.length - 1).split(', ')
150
- : [],
145
+ url: `https://www.discogs.com${releaseHref}`,
151
146
  },
147
+ formats: lastIndexOfParenthesis > -1
148
+ ? originalTitle.substring(lastIndexOfParenthesis + 2, originalTitle.length - 1).split(', ')
149
+ : [],
150
+ labels: [...el.querySelectorAll(".label_and_cat a[href^='https://www.discogs.com/']")]
151
+ .map(x => ({
152
+ id: safeParseInt(x.getAttribute('href')?.split('label/').pop()?.split('-').shift()),
153
+ name: x.textContent?.trim() ?? '',
154
+ url: `https://www.discogs.com${x.getAttribute('href') ?? ''}`,
155
+ }))
156
+ .filter((value, index, self) => self.findIndex(v => v.name === value.name) === index),
152
157
  url: `https://www.discogs.com${itemHref}`,
153
158
  listedAt: null,
154
- labels: [...el.querySelectorAll(".label_and_cat a[href^='https://www.discogs.com/']")]
155
- .map(x => x.textContent?.trim() ?? '')
156
- .filter((value, index, self) => self.indexOf(value) === index),
157
159
  catnos: getTextContent('.label_and_cat .item_catno', el) // cspell:disable-line
158
160
  .split(', ')
159
161
  .filter(x => x !== 'none'),
160
- imageUrl: el.querySelector('.marketplace_image')?.getAttribute('data-src') ?? '',
161
- description: getTextContent('.item_condition + *', el),
162
+ imageUrl: el.querySelector('.marketplace_image')?.getAttribute('data-src') ?? null,
163
+ description: getTextContent('.item_condition + *', el) || null,
162
164
  isAcceptingOffer: getTextContent('.item_add_to_cart p a strong', el).split('/').length > 1,
163
165
  isAvailable: !el.classList.contains('unavailable'),
164
166
  condition: {
@@ -167,17 +169,18 @@ async function scrapeLegacy({ searchType, searchValue, currency, genre, style, f
167
169
  short: /\(([^)]+)\)/.exec(mediaCondition)?.[1] ?? '',
168
170
  },
169
171
  sleeve: {
170
- full: sleeveCondition,
171
- short: /\(([^)]+)\)/.exec(sleeveCondition)?.[1] ?? '',
172
+ full: sleeveCondition || null,
173
+ short: /\(([^)]+)\)/.exec(sleeveCondition)?.[1] ?? null,
172
174
  },
173
175
  },
174
176
  seller: {
175
177
  name: getTextContent('.seller_info a', el),
176
178
  url: `https://www.discogs.com${el.querySelector('.seller_info a')?.getAttribute('href') ?? ''}`,
177
- score: getTextContent('.seller_info li:nth-child(2) strong', el),
178
- notes: safeParseInt(getTextContent('.seller_info li:nth-child(2) .section_link', el)),
179
+ score: getTextContent('.seller_info li:nth-child(2) strong', el) || null,
180
+ notes: safeParseInt(getTextContent('.seller_info li:nth-child(2) .section_link', el)) || null,
179
181
  },
180
182
  price: {
183
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
181
184
  base: convertCurrency(getTextContent('.price', el).replace(/,/, '.')),
182
185
  shipping: convertCurrency(getTextContent('.item_shipping', el)
183
186
  .replace(/(\s+|\+)/g, ' ')
@@ -191,10 +194,6 @@ async function scrapeLegacy({ searchType, searchValue, currency, genre, style, f
191
194
  have: safeParseInt(getTextContent('.community_summary .community_result:nth-child(1) .community_number', el)),
192
195
  want: safeParseInt(getTextContent('.community_summary .community_result:nth-child(2) .community_number', el)),
193
196
  },
194
- release: {
195
- id: safeParseInt(releaseHref.split('release/').pop()?.split('-').shift()),
196
- url: `https://www.discogs.com${releaseHref}`,
197
- },
198
197
  };
199
198
  });
200
199
  return { total, items, urlGenerated };
@@ -1,14 +1,11 @@
1
1
  import type SearchResult from '../interfaces/search-result.interface.js';
2
- import type { SearchParamsDefaulted } from '../interfaces/search-params.interface.js';
2
+ import type { SearchParamsModern } from '../interfaces/search-params.interface.js';
3
3
  /**
4
4
  * Parses the page and returns the items found.
5
5
  * @param SearchParams Search parameters
6
6
  * @returns Items found and total
7
7
  */
8
- export default function scrape({ currency, genre, format, formatDescription, condition, years, isMakeAnOfferOnly, from, sort, limit, page, releases, }: SearchParamsDefaulted & {
9
- /** Releases */
10
- releases?: Array<number>;
11
- }): Promise<Pick<SearchResult, 'items' | 'urlGenerated'> & {
8
+ export default function scrape({ currencies, genres, formats, formatDescriptions, conditions, years, isMakeAnOfferOnly, from, sort, limit, page, releaseIds, sellerIds, artistIds, priceRange, sellerRatingMin, includeGenericSleeves, includeSleevelessMedia, showUnavailable, sellerRatingCountMin, }: SearchParamsModern): Promise<Pick<SearchResult, 'items' | 'urlGenerated'> & {
12
9
  /** Total items found */
13
10
  total: SearchResult['result']['total'];
14
11
  }>;