node-csfd-api 5.3.0 → 5.5.0-next.0
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/bin/{export-ratings.mjs → export-ratings.js} +1 -1
- package/bin/{mcp-server.mjs → mcp-server.js} +2 -2
- package/bin/{server.mjs → server.js} +2 -2
- package/{cli.mjs → cli.js} +3 -3
- package/dto/{cinema.d.mts → cinema.d.cts} +2 -2
- package/dto/{creator.d.mts → creator.d.cts} +2 -2
- package/dto/{global.d.mts → global.d.cts} +1 -1
- package/dto/{movie.d.mts → movie.d.cts} +2 -2
- package/dto/{options.d.mts → options.d.cts} +1 -1
- package/dto/{search.d.mts → search.d.cts} +3 -3
- package/dto/{user-ratings.d.mts → user-ratings.d.cts} +2 -2
- package/dto/{user-reviews.d.mts → user-reviews.d.cts} +2 -2
- package/fetchers/{fetch.polyfill.mjs → fetch.polyfill.cjs} +3 -4
- package/fetchers/fetch.polyfill.cjs.map +1 -0
- package/fetchers/fetch.polyfill.js +2 -3
- package/fetchers/fetch.polyfill.js.map +1 -1
- package/fetchers/index.cjs +75 -0
- package/fetchers/index.cjs.map +1 -0
- package/fetchers/index.js +56 -12
- package/fetchers/index.js.map +1 -1
- package/helpers/cinema.helper.cjs +83 -0
- package/helpers/cinema.helper.cjs.map +1 -0
- package/helpers/cinema.helper.js +4 -8
- package/helpers/cinema.helper.js.map +1 -1
- package/helpers/creator.helper.cjs +72 -0
- package/helpers/creator.helper.cjs.map +1 -0
- package/helpers/creator.helper.js +6 -10
- package/helpers/creator.helper.js.map +1 -1
- package/helpers/global.helper.cjs +109 -0
- package/helpers/{global.helper.mjs.map → global.helper.cjs.map} +1 -1
- package/helpers/global.helper.js +1 -9
- package/helpers/movie.helper.cjs +324 -0
- package/helpers/movie.helper.cjs.map +1 -0
- package/helpers/movie.helper.js +12 -35
- package/helpers/movie.helper.js.map +1 -1
- package/helpers/search-creator.helper.cjs +18 -0
- package/helpers/search-creator.helper.cjs.map +1 -0
- package/helpers/search-creator.helper.js +3 -5
- package/helpers/search-creator.helper.js.map +1 -1
- package/helpers/search-user.helper.cjs +26 -0
- package/helpers/search-user.helper.cjs.map +1 -0
- package/helpers/search-user.helper.js +5 -8
- package/helpers/search-user.helper.js.map +1 -1
- package/helpers/search.helper.cjs +52 -0
- package/helpers/search.helper.cjs.map +1 -0
- package/helpers/search.helper.js +6 -13
- package/helpers/search.helper.js.map +1 -1
- package/helpers/user-ratings.helper.cjs +41 -0
- package/helpers/user-ratings.helper.cjs.map +1 -0
- package/helpers/user-ratings.helper.js +6 -13
- package/helpers/user-ratings.helper.js.map +1 -1
- package/helpers/user-reviews.helper.cjs +56 -0
- package/helpers/user-reviews.helper.cjs.map +1 -0
- package/helpers/user-reviews.helper.js +6 -15
- package/helpers/user-reviews.helper.js.map +1 -1
- package/index.cjs +64 -0
- package/index.cjs.map +1 -0
- package/{index.d.mts → index.d.cts} +15 -15
- package/index.js +13 -14
- package/index.js.map +1 -1
- package/{package.mjs → package.js} +1 -1
- package/package.json +13 -7
- package/services/cinema.service.cjs +31 -0
- package/services/cinema.service.cjs.map +1 -0
- package/services/{cinema.service.d.mts → cinema.service.d.cts} +3 -3
- package/services/cinema.service.js +11 -11
- package/services/cinema.service.js.map +1 -1
- package/services/creator.service.cjs +32 -0
- package/services/creator.service.cjs.map +1 -0
- package/services/{creator.service.d.mts → creator.service.d.cts} +3 -3
- package/services/creator.service.js +11 -11
- package/services/creator.service.js.map +1 -1
- package/services/movie.service.cjs +61 -0
- package/services/movie.service.cjs.map +1 -0
- package/services/{movie.service.d.mts → movie.service.d.cts} +3 -3
- package/services/movie.service.js +33 -33
- package/services/movie.service.js.map +1 -1
- package/services/search.service.cjs +75 -0
- package/services/search.service.cjs.map +1 -0
- package/services/{search.service.d.mts → search.service.d.cts} +3 -3
- package/services/search.service.js +29 -29
- package/services/search.service.js.map +1 -1
- package/services/user-ratings.service.cjs +65 -0
- package/services/user-ratings.service.cjs.map +1 -0
- package/services/{user-ratings.service.d.mts → user-ratings.service.d.cts} +3 -3
- package/services/user-ratings.service.js +18 -18
- package/services/user-ratings.service.js.map +1 -1
- package/services/user-reviews.service.cjs +67 -0
- package/services/user-reviews.service.cjs.map +1 -0
- package/services/{user-reviews.service.d.mts → user-reviews.service.d.cts} +3 -3
- package/services/user-reviews.service.js +20 -20
- package/services/user-reviews.service.js.map +1 -1
- package/src/fetchers/fetch.polyfill.js +6 -0
- package/src/fetchers/index.js +76 -0
- package/{helpers/cinema.helper.mjs → src/helpers/cinema.helper.js} +5 -4
- package/{helpers/creator.helper.mjs → src/helpers/creator.helper.js} +5 -4
- package/{helpers/global.helper.mjs → src/helpers/global.helper.js} +3 -3
- package/{helpers/movie.helper.mjs → src/helpers/movie.helper.js} +5 -4
- package/{helpers/search-creator.helper.mjs → src/helpers/search-creator.helper.js} +5 -4
- package/{helpers/search-user.helper.mjs → src/helpers/search-user.helper.js} +5 -4
- package/{helpers/search.helper.mjs → src/helpers/search.helper.js} +5 -4
- package/{helpers/user-ratings.helper.mjs → src/helpers/user-ratings.helper.js} +5 -4
- package/{helpers/user-reviews.helper.mjs → src/helpers/user-reviews.helper.js} +5 -4
- package/{index.mjs → src/index.js} +14 -10
- package/{services/cinema.service.mjs → src/services/cinema.service.js} +7 -6
- package/{services/creator.service.mjs → src/services/creator.service.js} +7 -6
- package/{services/movie.service.mjs → src/services/movie.service.js} +7 -6
- package/{services/search.service.mjs → src/services/search.service.js} +10 -9
- package/{services/user-ratings.service.mjs → src/services/user-ratings.service.js} +8 -7
- package/{services/user-reviews.service.mjs → src/services/user-reviews.service.js} +8 -7
- package/{vars.mjs → src/vars.js} +3 -3
- package/vars.cjs +28 -0
- package/{vars.mjs.map → vars.cjs.map} +1 -1
- package/vars.js +1 -7
- package/fetchers/fetch.polyfill.mjs.map +0 -1
- package/fetchers/index.mjs +0 -31
- package/fetchers/index.mjs.map +0 -1
- package/helpers/cinema.helper.mjs.map +0 -1
- package/helpers/creator.helper.mjs.map +0 -1
- package/helpers/movie.helper.mjs.map +0 -1
- package/helpers/search-creator.helper.mjs.map +0 -1
- package/helpers/search-user.helper.mjs.map +0 -1
- package/helpers/search.helper.mjs.map +0 -1
- package/helpers/user-ratings.helper.mjs.map +0 -1
- package/helpers/user-reviews.helper.mjs.map +0 -1
- package/index.mjs.map +0 -1
- package/services/cinema.service.mjs.map +0 -1
- package/services/creator.service.mjs.map +0 -1
- package/services/movie.service.mjs.map +0 -1
- package/services/search.service.mjs.map +0 -1
- package/services/user-ratings.service.mjs.map +0 -1
- package/services/user-reviews.service.mjs.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const require_global_helper = require("./global.helper.cjs");
|
|
2
|
+
//#region src/helpers/user-reviews.helper.ts
|
|
3
|
+
const getUserReviewId = (el) => {
|
|
4
|
+
const url = el.querySelector(".film-title-name").attributes.href;
|
|
5
|
+
return require_global_helper.parseIdFromUrl(url);
|
|
6
|
+
};
|
|
7
|
+
const getUserReviewRating = (el) => {
|
|
8
|
+
const ratingText = el.querySelector(".star-rating .stars").classNames.split(" ").pop();
|
|
9
|
+
return ratingText.includes("stars-") ? +ratingText.split("-").pop() : 0;
|
|
10
|
+
};
|
|
11
|
+
const getUserReviewType = (el) => {
|
|
12
|
+
const typeNode = el.querySelector(".film-title-info .info ~ .info");
|
|
13
|
+
return require_global_helper.parseFilmType(typeNode ? typeNode.text.slice(1, -1) : "film");
|
|
14
|
+
};
|
|
15
|
+
const getUserReviewTitle = (el) => {
|
|
16
|
+
return el.querySelector(".film-title-name").text;
|
|
17
|
+
};
|
|
18
|
+
const getUserReviewYear = (el) => {
|
|
19
|
+
const infoSpan = el.querySelector(".film-title-info .info");
|
|
20
|
+
return infoSpan ? +infoSpan.text.replace(/[()]/g, "") || null : null;
|
|
21
|
+
};
|
|
22
|
+
const getUserReviewColorRating = (el) => {
|
|
23
|
+
return require_global_helper.parseColor(el.querySelector(".film-title-inline i.icon")?.classNames.split(" ").pop());
|
|
24
|
+
};
|
|
25
|
+
const getUserReviewDate = (el) => {
|
|
26
|
+
return require_global_helper.parseDate(el.querySelector(".article-header-date-content .info time").text.trim());
|
|
27
|
+
};
|
|
28
|
+
const getUserReviewUrl = (el) => {
|
|
29
|
+
return `https://www.csfd.cz${el.querySelector(".film-title-name").attributes.href}`;
|
|
30
|
+
};
|
|
31
|
+
const getUserReviewText = (el) => {
|
|
32
|
+
return el.querySelector(".comment").text.trim();
|
|
33
|
+
};
|
|
34
|
+
const getUserReviewPoster = (el) => {
|
|
35
|
+
const img = el.querySelector(".article-img img");
|
|
36
|
+
const srcset = img?.attributes.srcset;
|
|
37
|
+
if (srcset) {
|
|
38
|
+
const poster3x = srcset.split(",").map((s) => s.trim()).find((s) => s.endsWith("3x"));
|
|
39
|
+
if (poster3x) return `https:${poster3x.replace(/\s+3x$/, "").trim()}`;
|
|
40
|
+
}
|
|
41
|
+
const src = img?.attributes.src;
|
|
42
|
+
return src ? `https:${src}` : null;
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.getUserReviewColorRating = getUserReviewColorRating;
|
|
46
|
+
exports.getUserReviewDate = getUserReviewDate;
|
|
47
|
+
exports.getUserReviewId = getUserReviewId;
|
|
48
|
+
exports.getUserReviewPoster = getUserReviewPoster;
|
|
49
|
+
exports.getUserReviewRating = getUserReviewRating;
|
|
50
|
+
exports.getUserReviewText = getUserReviewText;
|
|
51
|
+
exports.getUserReviewTitle = getUserReviewTitle;
|
|
52
|
+
exports.getUserReviewType = getUserReviewType;
|
|
53
|
+
exports.getUserReviewUrl = getUserReviewUrl;
|
|
54
|
+
exports.getUserReviewYear = getUserReviewYear;
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=user-reviews.helper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-reviews.helper.cjs","names":["parseIdFromUrl","parseFilmType","parseColor","parseDate"],"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, parseDate, parseFilmType, 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 typeNode = el.querySelector('.film-title-info .info ~ .info');\n return parseFilmType(typeNode ? typeNode.text.slice(1, -1) : 'film');\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number | null => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') || null : 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 | null => {\n const dateRaw = el.querySelector('.article-header-date-content .info time').text.trim();\n return parseDate(dateRaw);\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,sBAAAA,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,cAAc,iCAAiC;AACnE,QAAOC,sBAAAA,cAAc,WAAW,SAAS,KAAK,MAAM,GAAG,GAAG,GAAG,OAAO;;AAGtE,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,cAAc,yBAAyB;AAC3D,QAAO,WAAW,CAAC,SAAS,KAAK,QAAQ,SAAS,GAAG,IAAI,OAAO;;AAGlE,MAAa,4BAA4B,OAAqC;AAG5E,QADcC,sBAAAA,WADD,GAAG,cAAc,4BAA4B,EAC3B,WAAW,MAAM,IAAI,CAAC,KAAK,CAAe;;AAI3E,MAAa,qBAAqB,OAAmC;AAEnE,QAAOC,sBAAAA,UADS,GAAG,cAAc,0CAA0C,CAAC,KAAK,MAAM,CAC9D;;AAG3B,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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { parseColor, parseDate, parseFilmType, parseIdFromUrl } from "./global.helper.js";
|
|
2
2
|
//#region src/helpers/user-reviews.helper.ts
|
|
3
3
|
const getUserReviewId = (el) => {
|
|
4
4
|
const url = el.querySelector(".film-title-name").attributes.href;
|
|
5
|
-
return
|
|
5
|
+
return parseIdFromUrl(url);
|
|
6
6
|
};
|
|
7
7
|
const getUserReviewRating = (el) => {
|
|
8
8
|
const ratingText = el.querySelector(".star-rating .stars").classNames.split(" ").pop();
|
|
@@ -10,7 +10,7 @@ const getUserReviewRating = (el) => {
|
|
|
10
10
|
};
|
|
11
11
|
const getUserReviewType = (el) => {
|
|
12
12
|
const typeNode = el.querySelector(".film-title-info .info ~ .info");
|
|
13
|
-
return
|
|
13
|
+
return parseFilmType(typeNode ? typeNode.text.slice(1, -1) : "film");
|
|
14
14
|
};
|
|
15
15
|
const getUserReviewTitle = (el) => {
|
|
16
16
|
return el.querySelector(".film-title-name").text;
|
|
@@ -20,10 +20,10 @@ const getUserReviewYear = (el) => {
|
|
|
20
20
|
return infoSpan ? +infoSpan.text.replace(/[()]/g, "") || null : null;
|
|
21
21
|
};
|
|
22
22
|
const getUserReviewColorRating = (el) => {
|
|
23
|
-
return
|
|
23
|
+
return parseColor(el.querySelector(".film-title-inline i.icon")?.classNames.split(" ").pop());
|
|
24
24
|
};
|
|
25
25
|
const getUserReviewDate = (el) => {
|
|
26
|
-
return
|
|
26
|
+
return parseDate(el.querySelector(".article-header-date-content .info time").text.trim());
|
|
27
27
|
};
|
|
28
28
|
const getUserReviewUrl = (el) => {
|
|
29
29
|
return `https://www.csfd.cz${el.querySelector(".film-title-name").attributes.href}`;
|
|
@@ -42,15 +42,6 @@ const getUserReviewPoster = (el) => {
|
|
|
42
42
|
return src ? `https:${src}` : null;
|
|
43
43
|
};
|
|
44
44
|
//#endregion
|
|
45
|
-
|
|
46
|
-
exports.getUserReviewDate = getUserReviewDate;
|
|
47
|
-
exports.getUserReviewId = getUserReviewId;
|
|
48
|
-
exports.getUserReviewPoster = getUserReviewPoster;
|
|
49
|
-
exports.getUserReviewRating = getUserReviewRating;
|
|
50
|
-
exports.getUserReviewText = getUserReviewText;
|
|
51
|
-
exports.getUserReviewTitle = getUserReviewTitle;
|
|
52
|
-
exports.getUserReviewType = getUserReviewType;
|
|
53
|
-
exports.getUserReviewUrl = getUserReviewUrl;
|
|
54
|
-
exports.getUserReviewYear = getUserReviewYear;
|
|
45
|
+
export { getUserReviewColorRating, getUserReviewDate, getUserReviewId, getUserReviewPoster, getUserReviewRating, getUserReviewText, getUserReviewTitle, getUserReviewType, getUserReviewUrl, getUserReviewYear };
|
|
55
46
|
|
|
56
47
|
//# sourceMappingURL=user-reviews.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-reviews.helper.js","names":[
|
|
1
|
+
{"version":3,"file":"user-reviews.helper.js","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, parseDate, parseFilmType, 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 typeNode = el.querySelector('.film-title-info .info ~ .info');\n return parseFilmType(typeNode ? typeNode.text.slice(1, -1) : 'film');\n};\n\nexport const getUserReviewTitle = (el: HTMLElement): string => {\n return el.querySelector('.film-title-name').text;\n};\n\nexport const getUserReviewYear = (el: HTMLElement): number | null => {\n const infoSpan = el.querySelector('.film-title-info .info');\n return infoSpan ? +infoSpan.text.replace(/[()]/g, '') || null : 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 | null => {\n const dateRaw = el.querySelector('.article-header-date-content .info time').text.trim();\n return parseDate(dateRaw);\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,cAAc,iCAAiC;AACnE,QAAO,cAAc,WAAW,SAAS,KAAK,MAAM,GAAG,GAAG,GAAG,OAAO;;AAGtE,MAAa,sBAAsB,OAA4B;AAC7D,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,qBAAqB,OAAmC;CACnE,MAAM,WAAW,GAAG,cAAc,yBAAyB;AAC3D,QAAO,WAAW,CAAC,SAAS,KAAK,QAAQ,SAAS,GAAG,IAAI,OAAO;;AAGlE,MAAa,4BAA4B,OAAqC;AAG5E,QADc,WADD,GAAG,cAAc,4BAA4B,EAC3B,WAAW,MAAM,IAAI,CAAC,KAAK,CAAe;;AAI3E,MAAa,qBAAqB,OAAmC;AAEnE,QAAO,UADS,GAAG,cAAc,0CAA0C,CAAC,KAAK,MAAM,CAC9D;;AAG3B,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.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_cinema_service = require("./services/cinema.service.cjs");
|
|
3
|
+
const require_creator_service = require("./services/creator.service.cjs");
|
|
4
|
+
const require_movie_service = require("./services/movie.service.cjs");
|
|
5
|
+
const require_search_service = require("./services/search.service.cjs");
|
|
6
|
+
const require_user_ratings_service = require("./services/user-ratings.service.cjs");
|
|
7
|
+
const require_user_reviews_service = require("./services/user-reviews.service.cjs");
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
var Csfd = class {
|
|
10
|
+
defaultOptions;
|
|
11
|
+
constructor(userRatingsService, userReviewsService, movieService, creatorService, searchService, cinemaService, defaultOptions) {
|
|
12
|
+
this.userRatingsService = userRatingsService;
|
|
13
|
+
this.userReviewsService = userReviewsService;
|
|
14
|
+
this.movieService = movieService;
|
|
15
|
+
this.creatorService = creatorService;
|
|
16
|
+
this.searchService = searchService;
|
|
17
|
+
this.cinemaService = cinemaService;
|
|
18
|
+
this.defaultOptions = defaultOptions;
|
|
19
|
+
}
|
|
20
|
+
setOptions({ request, language }) {
|
|
21
|
+
if (request !== void 0) this.defaultOptions = {
|
|
22
|
+
...this.defaultOptions,
|
|
23
|
+
request
|
|
24
|
+
};
|
|
25
|
+
if (language !== void 0) this.defaultOptions = {
|
|
26
|
+
...this.defaultOptions,
|
|
27
|
+
language
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async userRatings(user, config, options) {
|
|
31
|
+
const opts = options ?? this.defaultOptions;
|
|
32
|
+
return this.userRatingsService.userRatings(user, config, opts);
|
|
33
|
+
}
|
|
34
|
+
async userReviews(user, config, options) {
|
|
35
|
+
const opts = options ?? this.defaultOptions;
|
|
36
|
+
return this.userReviewsService.userReviews(user, config, opts);
|
|
37
|
+
}
|
|
38
|
+
async movie(movie, options) {
|
|
39
|
+
const opts = options ?? this.defaultOptions;
|
|
40
|
+
return this.movieService.movie(+movie, opts);
|
|
41
|
+
}
|
|
42
|
+
async creator(creator, options) {
|
|
43
|
+
const opts = options ?? this.defaultOptions;
|
|
44
|
+
return this.creatorService.creator(+creator, opts);
|
|
45
|
+
}
|
|
46
|
+
async search(text, options) {
|
|
47
|
+
const opts = options ?? this.defaultOptions;
|
|
48
|
+
return this.searchService.search(text, opts);
|
|
49
|
+
}
|
|
50
|
+
async cinema(district, period, options) {
|
|
51
|
+
const opts = options ?? this.defaultOptions;
|
|
52
|
+
return this.cinemaService.cinemas(+district, period, opts);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const movieScraper = new require_movie_service.MovieScraper();
|
|
56
|
+
const userRatingsScraper = new require_user_ratings_service.UserRatingsScraper();
|
|
57
|
+
const userReviewsScraper = new require_user_reviews_service.UserReviewsScraper();
|
|
58
|
+
const cinemaScraper = new require_cinema_service.CinemaScraper();
|
|
59
|
+
const csfd = new Csfd(userRatingsScraper, userReviewsScraper, movieScraper, new require_creator_service.CreatorScraper(), new require_search_service.SearchScraper(), cinemaScraper);
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.Csfd = Csfd;
|
|
62
|
+
exports.csfd = csfd;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","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;CAChB;CAEA,YACE,oBACA,oBACA,cACA,gBACA,eACA,eACA,gBACA;AAPQ,OAAA,qBAAA;AACA,OAAA,qBAAA;AACA,OAAA,eAAA;AACA,OAAA,iBAAA;AACA,OAAA,gBAAA;AACA,OAAA,gBAAA;AAGR,OAAK,iBAAiB;;CAGxB,WAAkB,EAAE,SAAS,YAA+B;AAC1D,MAAI,YAAY,KAAA,EACd,MAAK,iBAAiB;GAAE,GAAG,KAAK;GAAgB;GAAS;AAE3D,MAAI,aAAa,KAAA,EACf,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,sBAAAA,cAAc;AACvC,MAAM,qBAAqB,IAAIC,6BAAAA,oBAAoB;AACnD,MAAM,qBAAqB,IAAIC,6BAAAA,oBAAoB;AACnD,MAAM,gBAAgB,IAAIC,uBAAAA,eAAe;AAIzC,MAAa,OAAO,IAAI,KACtB,oBACA,oBACA,cANqB,IAAIC,wBAAAA,gBAAgB,EACrB,IAAIC,uBAAAA,eAAe,EAQvC,cACD"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { CSFDColorRating, CSFDFilmTypes, CSFDScreening, CSFDStars } from "./dto/global.
|
|
2
|
-
import { CSFDBoxContent, CSFDCreatorGroups, CSFDCreatorGroupsEnglish, CSFDCreatorGroupsSlovak, CSFDCreators, CSFDGenres, CSFDMovie, CSFDMovieCreator, CSFDMovieListItem, CSFDParent, CSFDPremiere, CSFDSeriesChild, CSFDTitlesOther, CSFDVod, CSFDVodService, MovieJsonLd } from "./dto/movie.
|
|
3
|
-
import { CSFDCinema, CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie, CSFDCinemaPeriod } from "./dto/cinema.
|
|
4
|
-
import { CSFDCreator, CSFDCreatorScreening } from "./dto/creator.
|
|
5
|
-
import { CSFDSearch, CSFDSearchCreator, CSFDSearchCreators, CSFDSearchMovie, CSFDSearchUser } from "./dto/search.
|
|
6
|
-
import { CSFDColors, CSFDUserRatingConfig, CSFDUserRatings } from "./dto/user-ratings.
|
|
7
|
-
import { CSFDUserReviews, CSFDUserReviewsConfig } from "./dto/user-reviews.
|
|
8
|
-
import { CSFDOptions } from "./dto/options.
|
|
9
|
-
import { CinemaScraper } from "./services/cinema.service.
|
|
10
|
-
import { CreatorScraper } from "./services/creator.service.
|
|
11
|
-
import { MovieScraper } from "./services/movie.service.
|
|
12
|
-
import { SearchScraper } from "./services/search.service.
|
|
13
|
-
import { UserRatingsScraper } from "./services/user-ratings.service.
|
|
14
|
-
import { UserReviewsScraper } from "./services/user-reviews.service.
|
|
1
|
+
import { CSFDColorRating, CSFDFilmTypes, CSFDScreening, CSFDStars } from "./dto/global.cjs";
|
|
2
|
+
import { CSFDBoxContent, CSFDCreatorGroups, CSFDCreatorGroupsEnglish, CSFDCreatorGroupsSlovak, CSFDCreators, CSFDGenres, CSFDMovie, CSFDMovieCreator, CSFDMovieListItem, CSFDParent, CSFDPremiere, CSFDSeriesChild, CSFDTitlesOther, CSFDVod, CSFDVodService, MovieJsonLd } from "./dto/movie.cjs";
|
|
3
|
+
import { CSFDCinema, CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie, CSFDCinemaPeriod } from "./dto/cinema.cjs";
|
|
4
|
+
import { CSFDCreator, CSFDCreatorScreening } from "./dto/creator.cjs";
|
|
5
|
+
import { CSFDSearch, CSFDSearchCreator, CSFDSearchCreators, CSFDSearchMovie, CSFDSearchUser } from "./dto/search.cjs";
|
|
6
|
+
import { CSFDColors, CSFDUserRatingConfig, CSFDUserRatings } from "./dto/user-ratings.cjs";
|
|
7
|
+
import { CSFDUserReviews, CSFDUserReviewsConfig } from "./dto/user-reviews.cjs";
|
|
8
|
+
import { CSFDOptions } from "./dto/options.cjs";
|
|
9
|
+
import { CinemaScraper } from "./services/cinema.service.cjs";
|
|
10
|
+
import { CreatorScraper } from "./services/creator.service.cjs";
|
|
11
|
+
import { MovieScraper } from "./services/movie.service.cjs";
|
|
12
|
+
import { SearchScraper } from "./services/search.service.cjs";
|
|
13
|
+
import { UserRatingsScraper } from "./services/user-ratings.service.cjs";
|
|
14
|
+
import { UserReviewsScraper } from "./services/user-reviews.service.cjs";
|
|
15
15
|
|
|
16
16
|
//#region src/index.d.ts
|
|
17
17
|
declare class Csfd {
|
|
@@ -37,4 +37,4 @@ declare class Csfd {
|
|
|
37
37
|
declare const csfd: Csfd;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { CSFDBoxContent, CSFDCinema, CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie, CSFDCinemaPeriod, CSFDColorRating, CSFDColors, CSFDCreator, CSFDCreatorGroups, CSFDCreatorGroupsEnglish, CSFDCreatorGroupsSlovak, CSFDCreatorScreening, CSFDCreators, CSFDFilmTypes, CSFDGenres, CSFDMovie, CSFDMovieCreator, CSFDMovieListItem, CSFDParent, CSFDPremiere, CSFDScreening, CSFDSearch, CSFDSearchCreator, CSFDSearchCreators, CSFDSearchMovie, CSFDSearchUser, CSFDSeriesChild, CSFDStars, CSFDTitlesOther, CSFDUserRatingConfig, CSFDUserRatings, CSFDVod, CSFDVodService, Csfd, MovieJsonLd, csfd };
|
|
40
|
-
//# sourceMappingURL=index.d.
|
|
40
|
+
//# sourceMappingURL=index.d.cts.map
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const require_user_reviews_service = require("./services/user-reviews.service.js");
|
|
1
|
+
import { CinemaScraper } from "./services/cinema.service.js";
|
|
2
|
+
import { CreatorScraper } from "./services/creator.service.js";
|
|
3
|
+
import { MovieScraper } from "./services/movie.service.js";
|
|
4
|
+
import { SearchScraper } from "./services/search.service.js";
|
|
5
|
+
import { UserRatingsScraper } from "./services/user-ratings.service.js";
|
|
6
|
+
import { UserReviewsScraper } from "./services/user-reviews.service.js";
|
|
8
7
|
//#region src/index.ts
|
|
9
8
|
var Csfd = class {
|
|
9
|
+
defaultOptions;
|
|
10
10
|
constructor(userRatingsService, userReviewsService, movieService, creatorService, searchService, cinemaService, defaultOptions) {
|
|
11
11
|
this.userRatingsService = userRatingsService;
|
|
12
12
|
this.userReviewsService = userReviewsService;
|
|
@@ -51,13 +51,12 @@ var Csfd = class {
|
|
|
51
51
|
return this.cinemaService.cinemas(+district, period, opts);
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
const movieScraper = new
|
|
55
|
-
const userRatingsScraper = new
|
|
56
|
-
const userReviewsScraper = new
|
|
57
|
-
const cinemaScraper = new
|
|
58
|
-
const csfd = new Csfd(userRatingsScraper, userReviewsScraper, movieScraper, new
|
|
54
|
+
const movieScraper = new MovieScraper();
|
|
55
|
+
const userRatingsScraper = new UserRatingsScraper();
|
|
56
|
+
const userReviewsScraper = new UserReviewsScraper();
|
|
57
|
+
const cinemaScraper = new CinemaScraper();
|
|
58
|
+
const csfd = new Csfd(userRatingsScraper, userReviewsScraper, movieScraper, new CreatorScraper(), new SearchScraper(), cinemaScraper);
|
|
59
59
|
//#endregion
|
|
60
|
-
|
|
61
|
-
exports.csfd = csfd;
|
|
60
|
+
export { Csfd, csfd };
|
|
62
61
|
|
|
63
62
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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;CAChB;CAEA,YACE,oBACA,oBACA,cACA,gBACA,eACA,eACA,gBACA;AAPQ,OAAA,qBAAA;AACA,OAAA,qBAAA;AACA,OAAA,eAAA;AACA,OAAA,iBAAA;AACA,OAAA,gBAAA;AACA,OAAA,gBAAA;AAGR,OAAK,iBAAiB;;CAGxB,WAAkB,EAAE,SAAS,YAA+B;AAC1D,MAAI,YAAY,KAAA,EACd,MAAK,iBAAiB;GAAE,GAAG,KAAK;GAAgB;GAAS;AAE3D,MAAI,aAAa,KAAA,EACf,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,IAAI,cAAc;AACvC,MAAM,qBAAqB,IAAI,oBAAoB;AACnD,MAAM,qBAAqB,IAAI,oBAAoB;AACnD,MAAM,gBAAgB,IAAI,eAAe;AAIzC,MAAa,OAAO,IAAI,KACtB,oBACA,oBACA,cANqB,IAAI,gBAAgB,EACrB,IAAI,eAAe,EAQvC,cACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0-next.0",
|
|
4
4
|
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
|
|
5
5
|
"author": "BART! <bart@bartweb.cz>",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
12
|
-
"cross-fetch": "^4.1.0",
|
|
13
12
|
"dotenv": "^17.3.1",
|
|
14
13
|
"express": "^5.2.1",
|
|
15
14
|
"node-html-parser": "^7.1.0",
|
|
@@ -40,16 +39,23 @@
|
|
|
40
39
|
"node": ">= 18"
|
|
41
40
|
},
|
|
42
41
|
"license": "MIT",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
42
|
+
"type": "module",
|
|
43
|
+
"main": "./index.cjs",
|
|
44
|
+
"module": "./index.js",
|
|
45
45
|
"types": "./index.d.ts",
|
|
46
46
|
"exports": {
|
|
47
47
|
".": {
|
|
48
|
-
"import":
|
|
49
|
-
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./index.d.ts",
|
|
50
|
+
"default": "./index.js"
|
|
51
|
+
},
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./index.d.cts",
|
|
54
|
+
"default": "./index.cjs"
|
|
55
|
+
}
|
|
50
56
|
},
|
|
51
57
|
"./package.json": "./package.json"
|
|
52
58
|
},
|
|
53
|
-
"bin": "cli.
|
|
59
|
+
"bin": "cli.js",
|
|
54
60
|
"sideEffects": false
|
|
55
61
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_index = require("../fetchers/index.cjs");
|
|
2
|
+
const require_vars = require("../vars.cjs");
|
|
3
|
+
const require_cinema_helper = require("../helpers/cinema.helper.cjs");
|
|
4
|
+
let node_html_parser = require("node-html-parser");
|
|
5
|
+
//#region src/services/cinema.service.ts
|
|
6
|
+
var CinemaScraper = class {
|
|
7
|
+
async cinemas(district = 1, period = "today", options) {
|
|
8
|
+
const contentNode = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.cinemasUrl(district, period, { language: options?.language }), { ...options?.request })).querySelectorAll("#snippet--cinemas section[id*=\"cinema-\"]");
|
|
9
|
+
return this.buildCinemas(contentNode);
|
|
10
|
+
}
|
|
11
|
+
buildCinemas(contentNode) {
|
|
12
|
+
const cinemas = [];
|
|
13
|
+
contentNode.forEach((x) => {
|
|
14
|
+
const cinemaInfo = require_cinema_helper.parseCinema(x);
|
|
15
|
+
const cinema = {
|
|
16
|
+
id: require_cinema_helper.getCinemaId(x),
|
|
17
|
+
name: cinemaInfo?.name,
|
|
18
|
+
city: cinemaInfo?.city,
|
|
19
|
+
url: require_cinema_helper.getCinemaUrl(x),
|
|
20
|
+
coords: require_cinema_helper.getCinemaCoords(x),
|
|
21
|
+
screenings: require_cinema_helper.getGroupedFilmsByDate(x)
|
|
22
|
+
};
|
|
23
|
+
cinemas.push(cinema);
|
|
24
|
+
});
|
|
25
|
+
return cinemas;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.CinemaScraper = CinemaScraper;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=cinema.service.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cinema.service.cjs","names":["fetchPage","cinemasUrl","parseCinema","getCinemaId","getCinemaUrl","getCinemaCoords","getGroupedFilmsByDate"],"sources":["../../src/services/cinema.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDCinema, CSFDCinemaPeriod } from '../dto/cinema';\nimport { fetchPage } from '../fetchers';\nimport { CSFDOptions } from '../types';\nimport { cinemasUrl } from '../vars';\nimport {\n getCinemaCoords,\n getCinemaId,\n getCinemaUrl,\n getGroupedFilmsByDate,\n parseCinema\n} from './../helpers/cinema.helper';\n\nexport class CinemaScraper {\n public async cinemas(\n district: number = 1,\n period: CSFDCinemaPeriod = 'today',\n options?: CSFDOptions\n ): Promise<CSFDCinema[]> {\n const url = cinemasUrl(district, period, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n const cinemasHtml = parse(response);\n\n const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section[id*=\"cinema-\"]');\n\n return this.buildCinemas(contentNode);\n }\n\n private buildCinemas(contentNode: HTMLElement[]): CSFDCinema[] {\n const cinemas: CSFDCinema[] = [];\n\n contentNode.forEach((x) => {\n const cinemaInfo = parseCinema(x);\n const cinema: CSFDCinema = {\n id: getCinemaId(x),\n name: cinemaInfo?.name,\n city: cinemaInfo?.city,\n url: getCinemaUrl(x),\n coords: getCinemaCoords(x),\n screenings: getGroupedFilmsByDate(x)\n };\n cinemas.push(cinema);\n });\n\n return cinemas;\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,gBAAb,MAA2B;CACzB,MAAa,QACX,WAAmB,GACnB,SAA2B,SAC3B,SACuB;EAKvB,MAAM,eAAA,GAAA,iBAAA,OAHW,MAAMA,cAAAA,UADXC,aAAAA,WAAW,UAAU,QAAQ,EAAE,UAAU,SAAS,UAAU,CAAC,EACnC,EAAE,GAAG,SAAS,SAAS,CAAC,CAC3B,CAEH,iBAAiB,6CAA2C;AAE5F,SAAO,KAAK,aAAa,YAAY;;CAGvC,aAAqB,aAA0C;EAC7D,MAAM,UAAwB,EAAE;AAEhC,cAAY,SAAS,MAAM;GACzB,MAAM,aAAaC,sBAAAA,YAAY,EAAE;GACjC,MAAM,SAAqB;IACzB,IAAIC,sBAAAA,YAAY,EAAE;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,KAAKC,sBAAAA,aAAa,EAAE;IACpB,QAAQC,sBAAAA,gBAAgB,EAAE;IAC1B,YAAYC,sBAAAA,sBAAsB,EAAE;IACrC;AACD,WAAQ,KAAK,OAAO;IACpB;AAEF,SAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CSFDCinema, CSFDCinemaPeriod } from "../dto/cinema.
|
|
2
|
-
import { CSFDOptions } from "../dto/options.
|
|
1
|
+
import { CSFDCinema, CSFDCinemaPeriod } from "../dto/cinema.cjs";
|
|
2
|
+
import { CSFDOptions } from "../dto/options.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/services/cinema.service.d.ts
|
|
5
5
|
declare class CinemaScraper {
|
|
@@ -8,4 +8,4 @@ declare class CinemaScraper {
|
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { CinemaScraper };
|
|
11
|
-
//# sourceMappingURL=cinema.service.d.
|
|
11
|
+
//# sourceMappingURL=cinema.service.d.cts.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { fetchPage } from "../fetchers/index.js";
|
|
2
|
+
import { cinemasUrl } from "../vars.js";
|
|
3
|
+
import { getCinemaCoords, getCinemaId, getCinemaUrl, getGroupedFilmsByDate, parseCinema } from "../helpers/cinema.helper.js";
|
|
4
|
+
import { parse } from "node-html-parser";
|
|
5
5
|
//#region src/services/cinema.service.ts
|
|
6
6
|
var CinemaScraper = class {
|
|
7
7
|
async cinemas(district = 1, period = "today", options) {
|
|
8
|
-
const contentNode =
|
|
8
|
+
const contentNode = parse(await fetchPage(cinemasUrl(district, period, { language: options?.language }), { ...options?.request })).querySelectorAll("#snippet--cinemas section[id*=\"cinema-\"]");
|
|
9
9
|
return this.buildCinemas(contentNode);
|
|
10
10
|
}
|
|
11
11
|
buildCinemas(contentNode) {
|
|
12
12
|
const cinemas = [];
|
|
13
13
|
contentNode.forEach((x) => {
|
|
14
|
-
const cinemaInfo =
|
|
14
|
+
const cinemaInfo = parseCinema(x);
|
|
15
15
|
const cinema = {
|
|
16
|
-
id:
|
|
16
|
+
id: getCinemaId(x),
|
|
17
17
|
name: cinemaInfo?.name,
|
|
18
18
|
city: cinemaInfo?.city,
|
|
19
|
-
url:
|
|
20
|
-
coords:
|
|
21
|
-
screenings:
|
|
19
|
+
url: getCinemaUrl(x),
|
|
20
|
+
coords: getCinemaCoords(x),
|
|
21
|
+
screenings: getGroupedFilmsByDate(x)
|
|
22
22
|
};
|
|
23
23
|
cinemas.push(cinema);
|
|
24
24
|
});
|
|
@@ -26,6 +26,6 @@ var CinemaScraper = class {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
|
-
|
|
29
|
+
export { CinemaScraper };
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=cinema.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cinema.service.js","names":[
|
|
1
|
+
{"version":3,"file":"cinema.service.js","names":[],"sources":["../../src/services/cinema.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDCinema, CSFDCinemaPeriod } from '../dto/cinema';\nimport { fetchPage } from '../fetchers';\nimport { CSFDOptions } from '../types';\nimport { cinemasUrl } from '../vars';\nimport {\n getCinemaCoords,\n getCinemaId,\n getCinemaUrl,\n getGroupedFilmsByDate,\n parseCinema\n} from './../helpers/cinema.helper';\n\nexport class CinemaScraper {\n public async cinemas(\n district: number = 1,\n period: CSFDCinemaPeriod = 'today',\n options?: CSFDOptions\n ): Promise<CSFDCinema[]> {\n const url = cinemasUrl(district, period, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n const cinemasHtml = parse(response);\n\n const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section[id*=\"cinema-\"]');\n\n return this.buildCinemas(contentNode);\n }\n\n private buildCinemas(contentNode: HTMLElement[]): CSFDCinema[] {\n const cinemas: CSFDCinema[] = [];\n\n contentNode.forEach((x) => {\n const cinemaInfo = parseCinema(x);\n const cinema: CSFDCinema = {\n id: getCinemaId(x),\n name: cinemaInfo?.name,\n city: cinemaInfo?.city,\n url: getCinemaUrl(x),\n coords: getCinemaCoords(x),\n screenings: getGroupedFilmsByDate(x)\n };\n cinemas.push(cinema);\n });\n\n return cinemas;\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,gBAAb,MAA2B;CACzB,MAAa,QACX,WAAmB,GACnB,SAA2B,SAC3B,SACuB;EAKvB,MAAM,cAFc,MADH,MAAM,UADX,WAAW,UAAU,QAAQ,EAAE,UAAU,SAAS,UAAU,CAAC,EACnC,EAAE,GAAG,SAAS,SAAS,CAAC,CAC3B,CAEH,iBAAiB,6CAA2C;AAE5F,SAAO,KAAK,aAAa,YAAY;;CAGvC,aAAqB,aAA0C;EAC7D,MAAM,UAAwB,EAAE;AAEhC,cAAY,SAAS,MAAM;GACzB,MAAM,aAAa,YAAY,EAAE;GACjC,MAAM,SAAqB;IACzB,IAAI,YAAY,EAAE;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,KAAK,aAAa,EAAE;IACpB,QAAQ,gBAAgB,EAAE;IAC1B,YAAY,sBAAsB,EAAE;IACrC;AACD,WAAQ,KAAK,OAAO;IACpB;AAEF,SAAO"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_index = require("../fetchers/index.cjs");
|
|
2
|
+
const require_vars = require("../vars.cjs");
|
|
3
|
+
const require_creator_helper = require("../helpers/creator.helper.cjs");
|
|
4
|
+
let node_html_parser = require("node-html-parser");
|
|
5
|
+
//#region src/services/creator.service.ts
|
|
6
|
+
var CreatorScraper = class {
|
|
7
|
+
async creator(creatorId, options) {
|
|
8
|
+
const id = Number(creatorId);
|
|
9
|
+
if (isNaN(id)) throw new Error("node-csfd-api: creatorId must be a valid number");
|
|
10
|
+
const creatorHtml = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.creatorUrl(id, { language: options?.language }), { ...options?.request }));
|
|
11
|
+
const asideNode = creatorHtml.querySelector(".creator-about");
|
|
12
|
+
const filmsNode = creatorHtml.querySelector(".creator-filmography");
|
|
13
|
+
return this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
14
|
+
}
|
|
15
|
+
buildCreator(id, asideEl, filmsNode) {
|
|
16
|
+
const birthdayInfo = require_creator_helper.getCreatorBirthdayInfo(asideEl);
|
|
17
|
+
return {
|
|
18
|
+
id,
|
|
19
|
+
name: require_creator_helper.getCreatorName(asideEl),
|
|
20
|
+
birthday: birthdayInfo?.birthday,
|
|
21
|
+
birthplace: birthdayInfo?.birthPlace,
|
|
22
|
+
photo: require_creator_helper.getCreatorPhoto(asideEl),
|
|
23
|
+
age: birthdayInfo?.age || null,
|
|
24
|
+
bio: require_creator_helper.getCreatorBio(asideEl),
|
|
25
|
+
films: require_creator_helper.getCreatorFilms(filmsNode)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.CreatorScraper = CreatorScraper;
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=creator.service.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"creator.service.cjs","names":["fetchPage","creatorUrl","getCreatorBirthdayInfo","getCreatorName","getCreatorPhoto","getCreatorBio","getCreatorFilms"],"sources":["../../src/services/creator.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDCreator } from '../dto/creator';\nimport { fetchPage } from '../fetchers';\nimport {\n getCreatorBio,\n getCreatorBirthdayInfo,\n getCreatorFilms,\n getCreatorName,\n getCreatorPhoto\n} from '../helpers/creator.helper';\nimport { CSFDOptions } from '../types';\nimport { creatorUrl } from '../vars';\n\nexport class CreatorScraper {\n public async creator(creatorId: number, options?: CSFDOptions): Promise<CSFDCreator> {\n const id = Number(creatorId);\n if (isNaN(id)) {\n throw new Error('node-csfd-api: creatorId must be a valid number');\n }\n const url = creatorUrl(id, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n\n const creatorHtml = parse(response);\n\n const asideNode = creatorHtml.querySelector('.creator-about');\n const filmsNode = creatorHtml.querySelector('.creator-filmography');\n return this.buildCreator(+creatorId, asideNode, filmsNode);\n }\n\n private buildCreator(id: number, asideEl: HTMLElement, filmsNode: HTMLElement): CSFDCreator {\n const birthdayInfo = getCreatorBirthdayInfo(asideEl);\n return {\n id,\n name: getCreatorName(asideEl),\n birthday: birthdayInfo?.birthday,\n birthplace: birthdayInfo?.birthPlace,\n photo: getCreatorPhoto(asideEl),\n age: birthdayInfo?.age || null,\n bio: getCreatorBio(asideEl),\n films: getCreatorFilms(filmsNode)\n };\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,iBAAb,MAA4B;CAC1B,MAAa,QAAQ,WAAmB,SAA6C;EACnF,MAAM,KAAK,OAAO,UAAU;AAC5B,MAAI,MAAM,GAAG,CACX,OAAM,IAAI,MAAM,kDAAkD;EAKpE,MAAM,eAAA,GAAA,iBAAA,OAFW,MAAMA,cAAAA,UADXC,aAAAA,WAAW,IAAI,EAAE,UAAU,SAAS,UAAU,CAAC,EACrB,EAAE,GAAG,SAAS,SAAS,CAAC,CAE3B;EAEnC,MAAM,YAAY,YAAY,cAAc,iBAAiB;EAC7D,MAAM,YAAY,YAAY,cAAc,uBAAuB;AACnE,SAAO,KAAK,aAAa,CAAC,WAAW,WAAW,UAAU;;CAG5D,aAAqB,IAAY,SAAsB,WAAqC;EAC1F,MAAM,eAAeC,uBAAAA,uBAAuB,QAAQ;AACpD,SAAO;GACL;GACA,MAAMC,uBAAAA,eAAe,QAAQ;GAC7B,UAAU,cAAc;GACxB,YAAY,cAAc;GAC1B,OAAOC,uBAAAA,gBAAgB,QAAQ;GAC/B,KAAK,cAAc,OAAO;GAC1B,KAAKC,uBAAAA,cAAc,QAAQ;GAC3B,OAAOC,uBAAAA,gBAAgB,UAAU;GAClC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CSFDCreator } from "../dto/creator.
|
|
2
|
-
import { CSFDOptions } from "../dto/options.
|
|
1
|
+
import { CSFDCreator } from "../dto/creator.cjs";
|
|
2
|
+
import { CSFDOptions } from "../dto/options.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/services/creator.service.d.ts
|
|
5
5
|
declare class CreatorScraper {
|
|
@@ -8,4 +8,4 @@ declare class CreatorScraper {
|
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { CreatorScraper };
|
|
11
|
-
//# sourceMappingURL=creator.service.d.
|
|
11
|
+
//# sourceMappingURL=creator.service.d.cts.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { fetchPage } from "../fetchers/index.js";
|
|
2
|
+
import { creatorUrl } from "../vars.js";
|
|
3
|
+
import { getCreatorBio, getCreatorBirthdayInfo, getCreatorFilms, getCreatorName, getCreatorPhoto } from "../helpers/creator.helper.js";
|
|
4
|
+
import { parse } from "node-html-parser";
|
|
5
5
|
//#region src/services/creator.service.ts
|
|
6
6
|
var CreatorScraper = class {
|
|
7
7
|
async creator(creatorId, options) {
|
|
8
8
|
const id = Number(creatorId);
|
|
9
9
|
if (isNaN(id)) throw new Error("node-csfd-api: creatorId must be a valid number");
|
|
10
|
-
const creatorHtml =
|
|
10
|
+
const creatorHtml = parse(await fetchPage(creatorUrl(id, { language: options?.language }), { ...options?.request }));
|
|
11
11
|
const asideNode = creatorHtml.querySelector(".creator-about");
|
|
12
12
|
const filmsNode = creatorHtml.querySelector(".creator-filmography");
|
|
13
13
|
return this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
14
14
|
}
|
|
15
15
|
buildCreator(id, asideEl, filmsNode) {
|
|
16
|
-
const birthdayInfo =
|
|
16
|
+
const birthdayInfo = getCreatorBirthdayInfo(asideEl);
|
|
17
17
|
return {
|
|
18
18
|
id,
|
|
19
|
-
name:
|
|
19
|
+
name: getCreatorName(asideEl),
|
|
20
20
|
birthday: birthdayInfo?.birthday,
|
|
21
21
|
birthplace: birthdayInfo?.birthPlace,
|
|
22
|
-
photo:
|
|
22
|
+
photo: getCreatorPhoto(asideEl),
|
|
23
23
|
age: birthdayInfo?.age || null,
|
|
24
|
-
bio:
|
|
25
|
-
films:
|
|
24
|
+
bio: getCreatorBio(asideEl),
|
|
25
|
+
films: getCreatorFilms(filmsNode)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
|
-
|
|
30
|
+
export { CreatorScraper };
|
|
31
31
|
|
|
32
32
|
//# sourceMappingURL=creator.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.service.js","names":[
|
|
1
|
+
{"version":3,"file":"creator.service.js","names":[],"sources":["../../src/services/creator.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDCreator } from '../dto/creator';\nimport { fetchPage } from '../fetchers';\nimport {\n getCreatorBio,\n getCreatorBirthdayInfo,\n getCreatorFilms,\n getCreatorName,\n getCreatorPhoto\n} from '../helpers/creator.helper';\nimport { CSFDOptions } from '../types';\nimport { creatorUrl } from '../vars';\n\nexport class CreatorScraper {\n public async creator(creatorId: number, options?: CSFDOptions): Promise<CSFDCreator> {\n const id = Number(creatorId);\n if (isNaN(id)) {\n throw new Error('node-csfd-api: creatorId must be a valid number');\n }\n const url = creatorUrl(id, { language: options?.language });\n const response = await fetchPage(url, { ...options?.request });\n\n const creatorHtml = parse(response);\n\n const asideNode = creatorHtml.querySelector('.creator-about');\n const filmsNode = creatorHtml.querySelector('.creator-filmography');\n return this.buildCreator(+creatorId, asideNode, filmsNode);\n }\n\n private buildCreator(id: number, asideEl: HTMLElement, filmsNode: HTMLElement): CSFDCreator {\n const birthdayInfo = getCreatorBirthdayInfo(asideEl);\n return {\n id,\n name: getCreatorName(asideEl),\n birthday: birthdayInfo?.birthday,\n birthplace: birthdayInfo?.birthPlace,\n photo: getCreatorPhoto(asideEl),\n age: birthdayInfo?.age || null,\n bio: getCreatorBio(asideEl),\n films: getCreatorFilms(filmsNode)\n };\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,iBAAb,MAA4B;CAC1B,MAAa,QAAQ,WAAmB,SAA6C;EACnF,MAAM,KAAK,OAAO,UAAU;AAC5B,MAAI,MAAM,GAAG,CACX,OAAM,IAAI,MAAM,kDAAkD;EAKpE,MAAM,cAAc,MAFH,MAAM,UADX,WAAW,IAAI,EAAE,UAAU,SAAS,UAAU,CAAC,EACrB,EAAE,GAAG,SAAS,SAAS,CAAC,CAE3B;EAEnC,MAAM,YAAY,YAAY,cAAc,iBAAiB;EAC7D,MAAM,YAAY,YAAY,cAAc,uBAAuB;AACnE,SAAO,KAAK,aAAa,CAAC,WAAW,WAAW,UAAU;;CAG5D,aAAqB,IAAY,SAAsB,WAAqC;EAC1F,MAAM,eAAe,uBAAuB,QAAQ;AACpD,SAAO;GACL;GACA,MAAM,eAAe,QAAQ;GAC7B,UAAU,cAAc;GACxB,YAAY,cAAc;GAC1B,OAAO,gBAAgB,QAAQ;GAC/B,KAAK,cAAc,OAAO;GAC1B,KAAK,cAAc,QAAQ;GAC3B,OAAO,gBAAgB,UAAU;GAClC"}
|