node-csfd-api 4.1.5 → 4.1.6
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/helpers/creator.helper.js +4 -4
- package/helpers/creator.helper.js.map +1 -1
- package/helpers/creator.helper.mjs +4 -4
- package/helpers/creator.helper.mjs.map +1 -1
- package/helpers/user-ratings.helper.js +2 -2
- package/helpers/user-ratings.helper.js.map +1 -1
- package/helpers/user-ratings.helper.mjs +2 -2
- package/helpers/user-ratings.helper.mjs.map +1 -1
- package/helpers/user-reviews.helper.js +3 -3
- package/helpers/user-reviews.helper.js.map +1 -1
- package/helpers/user-reviews.helper.mjs +3 -3
- package/helpers/user-reviews.helper.mjs.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/services/user-ratings.service.js +2 -2
- package/services/user-ratings.service.js.map +1 -1
- package/services/user-ratings.service.mjs +2 -2
- package/services/user-ratings.service.mjs.map +1 -1
- package/services/user-reviews.service.js +2 -2
- package/services/user-reviews.service.js.map +1 -1
- package/services/user-reviews.service.mjs +2 -2
- package/services/user-reviews.service.mjs.map +1 -1
|
@@ -13,10 +13,10 @@ const getCreatorName = (el) => {
|
|
|
13
13
|
return (el?.querySelector("h1"))?.innerText?.trim() ?? null;
|
|
14
14
|
};
|
|
15
15
|
const getCreatorBirthdayInfo = (el) => {
|
|
16
|
-
const infoBlock = el.querySelector("
|
|
16
|
+
const infoBlock = el.querySelector(".creator-profile-details p");
|
|
17
17
|
const text = infoBlock?.innerHTML.trim();
|
|
18
|
-
const birthPlaceRow = infoBlock?.querySelector(".info-place")?.
|
|
19
|
-
const ageRow = infoBlock?.querySelector(".info")?.
|
|
18
|
+
const birthPlaceRow = infoBlock?.querySelector(".info-place")?.innerText.trim();
|
|
19
|
+
const ageRow = infoBlock?.querySelector(".info")?.innerText.trim();
|
|
20
20
|
let birthday = "";
|
|
21
21
|
if (text) {
|
|
22
22
|
const birthdayRow = text.split("\n").find((x) => x.includes("nar."));
|
|
@@ -44,7 +44,7 @@ const parseAge = (text) => {
|
|
|
44
44
|
};
|
|
45
45
|
const parseBirthPlace = (text) => text.trim().replace(/<br>/g, "").trim();
|
|
46
46
|
const getCreatorFilms = (el) => {
|
|
47
|
-
const filmNodes = el?.querySelectorAll(".box")?.[0]?.querySelectorAll("table tr") ?? [];
|
|
47
|
+
const filmNodes = el?.querySelectorAll(".updated-box")?.[0]?.querySelectorAll("table tr") ?? [];
|
|
48
48
|
let yearCache = null;
|
|
49
49
|
return filmNodes.map((filmNode) => {
|
|
50
50
|
const id = getCreatorId(filmNode.querySelector("td.name .film-title-name")?.attributes?.href);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.helper.js","names":["parseColor","parseIdFromUrl","addProtocol"],"sources":["../../src/helpers/creator.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDCreatorScreening } from '../dto/creator';\nimport { CSFDColorRating } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseIdFromUrl } from './global.helper';\n\nconst getCreatorColorRating = (el: HTMLElement | null): CSFDColorRating => {\n const classes: string[] = el?.classNames.split(' ') ?? [];\n const last = classes[classes.length - 1] as CSFDColors | undefined;\n return parseColor(last);\n};\n\nexport const getCreatorId = (url: string | null | undefined): number | null => {\n return url ? parseIdFromUrl(url) : null;\n};\n\nexport const getCreatorName = (el: HTMLElement | null): string | null => {\n const h1 = el?.querySelector('h1');\n return h1?.innerText?.trim() ?? null;\n};\n\nexport const getCreatorBirthdayInfo = (\n el: HTMLElement | null\n): { birthday: string; age: number; birthPlace: string } => {\n const infoBlock = el.querySelector('
|
|
1
|
+
{"version":3,"file":"creator.helper.js","names":["parseColor","parseIdFromUrl","addProtocol"],"sources":["../../src/helpers/creator.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDCreatorScreening } from '../dto/creator';\nimport { CSFDColorRating } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseIdFromUrl } from './global.helper';\n\nconst getCreatorColorRating = (el: HTMLElement | null): CSFDColorRating => {\n const classes: string[] = el?.classNames.split(' ') ?? [];\n const last = classes[classes.length - 1] as CSFDColors | undefined;\n return parseColor(last);\n};\n\nexport const getCreatorId = (url: string | null | undefined): number | null => {\n return url ? parseIdFromUrl(url) : null;\n};\n\nexport const getCreatorName = (el: HTMLElement | null): string | null => {\n const h1 = el?.querySelector('h1');\n return h1?.innerText?.trim() ?? null;\n};\n\nexport const getCreatorBirthdayInfo = (\n el: HTMLElement | null\n): { birthday: string; age: number; birthPlace: string } => {\n const infoBlock = el.querySelector('.creator-profile-details p');\n const text = infoBlock?.innerHTML.trim();\n const birthPlaceRow = infoBlock?.querySelector('.info-place')?.innerText.trim();\n const ageRow = infoBlock?.querySelector('.info')?.innerText.trim();\n\n let birthday: string = '';\n\n if (text) {\n const parts = text.split('\\n');\n const birthdayRow = parts.find((x) => x.includes('nar.'));\n birthday = birthdayRow ? parseBirthday(birthdayRow) : '';\n }\n\n const age = ageRow ? +parseAge(ageRow) : null;\n const birthPlace = birthPlaceRow ? parseBirthPlace(birthPlaceRow) : '';\n return { birthday, age, birthPlace };\n};\n\nexport const getCreatorBio = (el: HTMLElement | null): string | null => {\n const p = el?.querySelector('.article-content p');\n const first = p?.text?.trim().split('\\n')[0]?.trim();\n return first || null;\n};\n\nexport const getCreatorPhoto = (el: HTMLElement | null): string | null => {\n const src = el?.querySelector('img')?.getAttribute('src');\n return src ? addProtocol(src) : null;\n};\n\nconst parseBirthday = (text: string): string => text.replace(/nar\\./g, '').trim();\n\nconst parseAge = (text: string): number | null => {\n const digits = text.replace(/[^\\d]/g, '');\n return digits ? Number(digits) : null;\n};\n\nconst parseBirthPlace = (text: string): string => text.trim().replace(/<br>/g, '').trim();\n\nexport const getCreatorFilms = (el: HTMLElement | null): CSFDCreatorScreening[] => {\n const filmNodes = el?.querySelectorAll('.updated-box')?.[0]?.querySelectorAll('table tr') ?? [];\n let yearCache: number | null = null;\n\n const films = filmNodes.map((filmNode) => {\n const id = getCreatorId(filmNode.querySelector('td.name .film-title-name')?.attributes?.href);\n const title = filmNode.querySelector('.name')?.text?.trim();\n const yearText = filmNode.querySelector('.year')?.text?.trim();\n const year = yearText ? +yearText : null;\n const colorRating = getCreatorColorRating(filmNode.querySelector('.name .icon'));\n\n // Cache year from previous film because there is a gap between movies with same year\n if (typeof year === 'number' && !isNaN(year)) {\n yearCache = +year;\n }\n\n const finalYear = year ?? yearCache;\n if (id != null && title && finalYear != null) {\n return { id, title, year: finalYear, colorRating };\n }\n return null;\n });\n // Remove empty objects\n const filmsUnique = films.filter(Boolean) as CSFDCreatorScreening[];\n return filmsUnique;\n};\n"],"mappings":";;;AAMA,MAAM,yBAAyB,OAA4C;CACzE,MAAM,UAAoB,IAAI,WAAW,MAAM,IAAI,IAAI,EAAE;CACzD,MAAM,OAAO,QAAQ,QAAQ,SAAS;AACtC,QAAOA,iCAAW,KAAK;;AAGzB,MAAa,gBAAgB,QAAkD;AAC7E,QAAO,MAAMC,qCAAe,IAAI,GAAG;;AAGrC,MAAa,kBAAkB,OAA0C;AAEvE,SADW,IAAI,cAAc,KAAK,GACvB,WAAW,MAAM,IAAI;;AAGlC,MAAa,0BACX,OAC0D;CAC1D,MAAM,YAAY,GAAG,cAAc,6BAA6B;CAChE,MAAM,OAAO,WAAW,UAAU,MAAM;CACxC,MAAM,gBAAgB,WAAW,cAAc,cAAc,EAAE,UAAU,MAAM;CAC/E,MAAM,SAAS,WAAW,cAAc,QAAQ,EAAE,UAAU,MAAM;CAElE,IAAI,WAAmB;AAEvB,KAAI,MAAM;EAER,MAAM,cADQ,KAAK,MAAM,KAAK,CACJ,MAAM,MAAM,EAAE,SAAS,OAAO,CAAC;AACzD,aAAW,cAAc,cAAc,YAAY,GAAG;;CAGxD,MAAM,MAAM,SAAS,CAAC,SAAS,OAAO,GAAG;CACzC,MAAM,aAA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@@ const getCreatorName = (el) => {
|
|
|
13
13
|
return (el?.querySelector("h1"))?.innerText?.trim() ?? null;
|
|
14
14
|
};
|
|
15
15
|
const getCreatorBirthdayInfo = (el) => {
|
|
16
|
-
const infoBlock = el.querySelector("
|
|
16
|
+
const infoBlock = el.querySelector(".creator-profile-details p");
|
|
17
17
|
const text = infoBlock?.innerHTML.trim();
|
|
18
|
-
const birthPlaceRow = infoBlock?.querySelector(".info-place")?.
|
|
19
|
-
const ageRow = infoBlock?.querySelector(".info")?.
|
|
18
|
+
const birthPlaceRow = infoBlock?.querySelector(".info-place")?.innerText.trim();
|
|
19
|
+
const ageRow = infoBlock?.querySelector(".info")?.innerText.trim();
|
|
20
20
|
let birthday = "";
|
|
21
21
|
if (text) {
|
|
22
22
|
const birthdayRow = text.split("\n").find((x) => x.includes("nar."));
|
|
@@ -44,7 +44,7 @@ const parseAge = (text) => {
|
|
|
44
44
|
};
|
|
45
45
|
const parseBirthPlace = (text) => text.trim().replace(/<br>/g, "").trim();
|
|
46
46
|
const getCreatorFilms = (el) => {
|
|
47
|
-
const filmNodes = el?.querySelectorAll(".box")?.[0]?.querySelectorAll("table tr") ?? [];
|
|
47
|
+
const filmNodes = el?.querySelectorAll(".updated-box")?.[0]?.querySelectorAll("table tr") ?? [];
|
|
48
48
|
let yearCache = null;
|
|
49
49
|
return filmNodes.map((filmNode) => {
|
|
50
50
|
const id = getCreatorId(filmNode.querySelector("td.name .film-title-name")?.attributes?.href);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.helper.mjs","names":[],"sources":["../../src/helpers/creator.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDCreatorScreening } from '../dto/creator';\nimport { CSFDColorRating } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseIdFromUrl } from './global.helper';\n\nconst getCreatorColorRating = (el: HTMLElement | null): CSFDColorRating => {\n const classes: string[] = el?.classNames.split(' ') ?? [];\n const last = classes[classes.length - 1] as CSFDColors | undefined;\n return parseColor(last);\n};\n\nexport const getCreatorId = (url: string | null | undefined): number | null => {\n return url ? parseIdFromUrl(url) : null;\n};\n\nexport const getCreatorName = (el: HTMLElement | null): string | null => {\n const h1 = el?.querySelector('h1');\n return h1?.innerText?.trim() ?? null;\n};\n\nexport const getCreatorBirthdayInfo = (\n el: HTMLElement | null\n): { birthday: string; age: number; birthPlace: string } => {\n const infoBlock = el.querySelector('
|
|
1
|
+
{"version":3,"file":"creator.helper.mjs","names":[],"sources":["../../src/helpers/creator.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDCreatorScreening } from '../dto/creator';\nimport { CSFDColorRating } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { addProtocol, parseColor, parseIdFromUrl } from './global.helper';\n\nconst getCreatorColorRating = (el: HTMLElement | null): CSFDColorRating => {\n const classes: string[] = el?.classNames.split(' ') ?? [];\n const last = classes[classes.length - 1] as CSFDColors | undefined;\n return parseColor(last);\n};\n\nexport const getCreatorId = (url: string | null | undefined): number | null => {\n return url ? parseIdFromUrl(url) : null;\n};\n\nexport const getCreatorName = (el: HTMLElement | null): string | null => {\n const h1 = el?.querySelector('h1');\n return h1?.innerText?.trim() ?? null;\n};\n\nexport const getCreatorBirthdayInfo = (\n el: HTMLElement | null\n): { birthday: string; age: number; birthPlace: string } => {\n const infoBlock = el.querySelector('.creator-profile-details p');\n const text = infoBlock?.innerHTML.trim();\n const birthPlaceRow = infoBlock?.querySelector('.info-place')?.innerText.trim();\n const ageRow = infoBlock?.querySelector('.info')?.innerText.trim();\n\n let birthday: string = '';\n\n if (text) {\n const parts = text.split('\\n');\n const birthdayRow = parts.find((x) => x.includes('nar.'));\n birthday = birthdayRow ? parseBirthday(birthdayRow) : '';\n }\n\n const age = ageRow ? +parseAge(ageRow) : null;\n const birthPlace = birthPlaceRow ? parseBirthPlace(birthPlaceRow) : '';\n return { birthday, age, birthPlace };\n};\n\nexport const getCreatorBio = (el: HTMLElement | null): string | null => {\n const p = el?.querySelector('.article-content p');\n const first = p?.text?.trim().split('\\n')[0]?.trim();\n return first || null;\n};\n\nexport const getCreatorPhoto = (el: HTMLElement | null): string | null => {\n const src = el?.querySelector('img')?.getAttribute('src');\n return src ? addProtocol(src) : null;\n};\n\nconst parseBirthday = (text: string): string => text.replace(/nar\\./g, '').trim();\n\nconst parseAge = (text: string): number | null => {\n const digits = text.replace(/[^\\d]/g, '');\n return digits ? Number(digits) : null;\n};\n\nconst parseBirthPlace = (text: string): string => text.trim().replace(/<br>/g, '').trim();\n\nexport const getCreatorFilms = (el: HTMLElement | null): CSFDCreatorScreening[] => {\n const filmNodes = el?.querySelectorAll('.updated-box')?.[0]?.querySelectorAll('table tr') ?? [];\n let yearCache: number | null = null;\n\n const films = filmNodes.map((filmNode) => {\n const id = getCreatorId(filmNode.querySelector('td.name .film-title-name')?.attributes?.href);\n const title = filmNode.querySelector('.name')?.text?.trim();\n const yearText = filmNode.querySelector('.year')?.text?.trim();\n const year = yearText ? +yearText : null;\n const colorRating = getCreatorColorRating(filmNode.querySelector('.name .icon'));\n\n // Cache year from previous film because there is a gap between movies with same year\n if (typeof year === 'number' && !isNaN(year)) {\n yearCache = +year;\n }\n\n const finalYear = year ?? yearCache;\n if (id != null && title && finalYear != null) {\n return { id, title, year: finalYear, colorRating };\n }\n return null;\n });\n // Remove empty objects\n const filmsUnique = films.filter(Boolean) as CSFDCreatorScreening[];\n return filmsUnique;\n};\n"],"mappings":";;;AAMA,MAAM,yBAAyB,OAA4C;CACzE,MAAM,UAAoB,IAAI,WAAW,MAAM,IAAI,IAAI,EAAE;CACzD,MAAM,OAAO,QAAQ,QAAQ,SAAS;AACtC,QAAO,WAAW,KAAK;;AAGzB,MAAa,gBAAgB,QAAkD;AAC7E,QAAO,MAAM,eAAe,IAAI,GAAG;;AAGrC,MAAa,kBAAkB,OAA0C;AAEvE,SADW,IAAI,cAAc,KAAK,GACvB,WA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AK;EAC7F,MAAM,QAAQ,SAAS,cAAc,QAAQ,EAAE,MAAM,MAAM;EAC3D,MAAM,WAAW,SAAS,cAAc,QAAQ,EAAE,MAAM,MAAM;EAC9D,MAAM,OAAO,WAAW,CAAC,WAAW;EACpC,MAAM,cAAc,sBAAsB,SAAS,cAAc,cAAc,CAAC;AAGhF,MAAI,OAAO,SAAS,YAAY,CAAC,MAAM,KAAK,CAC1C,aAAY,CAAC;EAGf,MAAM,YAAY,QAAQ;AAC1B,MAAI,MAAM,QAAQ,SAAS,aAAa,KACtC,QAAO;GAAE;GAAI;GAAO,MAAM;GAAW;GAAa;AAEpD,SAAO;GACP,CAEwB,OAAO,QAAQ"}
|
|
@@ -11,13 +11,13 @@ const getUserRating = (el) => {
|
|
|
11
11
|
};
|
|
12
12
|
const getUserRatingType = (el) => {
|
|
13
13
|
const typeText = el.querySelectorAll("td.name .film-title-info .info");
|
|
14
|
-
return typeText.length > 1 ? typeText[1].text
|
|
14
|
+
return typeText.length > 1 ? typeText[1].text : "film";
|
|
15
15
|
};
|
|
16
16
|
const getUserRatingTitle = (el) => {
|
|
17
17
|
return el.querySelector("td.name .film-title-name").text;
|
|
18
18
|
};
|
|
19
19
|
const getUserRatingYear = (el) => {
|
|
20
|
-
return +el.querySelectorAll("td.name .film-title-info .info")[0]?.text
|
|
20
|
+
return +el.querySelectorAll("td.name .film-title-info .info")[0]?.text || null;
|
|
21
21
|
};
|
|
22
22
|
const getUserRatingColorRating = (el) => {
|
|
23
23
|
return require_global_helper.parseColor(el.querySelector("td.name .icon").classNames.split(" ").pop());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-ratings.helper.js","names":["parseIdFromUrl","parseColor"],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text
|
|
1
|
+
{"version":3,"file":"user-ratings.helper.js","names":["parseIdFromUrl","parseColor"],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('td.name .film-title-info .info')[0]?.text || null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n const color = parseColor(\n el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n );\n return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n return el.querySelector('td.date-only').text.trim();\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,2BAA2B,CAAC,WAAW;AACpE,QAAOA,qCAAe,IAAI;;AAG5B,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,6BAA6B,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAG7F,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,iBAAiB,iCAAiC;AAEtE,QAAQ,SAAS,SAAS,IAAI,SAAS,GAAG,OAAO;;AAGnD,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,2BAA2B,CAAC;;AAGtD,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,CAAC,GAAG,iBAAiB,iCAAiC,CAAC,IAAI,QAAQ;;AAG5E,MAAa,4BAA4B,OAAqC;AAI5E,QAHcC,iCACZ,GAAG,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CAC9D;;AAIH,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,eAAe,CAAC,KAAK,MAAM;;AAGrD,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,2BAA2B,CAAC,WAAW"}
|
|
@@ -11,13 +11,13 @@ const getUserRating = (el) => {
|
|
|
11
11
|
};
|
|
12
12
|
const getUserRatingType = (el) => {
|
|
13
13
|
const typeText = el.querySelectorAll("td.name .film-title-info .info");
|
|
14
|
-
return typeText.length > 1 ? typeText[1].text
|
|
14
|
+
return typeText.length > 1 ? typeText[1].text : "film";
|
|
15
15
|
};
|
|
16
16
|
const getUserRatingTitle = (el) => {
|
|
17
17
|
return el.querySelector("td.name .film-title-name").text;
|
|
18
18
|
};
|
|
19
19
|
const getUserRatingYear = (el) => {
|
|
20
|
-
return +el.querySelectorAll("td.name .film-title-info .info")[0]?.text
|
|
20
|
+
return +el.querySelectorAll("td.name .film-title-info .info")[0]?.text || null;
|
|
21
21
|
};
|
|
22
22
|
const getUserRatingColorRating = (el) => {
|
|
23
23
|
return parseColor(el.querySelector("td.name .icon").classNames.split(" ").pop());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-ratings.helper.mjs","names":[],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text
|
|
1
|
+
{"version":3,"file":"user-ratings.helper.mjs","names":[],"sources":["../../src/helpers/user-ratings.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserRatingId = (el: HTMLElement): number => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserRatingType = (el: HTMLElement): CSFDFilmTypes => {\n const typeText = el.querySelectorAll('td.name .film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserRatingTitle = (el: HTMLElement): string => {\n return el.querySelector('td.name .film-title-name').text;\n};\n\nexport const getUserRatingYear = (el: HTMLElement): number => {\n return +el.querySelectorAll('td.name .film-title-info .info')[0]?.text || null;\n};\n\nexport const getUserRatingColorRating = (el: HTMLElement): CSFDColorRating => {\n const color = parseColor(\n el.querySelector('td.name .icon').classNames.split(' ').pop() as CSFDColors\n );\n return color;\n};\n\nexport const getUserRatingDate = (el: HTMLElement): string => {\n return el.querySelector('td.date-only').text.trim();\n};\n\nexport const getUserRatingUrl = (el: HTMLElement): string => {\n const url = el.querySelector('td.name .film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,2BAA2B,CAAC,WAAW;AACpE,QAAO,eAAe,IAAI;;AAG5B,MAAa,iBAAiB,OAA+B;CAC3D,MAAM,aAAa,GAAG,cAAc,6BAA6B,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAG7F,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,iBAAiB,iCAAiC;AAEtE,QAAQ,SAAS,SAAS,IAAI,SAAS,GAAG,OAAO;;AAGnD,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,2BAA2B,CAAC;;AAGtD,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,CAAC,GAAG,iBAAiB,iCAAiC,CAAC,IAAI,QAAQ;;AAG5E,MAAa,4BAA4B,OAAqC;AAI5E,QAHc,WACZ,GAAG,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,CAC9D;;AAIH,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,eAAe,CAAC,KAAK,MAAM;;AAGrD,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,2BAA2B,CAAC,WAAW"}
|
|
@@ -21,16 +21,16 @@ const getUserReviewYear = (el) => {
|
|
|
21
21
|
return infoSpan ? +infoSpan.text.replace(/[()]/g, "") : null;
|
|
22
22
|
};
|
|
23
23
|
const getUserReviewColorRating = (el) => {
|
|
24
|
-
return require_global_helper.parseColor(el.querySelector(".film-title-
|
|
24
|
+
return require_global_helper.parseColor(el.querySelector(".film-title-inline i.icon")?.classNames.split(" ").pop());
|
|
25
25
|
};
|
|
26
26
|
const getUserReviewDate = (el) => {
|
|
27
|
-
return el.querySelector(".header-
|
|
27
|
+
return el.querySelector(".article-header-date-content .info time").text.trim();
|
|
28
28
|
};
|
|
29
29
|
const getUserReviewUrl = (el) => {
|
|
30
30
|
return `https://www.csfd.cz${el.querySelector(".film-title-name").attributes.href}`;
|
|
31
31
|
};
|
|
32
32
|
const getUserReviewText = (el) => {
|
|
33
|
-
return el.querySelector(".
|
|
33
|
+
return el.querySelector(".comment").text.trim();
|
|
34
34
|
};
|
|
35
35
|
const getUserReviewPoster = (el) => {
|
|
36
36
|
const img = el.querySelector(".article-img img");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-reviews.helper.js","names":["parseIdFromUrl","parseColor"],"sources":["../../src/helpers/user-reviews.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserReviewId = (el: HTMLElement): number => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserReviewRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('.star-rating .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserReviewType = (el: HTMLElement): CSFDFilmTypes => {\n // Type can be in the second .info span (e.g., \"(seriál)\") // TODO need more tests\n const typeText = el.querySelectorAll('.film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') : null;\n};\n\nexport const getUserReviewColorRating = (el: HTMLElement): CSFDColorRating => {\n const icon = el.querySelector('.film-title-
|
|
1
|
+
{"version":3,"file":"user-reviews.helper.js","names":["parseIdFromUrl","parseColor"],"sources":["../../src/helpers/user-reviews.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserReviewId = (el: HTMLElement): number => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserReviewRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('.star-rating .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserReviewType = (el: HTMLElement): CSFDFilmTypes => {\n // Type can be in the second .info span (e.g., \"(seriál)\") // TODO need more tests\n const typeText = el.querySelectorAll('.film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') : null;\n};\n\nexport const getUserReviewColorRating = (el: HTMLElement): CSFDColorRating => {\n const icon = el.querySelector('.film-title-inline i.icon');\n const color = parseColor(icon?.classNames.split(' ').pop() as CSFDColors);\n return color;\n};\n\nexport const getUserReviewDate = (el: HTMLElement): string => {\n return el.querySelector('.article-header-date-content .info time').text.trim();\n};\n\nexport const getUserReviewUrl = (el: HTMLElement): string => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n\nexport const getUserReviewText = (el: HTMLElement): string => {\n return el.querySelector('.comment').text.trim();\n};\n\nexport const getUserReviewPoster = (el: HTMLElement): string => {\n const img = el.querySelector('.article-img img');\n const srcset = img?.attributes.srcset;\n\n if (srcset) {\n // Extract 3x version from srcset (e.g., \"url 1x, url 2x, url 3x\")\n const srcsetParts = srcset.split(',').map((s) => s.trim());\n const poster3x = srcsetParts.find((s) => s.endsWith('3x'));\n if (poster3x) {\n const url = poster3x.replace(/\\s+3x$/, '').trim();\n return `https:${url}`;\n }\n }\n\n // Fallback to src if srcset not available\n const src = img?.attributes.src;\n return src ? `https:${src}` : null;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,mBAAmB,CAAC,WAAW;AAC5D,QAAOA,qCAAe,IAAI;;AAG5B,MAAa,uBAAuB,OAA+B;CACjE,MAAM,aAAa,GAAG,cAAc,sBAAsB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAGtF,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GA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
-
return parseColor(el.querySelector(".film-title-
|
|
24
|
+
return parseColor(el.querySelector(".film-title-inline i.icon")?.classNames.split(" ").pop());
|
|
25
25
|
};
|
|
26
26
|
const getUserReviewDate = (el) => {
|
|
27
|
-
return el.querySelector(".header-
|
|
27
|
+
return el.querySelector(".article-header-date-content .info time").text.trim();
|
|
28
28
|
};
|
|
29
29
|
const getUserReviewUrl = (el) => {
|
|
30
30
|
return `https://www.csfd.cz${el.querySelector(".film-title-name").attributes.href}`;
|
|
31
31
|
};
|
|
32
32
|
const getUserReviewText = (el) => {
|
|
33
|
-
return el.querySelector(".
|
|
33
|
+
return el.querySelector(".comment").text.trim();
|
|
34
34
|
};
|
|
35
35
|
const getUserReviewPoster = (el) => {
|
|
36
36
|
const img = el.querySelector(".article-img img");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-reviews.helper.mjs","names":[],"sources":["../../src/helpers/user-reviews.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserReviewId = (el: HTMLElement): number => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserReviewRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('.star-rating .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserReviewType = (el: HTMLElement): CSFDFilmTypes => {\n // Type can be in the second .info span (e.g., \"(seriál)\") // TODO need more tests\n const typeText = el.querySelectorAll('.film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') : null;\n};\n\nexport const getUserReviewColorRating = (el: HTMLElement): CSFDColorRating => {\n const icon = el.querySelector('.film-title-
|
|
1
|
+
{"version":3,"file":"user-reviews.helper.mjs","names":[],"sources":["../../src/helpers/user-reviews.helper.ts"],"sourcesContent":["import { HTMLElement } from 'node-html-parser';\nimport { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';\nimport { CSFDColors } from '../dto/user-ratings';\nimport { parseColor, parseIdFromUrl } from './global.helper';\n\nexport const getUserReviewId = (el: HTMLElement): number => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return parseIdFromUrl(url);\n};\n\nexport const getUserReviewRating = (el: HTMLElement): CSFDStars => {\n const ratingText = el.querySelector('.star-rating .stars').classNames.split(' ').pop();\n\n const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;\n return rating as CSFDStars;\n};\n\nexport const getUserReviewType = (el: HTMLElement): CSFDFilmTypes => {\n // Type can be in the second .info span (e.g., \"(seriál)\") // TODO need more tests\n const typeText = el.querySelectorAll('.film-title-info .info');\n\n return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film') as CSFDFilmTypes;\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') : null;\n};\n\nexport const getUserReviewColorRating = (el: HTMLElement): CSFDColorRating => {\n const icon = el.querySelector('.film-title-inline i.icon');\n const color = parseColor(icon?.classNames.split(' ').pop() as CSFDColors);\n return color;\n};\n\nexport const getUserReviewDate = (el: HTMLElement): string => {\n return el.querySelector('.article-header-date-content .info time').text.trim();\n};\n\nexport const getUserReviewUrl = (el: HTMLElement): string => {\n const url = el.querySelector('.film-title-name').attributes.href;\n return `https://www.csfd.cz${url}`;\n};\n\nexport const getUserReviewText = (el: HTMLElement): string => {\n return el.querySelector('.comment').text.trim();\n};\n\nexport const getUserReviewPoster = (el: HTMLElement): string => {\n const img = el.querySelector('.article-img img');\n const srcset = img?.attributes.srcset;\n\n if (srcset) {\n // Extract 3x version from srcset (e.g., \"url 1x, url 2x, url 3x\")\n const srcsetParts = srcset.split(',').map((s) => s.trim());\n const poster3x = srcsetParts.find((s) => s.endsWith('3x'));\n if (poster3x) {\n const url = poster3x.replace(/\\s+3x$/, '').trim();\n return `https:${url}`;\n }\n }\n\n // Fallback to src if srcset not available\n const src = img?.attributes.src;\n return src ? `https:${src}` : null;\n};\n"],"mappings":";;;AAKA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,MAAM,GAAG,cAAc,mBAAmB,CAAC,WAAW;AAC5D,QAAO,eAAe,IAAI;;AAG5B,MAAa,uBAAuB,OAA+B;CACjE,MAAM,aAAa,GAAG,cAAc,sBAAsB,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK;AAGtF,QADe,WAAW,SAAS,SAAS,GAAG,CAAC,WAAW,MAAM,IAAI,CAAC,KAAK,GAAG;;AAIhF,MAAa,qBAAqB,OAAmC;CAEnE,MAAM,WAAW,GAAG,iBAAiB,yBAAyB;AAE9D,QAAQ,SAAS,SAAS,IAAI,SAAS,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG;;AAGhE,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,qBAAqB,OAA4B;CAC5D,MAAM,WAAW,GAAG,cAAc,yBAAyB;AAC3D,QAAO,WAAW,CAAC,SAAS,KAAK,QAAQ,SAAS,GAAG,GAAG;;AAG1D,MAAa,4BAA4B,OAAqC;AAG5E,QADc,WADD,GAAG,cAAc,4BAA4B,EAC3B,WAAW,MAAM,IAAI,CAAC,KAAK,CAAe;;AAI3E,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,0CAA0C,CAAC,KAAK,MAAM;;AAGhF,MAAa,oBAAoB,OAA4B;AAE3D,QAAO,sBADK,GAAG,cAAc,mBAAmB,CAAC,WAAW;;AAI9D,MAAa,qBAAqB,OAA4B;AAC5D,QAAO,GAAG,cAAc,WAAW,CAAC,KAAK,MAAM;;AAGjD,MAAa,uBAAuB,OAA4B;CAC9D,MAAM,MAAM,GAAG,cAAc,mBAAmB;CAChD,MAAM,SAAS,KAAK,WAAW;AAE/B,KAAI,QAAQ;EAGV,MAAM,WADc,OAAO,MAAM,IAAI,CAAC,KAAK,MAAM,EAAE,MAAM,CAAC,CAC7B,MAAM,MAAM,EAAE,SAAS,KAAK,CAAC;AAC1D,MAAI,SAEF,QAAO,SADK,SAAS,QAAQ,UAAU,GAAG,CAAC,MAAM;;CAMrD,MAAM,MAAM,KAAK,WAAW;AAC5B,QAAO,MAAM,SAAS,QAAQ"}
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_cinema_service = require('./services/cinema.service.js');
|
|
2
3
|
const require_creator_service = require('./services/creator.service.js');
|
|
3
4
|
const require_movie_service = require('./services/movie.service.js');
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["MovieScraper","UserRatingsScraper","UserReviewsScraper","CinemaScraper","CreatorScraper","SearchScraper"],"sources":["../src/index.ts"],"sourcesContent":["import { CSFDCinema, CSFDCinemaPeriod } from './dto/cinema';\nimport { CSFDCreator } from './dto/creator';\nimport { CSFDMovie } from './dto/movie';\nimport { CSFDSearch } from './dto/search';\nimport { CSFDUserRatingConfig, CSFDUserRatings } from './dto/user-ratings';\nimport { CSFDUserReviews, CSFDUserReviewsConfig } from './dto/user-reviews';\nimport { CinemaScraper } from './services/cinema.service';\nimport { CreatorScraper } from './services/creator.service';\nimport { MovieScraper } from './services/movie.service';\nimport { SearchScraper } from './services/search.service';\nimport { UserRatingsScraper } from './services/user-ratings.service';\nimport { UserReviewsScraper } from './services/user-reviews.service';\nimport { CSFDOptions } from './types';\n\nexport class Csfd {\n private defaultOptions?: CSFDOptions;\n\n constructor(\n private userRatingsService: UserRatingsScraper,\n private userReviewsService: UserReviewsScraper,\n private movieService: MovieScraper,\n private creatorService: CreatorScraper,\n private searchService: SearchScraper,\n private cinemaService: CinemaScraper,\n defaultOptions?: CSFDOptions\n ) {\n this.defaultOptions = defaultOptions;\n }\n\n public setOptions({ request, language }: CSFDOptions): void {\n if (request !== undefined) {\n this.defaultOptions = { ...this.defaultOptions, request };\n }\n if (language !== undefined) {\n this.defaultOptions = { ...this.defaultOptions, language };\n }\n }\n\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserRatings[]> {\n const opts = options ?? this.defaultOptions;\n return this.userRatingsService.userRatings(user, config, opts);\n }\n\n public async userReviews(\n user: string | number,\n config?: CSFDUserReviewsConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserReviews[]> {\n const opts = options ?? this.defaultOptions;\n return this.userReviewsService.userReviews(user, config, opts);\n }\n\n public async movie(movie: number, options?: CSFDOptions): Promise<CSFDMovie> {\n const opts = options ?? this.defaultOptions;\n return this.movieService.movie(+movie, opts);\n }\n\n public async creator(creator: number, options?: CSFDOptions): Promise<CSFDCreator> {\n const opts = options ?? this.defaultOptions;\n return this.creatorService.creator(+creator, opts);\n }\n\n public async search(text: string, options?: CSFDOptions): Promise<CSFDSearch> {\n const opts = options ?? this.defaultOptions;\n return this.searchService.search(text, opts);\n }\n\n public async cinema(\n district: number | string,\n period: CSFDCinemaPeriod,\n options?: CSFDOptions\n ): Promise<CSFDCinema[]> {\n const opts = options ?? this.defaultOptions;\n return this.cinemaService.cinemas(+district, period, opts);\n }\n}\n\nconst movieScraper = new MovieScraper();\nconst userRatingsScraper = new UserRatingsScraper();\nconst userReviewsScraper = new UserReviewsScraper();\nconst cinemaScraper = new CinemaScraper();\nconst creatorScraper = new CreatorScraper();\nconst searchScraper = new SearchScraper();\n\nexport const csfd = new Csfd(\n userRatingsScraper,\n userReviewsScraper,\n movieScraper,\n creatorScraper,\n searchScraper,\n cinemaScraper\n);\n\nexport type * from './dto';\n\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["MovieScraper","UserRatingsScraper","UserReviewsScraper","CinemaScraper","CreatorScraper","SearchScraper"],"sources":["../src/index.ts"],"sourcesContent":["import { CSFDCinema, CSFDCinemaPeriod } from './dto/cinema';\nimport { CSFDCreator } from './dto/creator';\nimport { CSFDMovie } from './dto/movie';\nimport { CSFDSearch } from './dto/search';\nimport { CSFDUserRatingConfig, CSFDUserRatings } from './dto/user-ratings';\nimport { CSFDUserReviews, CSFDUserReviewsConfig } from './dto/user-reviews';\nimport { CinemaScraper } from './services/cinema.service';\nimport { CreatorScraper } from './services/creator.service';\nimport { MovieScraper } from './services/movie.service';\nimport { SearchScraper } from './services/search.service';\nimport { UserRatingsScraper } from './services/user-ratings.service';\nimport { UserReviewsScraper } from './services/user-reviews.service';\nimport { CSFDOptions } from './types';\n\nexport class Csfd {\n private defaultOptions?: CSFDOptions;\n\n constructor(\n private userRatingsService: UserRatingsScraper,\n private userReviewsService: UserReviewsScraper,\n private movieService: MovieScraper,\n private creatorService: CreatorScraper,\n private searchService: SearchScraper,\n private cinemaService: CinemaScraper,\n defaultOptions?: CSFDOptions\n ) {\n this.defaultOptions = defaultOptions;\n }\n\n public setOptions({ request, language }: CSFDOptions): void {\n if (request !== undefined) {\n this.defaultOptions = { ...this.defaultOptions, request };\n }\n if (language !== undefined) {\n this.defaultOptions = { ...this.defaultOptions, language };\n }\n }\n\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserRatings[]> {\n const opts = options ?? this.defaultOptions;\n return this.userRatingsService.userRatings(user, config, opts);\n }\n\n public async userReviews(\n user: string | number,\n config?: CSFDUserReviewsConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserReviews[]> {\n const opts = options ?? this.defaultOptions;\n return this.userReviewsService.userReviews(user, config, opts);\n }\n\n public async movie(movie: number, options?: CSFDOptions): Promise<CSFDMovie> {\n const opts = options ?? this.defaultOptions;\n return this.movieService.movie(+movie, opts);\n }\n\n public async creator(creator: number, options?: CSFDOptions): Promise<CSFDCreator> {\n const opts = options ?? this.defaultOptions;\n return this.creatorService.creator(+creator, opts);\n }\n\n public async search(text: string, options?: CSFDOptions): Promise<CSFDSearch> {\n const opts = options ?? this.defaultOptions;\n return this.searchService.search(text, opts);\n }\n\n public async cinema(\n district: number | string,\n period: CSFDCinemaPeriod,\n options?: CSFDOptions\n ): Promise<CSFDCinema[]> {\n const opts = options ?? this.defaultOptions;\n return this.cinemaService.cinemas(+district, period, opts);\n }\n}\n\nconst movieScraper = new MovieScraper();\nconst userRatingsScraper = new UserRatingsScraper();\nconst userReviewsScraper = new UserReviewsScraper();\nconst cinemaScraper = new CinemaScraper();\nconst creatorScraper = new CreatorScraper();\nconst searchScraper = new SearchScraper();\n\nexport const csfd = new Csfd(\n userRatingsScraper,\n userReviewsScraper,\n movieScraper,\n creatorScraper,\n searchScraper,\n cinemaScraper\n);\n\nexport type * from './dto';\n\n"],"mappings":";;;;;;;;;AAcA,IAAa,OAAb,MAAkB;CAGhB,YACE,AAAQ,oBACR,AAAQ,oBACR,AAAQ,cACR,AAAQ,gBACR,AAAQ,eACR,AAAQ,eACR,gBACA;EAPQ;EACA;EACA;EACA;EACA;EACA;AAGR,OAAK,iBAAiB;;CAGxB,AAAO,WAAW,EAAE,SAAS,YAA+B;AAC1D,MAAI,YAAY,OACd,MAAK,iBAAiB;GAAE,GAAG,KAAK;GAAgB;GAAS;AAE3D,MAAI,aAAa,OACf,MAAK,iBAAiB;GAAE,GAAG,KAAK;GAAgB;GAAU;;CAI9D,MAAa,YACX,MACA,QACA,SAC4B;EAC5B,MAAM,OAAO,WAAW,KAAK;AAC7B,SAAO,KAAK,mBAAmB,YAAY,MAAM,QAAQ,KAAK;;CAGhE,MAAa,YACX,MACA,QACA,SAC4B;EAC5B,MAAM,OAAO,WAAW,KAAK;AAC7B,SAAO,KAAK,mBAAmB,YAAY,MAAM,QAAQ,KAAK;;CAGhE,MAAa,MAAM,OAAe,SAA2C;EAC3E,MAAM,OAAO,WAAW,KAAK;AAC7B,SAAO,KAAK,aAAa,MAAM,CAAC,OAAO,KAAK;;CAG9C,MAAa,QAAQ,SAAiB,SAA6C;EACjF,MAAM,OAAO,WAAW,KAAK;AAC7B,SAAO,KAAK,eAAe,QAAQ,CAAC,SAAS,KAAK;;CAGpD,MAAa,OAAO,MAAc,SAA4C;EAC5E,MAAM,OAAO,WAAW,KAAK;AAC7B,SAAO,KAAK,cAAc,OAAO,MAAM,KAAK;;CAG9C,MAAa,OACX,UACA,QACA,SACuB;EACvB,MAAM,OAAO,WAAW,KAAK;AAC7B,SAAO,KAAK,cAAc,QAAQ,CAAC,UAAU,QAAQ,KAAK;;;AAI9D,MAAM,eAAe,IAAIA,oCAAc;AACvC,MAAM,qBAAqB,IAAIC,iDAAoB;AACnD,MAAM,qBAAqB,IAAIC,iDAAoB;AACnD,MAAM,gBAAgB,IAAIC,sCAAe;AACzC,MAAM,iBAAiB,IAAIC,wCAAgB;AAC3C,MAAM,gBAAgB,IAAIC,sCAAe;AAEzC,MAAa,OAAO,IAAI,KACtB,oBACA,oBACA,cACA,gBACA,eACA,cACD"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ var UserRatingsScraper = class {
|
|
|
11
11
|
const pageToFetch = config?.page || 1;
|
|
12
12
|
const url = require_vars.userRatingsUrl(user, pageToFetch > 1 ? pageToFetch : void 0, { language: options?.language });
|
|
13
13
|
const items = (0, node_html_parser.parse)(await require_index.fetchPage(url, { ...options?.request }));
|
|
14
|
-
const movies = items.querySelectorAll("
|
|
14
|
+
const movies = items.querySelectorAll("#snippet--ratings table tr");
|
|
15
15
|
const pagesNode = items.querySelector(".pagination");
|
|
16
16
|
const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;
|
|
17
17
|
allMovies = this.getPage(config, movies);
|
|
@@ -20,7 +20,7 @@ var UserRatingsScraper = class {
|
|
|
20
20
|
console.log("Fetching all pages", pages);
|
|
21
21
|
for (let i = 2; i <= pages; i++) {
|
|
22
22
|
console.log("Fetching page", i, "out of", pages, "...");
|
|
23
|
-
const movies = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.userRatingsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll("
|
|
23
|
+
const movies = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.userRatingsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll("#snippet--ratings table tr");
|
|
24
24
|
allMovies = [...allMovies, ...this.getPage(config, movies)];
|
|
25
25
|
if (config.allPagesDelay) await require_global_helper.sleep(config.allPagesDelay);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-ratings.service.js","names":["userRatingsUrl","fetchPage","sleep","getUserRatingType","getUserRatingId","getUserRatingTitle","getUserRatingYear","getUserRatingUrl","getUserRatingColorRating","getUserRatingDate","getUserRating"],"sources":["../../src/services/user-ratings.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserRatingConfig, CSFDUserRatings } from '../dto/user-ratings';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear\n} from '../helpers/user-ratings.helper';\nimport { CSFDOptions } from '../types';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserRatings[]> {\n let allMovies: CSFDUserRatings[] = [];\n const pageToFetch = config?.page || 1;\n const url = userRatingsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {
|
|
1
|
+
{"version":3,"file":"user-ratings.service.js","names":["userRatingsUrl","fetchPage","sleep","getUserRatingType","getUserRatingId","getUserRatingTitle","getUserRatingYear","getUserRatingUrl","getUserRatingColorRating","getUserRatingDate","getUserRating"],"sources":["../../src/services/user-ratings.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserRatingConfig, CSFDUserRatings } from '../dto/user-ratings';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear\n} from '../helpers/user-ratings.helper';\nimport { CSFDOptions } from '../types';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserRatings[]> {\n let allMovies: CSFDUserRatings[] = [];\n const pageToFetch = config?.page || 1;\n const url = userRatingsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {\n language: options?.language\n });\n const response = await fetchPage(url, { ...options?.request });\n const items = parse(response);\n const movies = items.querySelectorAll('#snippet--ratings table tr');\n\n // Get number of pages\n const pagesNode = items.querySelector('.pagination');\n const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;\n\n allMovies = this.getPage(config, movies);\n\n if (config?.allPages) {\n console.log('User', user, url);\n console.log('Fetching all pages', pages);\n for (let i = 2; i <= pages; i++) {\n console.log('Fetching page', i, 'out of', pages, '...');\n const url = userRatingsUrl(user, i, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n\n const items = parse(response);\n const movies = items.querySelectorAll('#snippet--ratings table tr');\n allMovies = [...allMovies, ...this.getPage(config, movies)];\n\n // Sleep\n if (config.allPagesDelay) {\n await sleep(config.allPagesDelay);\n }\n }\n return allMovies;\n }\n\n return allMovies;\n }\n\n private getPage(config: CSFDUserRatingConfig, movies: HTMLElement[]) {\n const films: CSFDUserRatings[] = [];\n if (config) {\n if (config.includesOnly?.length && config.excludes?.length) {\n console.warn(\n `node-csfd-api:\n You can not use both parameters 'includesOnly' and 'excludes'.\n Parameter 'includesOnly' will be used now:`,\n config.includesOnly\n );\n }\n }\n\n for (const el of movies) {\n const type = getUserRatingType(el);\n\n // Filtering includesOnly\n if (config?.includesOnly?.length) {\n if (config.includesOnly.some((include) => type === include)) {\n films.push(this.buildUserRatings(el));\n }\n // Filter excludes\n } else if (config?.excludes?.length) {\n if (!config.excludes.some((exclude) => type === exclude)) {\n films.push(this.buildUserRatings(el));\n }\n } else {\n // Without filtering\n films.push(this.buildUserRatings(el));\n }\n }\n return films;\n }\n\n private buildUserRatings(el: HTMLElement): CSFDUserRatings {\n return {\n id: getUserRatingId(el),\n title: getUserRatingTitle(el),\n year: getUserRatingYear(el),\n type: getUserRatingType(el),\n url: getUserRatingUrl(el),\n colorRating: getUserRatingColorRating(el) as CSFDColorRating,\n userDate: getUserRatingDate(el),\n userRating: getUserRating(el) as CSFDStars\n };\n }\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,qBAAb,MAAgC;CAC9B,MAAa,YACX,MACA,QACA,SAC4B;EAC5B,IAAI,YAA+B,EAAE;EACrC,MAAM,cAAc,QAAQ,QAAQ;EACpC,MAAM,MAAMA,4BAAe,MAAM,cAAc,IAAI,cAAc,QAAW,EAC1E,UAAU,SAAS,UACpB,CAAC;EAEF,MAAM,oCADW,MAAMC,wBAAU,KAAK,EAAE,GAAG,SAAS,SAAS,CAAC,CACjC;EAC7B,MAAM,SAAS,MAAM,iBAAiB,6BAA6B;EAGnE,MAAM,YAAY,MAAM,cAAc,cAAc;EACpD,MAAM,QAAQ,CAAC,WAAW,WAAW,UA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GAAG;GAC3B,KAAKI,6CAAiB,GAAG;GACzB,aAAaC,qDAAyB,GAAG;GACzC,UAAUC,8CAAkB,GAAG;GAC/B,YAAYC,0CAAc,GAAG;GAC9B"}
|
|
@@ -11,7 +11,7 @@ var UserRatingsScraper = class {
|
|
|
11
11
|
const pageToFetch = config?.page || 1;
|
|
12
12
|
const url = userRatingsUrl(user, pageToFetch > 1 ? pageToFetch : void 0, { language: options?.language });
|
|
13
13
|
const items = parse(await fetchPage(url, { ...options?.request }));
|
|
14
|
-
const movies = items.querySelectorAll("
|
|
14
|
+
const movies = items.querySelectorAll("#snippet--ratings table tr");
|
|
15
15
|
const pagesNode = items.querySelector(".pagination");
|
|
16
16
|
const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;
|
|
17
17
|
allMovies = this.getPage(config, movies);
|
|
@@ -20,7 +20,7 @@ var UserRatingsScraper = class {
|
|
|
20
20
|
console.log("Fetching all pages", pages);
|
|
21
21
|
for (let i = 2; i <= pages; i++) {
|
|
22
22
|
console.log("Fetching page", i, "out of", pages, "...");
|
|
23
|
-
const movies = parse(await fetchPage(userRatingsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll("
|
|
23
|
+
const movies = parse(await fetchPage(userRatingsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll("#snippet--ratings table tr");
|
|
24
24
|
allMovies = [...allMovies, ...this.getPage(config, movies)];
|
|
25
25
|
if (config.allPagesDelay) await sleep(config.allPagesDelay);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-ratings.service.mjs","names":[],"sources":["../../src/services/user-ratings.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserRatingConfig, CSFDUserRatings } from '../dto/user-ratings';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear\n} from '../helpers/user-ratings.helper';\nimport { CSFDOptions } from '../types';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserRatings[]> {\n let allMovies: CSFDUserRatings[] = [];\n const pageToFetch = config?.page || 1;\n const url = userRatingsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {
|
|
1
|
+
{"version":3,"file":"user-ratings.service.mjs","names":[],"sources":["../../src/services/user-ratings.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserRatingConfig, CSFDUserRatings } from '../dto/user-ratings';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear\n} from '../helpers/user-ratings.helper';\nimport { CSFDOptions } from '../types';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserRatings[]> {\n let allMovies: CSFDUserRatings[] = [];\n const pageToFetch = config?.page || 1;\n const url = userRatingsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {\n language: options?.language\n });\n const response = await fetchPage(url, { ...options?.request });\n const items = parse(response);\n const movies = items.querySelectorAll('#snippet--ratings table tr');\n\n // Get number of pages\n const pagesNode = items.querySelector('.pagination');\n const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;\n\n allMovies = this.getPage(config, movies);\n\n if (config?.allPages) {\n console.log('User', user, url);\n console.log('Fetching all pages', pages);\n for (let i = 2; i <= pages; i++) {\n console.log('Fetching page', i, 'out of', pages, '...');\n const url = userRatingsUrl(user, i, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n\n const items = parse(response);\n const movies = items.querySelectorAll('#snippet--ratings table tr');\n allMovies = [...allMovies, ...this.getPage(config, movies)];\n\n // Sleep\n if (config.allPagesDelay) {\n await sleep(config.allPagesDelay);\n }\n }\n return allMovies;\n }\n\n return allMovies;\n }\n\n private getPage(config: CSFDUserRatingConfig, movies: HTMLElement[]) {\n const films: CSFDUserRatings[] = [];\n if (config) {\n if (config.includesOnly?.length && config.excludes?.length) {\n console.warn(\n `node-csfd-api:\n You can not use both parameters 'includesOnly' and 'excludes'.\n Parameter 'includesOnly' will be used now:`,\n config.includesOnly\n );\n }\n }\n\n for (const el of movies) {\n const type = getUserRatingType(el);\n\n // Filtering includesOnly\n if (config?.includesOnly?.length) {\n if (config.includesOnly.some((include) => type === include)) {\n films.push(this.buildUserRatings(el));\n }\n // Filter excludes\n } else if (config?.excludes?.length) {\n if (!config.excludes.some((exclude) => type === exclude)) {\n films.push(this.buildUserRatings(el));\n }\n } else {\n // Without filtering\n films.push(this.buildUserRatings(el));\n }\n }\n return films;\n }\n\n private buildUserRatings(el: HTMLElement): CSFDUserRatings {\n return {\n id: getUserRatingId(el),\n title: getUserRatingTitle(el),\n year: getUserRatingYear(el),\n type: getUserRatingType(el),\n url: getUserRatingUrl(el),\n colorRating: getUserRatingColorRating(el) as CSFDColorRating,\n userDate: getUserRatingDate(el),\n userRating: getUserRating(el) as CSFDStars\n };\n }\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,qBAAb,MAAgC;CAC9B,MAAa,YACX,MACA,QACA,SAC4B;EAC5B,IAAI,YAA+B,EAAE;EACrC,MAAM,cAAc,QAAQ,QAAQ;EACpC,MAAM,MAAM,eAAe,MAAM,cAAc,IAAI,cAAc,QAAW,EAC1E,UAAU,SAAS,UACpB,CAAC;EAEF,MAAM,QAAQ,MADG,MAAM,UAAU,KAAK,EAAE,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CAGT,AAAQ,iBAAiB,IAAkC;AACzD,SAAO;GACL,IAAI,gBAAgB,GAAG;GACvB,OAAO,mBAAmB,GAAG;GAC7B,MAAM,kBAAkB,GAAG;GAC3B,MAAM,kBAAkB,GAAG;GAC3B,KAAK,iBAAiB,GAAG;GACzB,aAAa,yBAAyB,GAAG;GACzC,UAAU,kBAAkB,GAAG;GAC/B,YAAY,cAAc,GAAG;GAC9B"}
|
|
@@ -11,7 +11,7 @@ var UserReviewsScraper = class {
|
|
|
11
11
|
const pageToFetch = config?.page || 1;
|
|
12
12
|
const url = require_vars.userReviewsUrl(user, pageToFetch > 1 ? pageToFetch : void 0, { language: options?.language });
|
|
13
13
|
const items = (0, node_html_parser.parse)(await require_index.fetchPage(url, { ...options?.request }));
|
|
14
|
-
const reviews = items.querySelectorAll(".user-reviews .article");
|
|
14
|
+
const reviews = items.querySelectorAll(".user-tab-reviews .article");
|
|
15
15
|
const pagesNode = items.querySelector(".pagination");
|
|
16
16
|
const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;
|
|
17
17
|
allReviews = this.getPage(config, reviews);
|
|
@@ -20,7 +20,7 @@ var UserReviewsScraper = class {
|
|
|
20
20
|
console.log("Fetching all pages", pages);
|
|
21
21
|
for (let i = 2; i <= pages; i++) {
|
|
22
22
|
console.log("Fetching page", i, "out of", pages, "...");
|
|
23
|
-
const reviews = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.userReviewsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll(".user-reviews .article");
|
|
23
|
+
const reviews = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.userReviewsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll(".user-tab-reviews .article");
|
|
24
24
|
allReviews = [...allReviews, ...this.getPage(config, reviews)];
|
|
25
25
|
if (config.allPagesDelay) await require_global_helper.sleep(config.allPagesDelay);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-reviews.service.js","names":["userReviewsUrl","fetchPage","sleep","getUserReviewType","getUserReviewId","getUserReviewTitle","getUserReviewYear","getUserReviewUrl","getUserReviewColorRating","getUserReviewDate","getUserReviewRating","getUserReviewText","getUserReviewPoster"],"sources":["../../src/services/user-reviews.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserReviews, CSFDUserReviewsConfig } from '../dto/user-reviews';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserReviewColorRating,\n getUserReviewDate,\n getUserReviewId,\n getUserReviewPoster,\n getUserReviewRating,\n getUserReviewText,\n getUserReviewTitle,\n getUserReviewType,\n getUserReviewUrl,\n getUserReviewYear\n} from '../helpers/user-reviews.helper';\nimport { CSFDOptions } from '../types';\nimport { userReviewsUrl } from '../vars';\n\nexport class UserReviewsScraper {\n public async userReviews(\n user: string | number,\n config?: CSFDUserReviewsConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserReviews[]> {\n let allReviews: CSFDUserReviews[] = [];\n const pageToFetch = config?.page || 1;\n const url = userReviewsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {
|
|
1
|
+
{"version":3,"file":"user-reviews.service.js","names":["userReviewsUrl","fetchPage","sleep","getUserReviewType","getUserReviewId","getUserReviewTitle","getUserReviewYear","getUserReviewUrl","getUserReviewColorRating","getUserReviewDate","getUserReviewRating","getUserReviewText","getUserReviewPoster"],"sources":["../../src/services/user-reviews.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserReviews, CSFDUserReviewsConfig } from '../dto/user-reviews';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserReviewColorRating,\n getUserReviewDate,\n getUserReviewId,\n getUserReviewPoster,\n getUserReviewRating,\n getUserReviewText,\n getUserReviewTitle,\n getUserReviewType,\n getUserReviewUrl,\n getUserReviewYear\n} from '../helpers/user-reviews.helper';\nimport { CSFDOptions } from '../types';\nimport { userReviewsUrl } from '../vars';\n\nexport class UserReviewsScraper {\n public async userReviews(\n user: string | number,\n config?: CSFDUserReviewsConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserReviews[]> {\n let allReviews: CSFDUserReviews[] = [];\n const pageToFetch = config?.page || 1;\n const url = userReviewsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {\n language: options?.language\n });\n const response = await fetchPage(url, { ...options?.request });\n const items = parse(response);\n const reviews = items.querySelectorAll('.user-tab-reviews .article');\n\n // Get number of pages\n const pagesNode = items.querySelector('.pagination');\n const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;\n\n allReviews = this.getPage(config, reviews);\n\n if (config?.allPages) {\n console.log('User', user, url);\n console.log('Fetching all pages', pages);\n for (let i = 2; i <= pages; i++) {\n console.log('Fetching page', i, 'out of', pages, '...');\n const url = userReviewsUrl(user, i, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n\n const items = parse(response);\n const reviews = items.querySelectorAll('.user-tab-reviews .article');\n allReviews = [...allReviews, ...this.getPage(config, reviews)];\n\n // Sleep\n if (config.allPagesDelay) {\n await sleep(config.allPagesDelay);\n }\n }\n return allReviews;\n }\n\n return allReviews;\n }\n\n private getPage(config: CSFDUserReviewsConfig, reviews: HTMLElement[]) {\n const films: CSFDUserReviews[] = [];\n if (config) {\n if (config.includesOnly?.length && config.excludes?.length) {\n console.warn(\n `node-csfd-api:\n You can not use both parameters 'includesOnly' and 'excludes'.\n Parameter 'includesOnly' will be used now:`,\n config.includesOnly\n );\n }\n }\n\n for (const el of reviews) {\n const type = getUserReviewType(el);\n\n // Filtering includesOnly\n if (config?.includesOnly?.length) {\n if (config.includesOnly.some((include) => type === include)) {\n films.push(this.buildUserReviews(el));\n }\n // Filter excludes\n } else if (config?.excludes?.length) {\n if (!config.excludes.some((exclude) => type === exclude)) {\n films.push(this.buildUserReviews(el));\n }\n } else {\n // Without filtering\n films.push(this.buildUserReviews(el));\n }\n }\n return films;\n }\n\n private buildUserReviews(el: HTMLElement): CSFDUserReviews {\n return {\n id: getUserReviewId(el),\n title: getUserReviewTitle(el),\n year: getUserReviewYear(el),\n type: getUserReviewType(el),\n url: getUserReviewUrl(el),\n colorRating: getUserReviewColorRating(el) as CSFDColorRating,\n userDate: getUserReviewDate(el),\n userRating: getUserReviewRating(el) as CSFDStars,\n text: getUserReviewText(el),\n poster: getUserReviewPoster(el)\n };\n }\n}\n"],"mappings":";;;;;;;AAoBA,IAAa,qBAAb,MAAgC;CAC9B,MAAa,YACX,MACA,QACA,SAC4B;EAC5B,IAAI,aAAgC,EAAE;EACtC,MAAM,cAAc,QAAQ,QAAQ;EACpC,MAAM,MAAMA,4BAAe,MAAM,cAAc,IAAI,cAAc,QAAW,EAC1E,UAAU,SAAS,UACpB,CAAC;EAEF,MAAM,oCADW,MAAMC,wBAAU,KAAK,EAAE,GAAG,SAAS,SAAS,CAAC,CACjC;EAC7B,MAAM,UAAU,MAAM,iBAAiB,6BAA6B;EAGpE,MAAM,YAAY,MAAM,cAAc,cAAc;EACpD,MAAM,QAAQ,CAAC,WAAW,WAAW,UAAU,WAAW,SAAS,GAAG,WAAW;AAEjF,eAAa,KAAK,QAAQ,QAAQ,QAAQ;AAE1C,MAAI,QAAQ,UAAU;AACpB,WAAQ,IAAI,QAAQ,MAAM,IAAI;AAC9B,WAAQ,IAAI,sBAAsB,MAAM;AACxC,QAAK,IAAI,IAAI,GAAG,KAAK,OAAO,KAAK;AAC/B,YAAQ,IAAI,iBAAiB,GAAG,UAAU,OAAO,MAAM;IAKvD,MAAM,sCAHW,MAAMA,wBADXD,4BAAe,MAAM,GAAG,EAAE,UAAU,SAAS,UAAU,CAAC,EAC9B,EAAE,GAAG,SAAS,SAAS,CAAC,CAEjC,CACP,iBAAiB,6BAA6B;AACpE,iBAAa,CAAC,GAAG,YAAY,GAAG,KAAK,QAAQ,QAAQ,QAAQ,CAAC;AAG9D,QAAI,OAAO,cACT,OAAME,4BAAM,OAAO,cAAc;;AAGrC,UAAO;;AAGT,SAAO;;CAGT,AAAQ,QAAQ,QAA+B,SAAwB;EACrE,MAAM,QAA2B,EAAE;AACnC,MAAI,QACF;OAAI,OAAO,cAAc,UAAU,OAAO,UAAU,OAClD,SAAQ,KACN;;qDAGA,OAAO,aACR;;AAIL,OAAK,MAAM,MAAM,SAAS;GACxB,MAAM,OAAOC,8CAAkB,GAAG;AAGlC,OAAI,QAAQ,cAAc,QACxB;QAAI,OAAO,aAAa,MAAM,YAAY,SAAS,QAAQ,CACzD,OAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC;cAG9B,QAAQ,UAAU,QAC3B;QAAI,CAAC,OAAO,SAAS,MAAM,YAAY,SAAS,QAAQ,CACtD,OAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC;SAIvC,OAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC;;AAGzC,SAAO;;CAGT,AAAQ,iBAAiB,IAAkC;AACzD,SAAO;GACL,IAAIC,4CAAgB,GAAG;GACvB,OAAOC,+CAAmB,GAAG;GAC7B,MAAMC,8CAAkB,GAAG;GAC3B,MAAMH,8CAAkB,GAAG;GAC3B,KAAKI,6CAAiB,GAAG;GACzB,aAAaC,qDAAyB,GAAG;GACzC,UAAUC,8CAAkB,GAAG;GAC/B,YAAYC,gDAAoB,GAAG;GACnC,MAAMC,8CAAkB,GAAG;GAC3B,QAAQC,gDAAoB,GAAG;GAChC"}
|
|
@@ -11,7 +11,7 @@ var UserReviewsScraper = class {
|
|
|
11
11
|
const pageToFetch = config?.page || 1;
|
|
12
12
|
const url = userReviewsUrl(user, pageToFetch > 1 ? pageToFetch : void 0, { language: options?.language });
|
|
13
13
|
const items = parse(await fetchPage(url, { ...options?.request }));
|
|
14
|
-
const reviews = items.querySelectorAll(".user-reviews .article");
|
|
14
|
+
const reviews = items.querySelectorAll(".user-tab-reviews .article");
|
|
15
15
|
const pagesNode = items.querySelector(".pagination");
|
|
16
16
|
const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;
|
|
17
17
|
allReviews = this.getPage(config, reviews);
|
|
@@ -20,7 +20,7 @@ var UserReviewsScraper = class {
|
|
|
20
20
|
console.log("Fetching all pages", pages);
|
|
21
21
|
for (let i = 2; i <= pages; i++) {
|
|
22
22
|
console.log("Fetching page", i, "out of", pages, "...");
|
|
23
|
-
const reviews = parse(await fetchPage(userReviewsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll(".user-reviews .article");
|
|
23
|
+
const reviews = parse(await fetchPage(userReviewsUrl(user, i, { language: options?.language }), { ...options?.request })).querySelectorAll(".user-tab-reviews .article");
|
|
24
24
|
allReviews = [...allReviews, ...this.getPage(config, reviews)];
|
|
25
25
|
if (config.allPagesDelay) await sleep(config.allPagesDelay);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-reviews.service.mjs","names":[],"sources":["../../src/services/user-reviews.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserReviews, CSFDUserReviewsConfig } from '../dto/user-reviews';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserReviewColorRating,\n getUserReviewDate,\n getUserReviewId,\n getUserReviewPoster,\n getUserReviewRating,\n getUserReviewText,\n getUserReviewTitle,\n getUserReviewType,\n getUserReviewUrl,\n getUserReviewYear\n} from '../helpers/user-reviews.helper';\nimport { CSFDOptions } from '../types';\nimport { userReviewsUrl } from '../vars';\n\nexport class UserReviewsScraper {\n public async userReviews(\n user: string | number,\n config?: CSFDUserReviewsConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserReviews[]> {\n let allReviews: CSFDUserReviews[] = [];\n const pageToFetch = config?.page || 1;\n const url = userReviewsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {
|
|
1
|
+
{"version":3,"file":"user-reviews.service.mjs","names":[],"sources":["../../src/services/user-reviews.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDColorRating, CSFDStars } from '../dto/global';\nimport { CSFDUserReviews, CSFDUserReviewsConfig } from '../dto/user-reviews';\nimport { fetchPage } from '../fetchers';\nimport { sleep } from '../helpers/global.helper';\nimport {\n getUserReviewColorRating,\n getUserReviewDate,\n getUserReviewId,\n getUserReviewPoster,\n getUserReviewRating,\n getUserReviewText,\n getUserReviewTitle,\n getUserReviewType,\n getUserReviewUrl,\n getUserReviewYear\n} from '../helpers/user-reviews.helper';\nimport { CSFDOptions } from '../types';\nimport { userReviewsUrl } from '../vars';\n\nexport class UserReviewsScraper {\n public async userReviews(\n user: string | number,\n config?: CSFDUserReviewsConfig,\n options?: CSFDOptions\n ): Promise<CSFDUserReviews[]> {\n let allReviews: CSFDUserReviews[] = [];\n const pageToFetch = config?.page || 1;\n const url = userReviewsUrl(user, pageToFetch > 1 ? pageToFetch : undefined, {\n language: options?.language\n });\n const response = await fetchPage(url, { ...options?.request });\n const items = parse(response);\n const reviews = items.querySelectorAll('.user-tab-reviews .article');\n\n // Get number of pages\n const pagesNode = items.querySelector('.pagination');\n const pages = +pagesNode?.childNodes[pagesNode.childNodes.length - 4].rawText || 1;\n\n allReviews = this.getPage(config, reviews);\n\n if (config?.allPages) {\n console.log('User', user, url);\n console.log('Fetching all pages', pages);\n for (let i = 2; i <= pages; i++) {\n console.log('Fetching page', i, 'out of', pages, '...');\n const url = userReviewsUrl(user, i, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n\n const items = parse(response);\n const reviews = items.querySelectorAll('.user-tab-reviews .article');\n allReviews = [...allReviews, ...this.getPage(config, reviews)];\n\n // Sleep\n if (config.allPagesDelay) {\n await sleep(config.allPagesDelay);\n }\n }\n return allReviews;\n }\n\n return allReviews;\n }\n\n private getPage(config: CSFDUserReviewsConfig, reviews: HTMLElement[]) {\n const films: CSFDUserReviews[] = [];\n if (config) {\n if (config.includesOnly?.length && config.excludes?.length) {\n console.warn(\n `node-csfd-api:\n You can not use both parameters 'includesOnly' and 'excludes'.\n Parameter 'includesOnly' will be used now:`,\n config.includesOnly\n );\n }\n }\n\n for (const el of reviews) {\n const type = getUserReviewType(el);\n\n // Filtering includesOnly\n if (config?.includesOnly?.length) {\n if (config.includesOnly.some((include) => type === include)) {\n films.push(this.buildUserReviews(el));\n }\n // Filter excludes\n } else if (config?.excludes?.length) {\n if (!config.excludes.some((exclude) => type === exclude)) {\n films.push(this.buildUserReviews(el));\n }\n } else {\n // Without filtering\n films.push(this.buildUserReviews(el));\n }\n }\n return films;\n }\n\n private buildUserReviews(el: HTMLElement): CSFDUserReviews {\n return {\n id: getUserReviewId(el),\n title: getUserReviewTitle(el),\n year: getUserReviewYear(el),\n type: getUserReviewType(el),\n url: getUserReviewUrl(el),\n colorRating: getUserReviewColorRating(el) as CSFDColorRating,\n userDate: getUserReviewDate(el),\n userRating: getUserReviewRating(el) as CSFDStars,\n text: getUserReviewText(el),\n poster: getUserReviewPoster(el)\n };\n }\n}\n"],"mappings":";;;;;;;AAoBA,IAAa,qBAAb,MAAgC;CAC9B,MAAa,YACX,MACA,QACA,SAC4B;EAC5B,IAAI,aAAgC,EAAE;EACtC,MAAM,cAAc,QAAQ,QAAQ;EACpC,MAAM,MAAM,eAAe,MAAM,cAAc,IAAI,cAAc,QAAW,EAC1E,UAAU,SAAS,UACpB,CAAC;EAEF,MAAM,QAAQ,MADG,MAAM,UAAU,KAAK,EAAE,GAAG,SAAS,SAAS,CAAC,CACjC;EAC7B,MAAM,UAAU,MAAM,iBAAiB,6BAA6B;EAGpE,MAAM,YAAY,MAAM,cAAc,cAAc;EACpD,MAAM,QAAQ,CAAC,WAAW,WAAW,UAAU,WAAW,SAAS,GAAG,WAAW;AAEjF,eAAa,KAAK,QAAQ,QAAQ,QAAQ;AAE1C,MAAI,QAAQ,UAAU;AACpB,WAAQ,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