node-csfd-api 3.1.1 → 3.2.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/package.json +1 -1
- package/services/cinema.service.d.mts +0 -1
- package/services/cinema.service.d.ts +0 -1
- package/services/cinema.service.js +2 -3
- package/services/cinema.service.js.map +1 -1
- package/services/cinema.service.mjs +2 -3
- package/services/cinema.service.mjs.map +1 -1
- package/services/creator.service.d.mts +0 -1
- package/services/creator.service.d.ts +0 -1
- package/services/creator.service.js +2 -3
- package/services/creator.service.js.map +1 -1
- package/services/creator.service.mjs +2 -3
- package/services/creator.service.mjs.map +1 -1
- package/services/movie.service.d.mts +0 -1
- package/services/movie.service.d.ts +0 -1
- package/services/movie.service.js +2 -3
- package/services/movie.service.js.map +1 -1
- package/services/movie.service.mjs +2 -3
- package/services/movie.service.mjs.map +1 -1
- package/services/user-ratings.service.d.mts +0 -1
- package/services/user-ratings.service.d.ts +0 -1
- package/services/user-ratings.service.js +8 -10
- package/services/user-ratings.service.js.map +1 -1
- package/services/user-ratings.service.mjs +8 -10
- package/services/user-ratings.service.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@ import { CSFDCinema, CSFDCinemaPeriod } from "../dto/cinema.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/services/cinema.service.d.ts
|
|
4
4
|
declare class CinemaScraper {
|
|
5
|
-
private cinema;
|
|
6
5
|
cinemas(district?: number, period?: CSFDCinemaPeriod, optionsRequest?: RequestInit): Promise<CSFDCinema[]>;
|
|
7
6
|
private buildCinemas;
|
|
8
7
|
}
|
|
@@ -2,7 +2,6 @@ import { CSFDCinema, CSFDCinemaPeriod } from "../dto/cinema.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/services/cinema.service.d.ts
|
|
4
4
|
declare class CinemaScraper {
|
|
5
|
-
private cinema;
|
|
6
5
|
cinemas(district?: number, period?: CSFDCinemaPeriod, optionsRequest?: RequestInit): Promise<CSFDCinema[]>;
|
|
7
6
|
private buildCinemas;
|
|
8
7
|
}
|
|
@@ -9,8 +9,7 @@ node_html_parser = require_rolldown_runtime.__toESM(node_html_parser);
|
|
|
9
9
|
var CinemaScraper = class {
|
|
10
10
|
async cinemas(district = 1, period = "today", optionsRequest) {
|
|
11
11
|
const contentNode = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.cinemasUrl(district, period), { ...optionsRequest })).querySelectorAll("#snippet--cinemas section[id*=\"cinema-\"]");
|
|
12
|
-
this.buildCinemas(contentNode);
|
|
13
|
-
return this.cinema;
|
|
12
|
+
return this.buildCinemas(contentNode);
|
|
14
13
|
}
|
|
15
14
|
buildCinemas(contentNode) {
|
|
16
15
|
const cinemas = [];
|
|
@@ -26,7 +25,7 @@ var CinemaScraper = class {
|
|
|
26
25
|
};
|
|
27
26
|
cinemas.push(cinema);
|
|
28
27
|
});
|
|
29
|
-
|
|
28
|
+
return cinemas;
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cinema.service.js","names":["fetchPage","cinemasUrl","cinemas: CSFDCinema[]","parseCinema","cinema: CSFDCinema","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 { cinemasUrl } from '../vars';\nimport {\n getCinemaCoords,\n getCinemaId,\n getCinemaUrl,\n getGroupedFilmsByDate,\n parseCinema\n} from './../helpers/cinema.helper';\n\nexport class CinemaScraper {\n
|
|
1
|
+
{"version":3,"file":"cinema.service.js","names":["fetchPage","cinemasUrl","cinemas: CSFDCinema[]","parseCinema","cinema: CSFDCinema","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 { 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 optionsRequest?: RequestInit\n ): Promise<CSFDCinema[]> {\n const url = cinemasUrl(district, period);\n const response = await fetchPage(url, { ...optionsRequest });\n\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":";;;;;;;;AAYA,IAAa,gBAAb,MAA2B;CACzB,MAAa,QACX,WAAmB,GACnB,SAA2B,SAC3B,gBACuB;EAMvB,MAAM,0CAJW,MAAMA,wBADXC,wBAAW,UAAU,OAAO,EACF,EAAE,GAAG,gBAAgB,CAAC,CAEzB,CAEH,iBAAiB,6CAA2C;AAE5F,SAAO,KAAK,aAAa,YAAY;;CAGvC,AAAQ,aAAa,aAA0C;EAC7D,MAAMC,UAAwB,EAAE;AAEhC,cAAY,SAAS,MAAM;GACzB,MAAM,aAAaC,kCAAY,EAAE;GACjC,MAAMC,SAAqB;IACzB,IAAIC,kCAAY,EAAE;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,KAAKC,mCAAa,EAAE;IACpB,QAAQC,sCAAgB,EAAE;IAC1B,YAAYC,4CAAsB,EAAE;IACrC;AACD,WAAQ,KAAK,OAAO;IACpB;AAEF,SAAO"}
|
|
@@ -7,8 +7,7 @@ import { parse } from "node-html-parser";
|
|
|
7
7
|
var CinemaScraper = class {
|
|
8
8
|
async cinemas(district = 1, period = "today", optionsRequest) {
|
|
9
9
|
const contentNode = parse(await fetchPage(cinemasUrl(district, period), { ...optionsRequest })).querySelectorAll("#snippet--cinemas section[id*=\"cinema-\"]");
|
|
10
|
-
this.buildCinemas(contentNode);
|
|
11
|
-
return this.cinema;
|
|
10
|
+
return this.buildCinemas(contentNode);
|
|
12
11
|
}
|
|
13
12
|
buildCinemas(contentNode) {
|
|
14
13
|
const cinemas = [];
|
|
@@ -24,7 +23,7 @@ var CinemaScraper = class {
|
|
|
24
23
|
};
|
|
25
24
|
cinemas.push(cinema);
|
|
26
25
|
});
|
|
27
|
-
|
|
26
|
+
return cinemas;
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cinema.service.mjs","names":["cinemas: CSFDCinema[]","cinema: CSFDCinema"],"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 { cinemasUrl } from '../vars';\nimport {\n getCinemaCoords,\n getCinemaId,\n getCinemaUrl,\n getGroupedFilmsByDate,\n parseCinema\n} from './../helpers/cinema.helper';\n\nexport class CinemaScraper {\n
|
|
1
|
+
{"version":3,"file":"cinema.service.mjs","names":["cinemas: CSFDCinema[]","cinema: CSFDCinema"],"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 { 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 optionsRequest?: RequestInit\n ): Promise<CSFDCinema[]> {\n const url = cinemasUrl(district, period);\n const response = await fetchPage(url, { ...optionsRequest });\n\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":";;;;;;AAYA,IAAa,gBAAb,MAA2B;CACzB,MAAa,QACX,WAAmB,GACnB,SAA2B,SAC3B,gBACuB;EAMvB,MAAM,cAFc,MAFH,MAAM,UADX,WAAW,UAAU,OAAO,EACF,EAAE,GAAG,gBAAgB,CAAC,CAEzB,CAEH,iBAAiB,6CAA2C;AAE5F,SAAO,KAAK,aAAa,YAAY;;CAGvC,AAAQ,aAAa,aAA0C;EAC7D,MAAMA,UAAwB,EAAE;AAEhC,cAAY,SAAS,MAAM;GACzB,MAAM,aAAa,YAAY,EAAE;GACjC,MAAMC,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"}
|
|
@@ -13,11 +13,10 @@ var CreatorScraper = class {
|
|
|
13
13
|
const creatorHtml = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.creatorUrl(id), { ...optionsRequest }));
|
|
14
14
|
const asideNode = creatorHtml.querySelector(".creator-about");
|
|
15
15
|
const filmsNode = creatorHtml.querySelector(".creator-filmography");
|
|
16
|
-
this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
17
|
-
return this.person;
|
|
16
|
+
return this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
18
17
|
}
|
|
19
18
|
buildCreator(id, asideEl, filmsNode) {
|
|
20
|
-
|
|
19
|
+
return {
|
|
21
20
|
id,
|
|
22
21
|
name: require_creator_helper.getCreatorName(asideEl),
|
|
23
22
|
birthday: require_creator_helper.getCreatorBirthdayInfo(asideEl)?.birthday,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.service.js","names":["fetchPage","creatorUrl","getCreatorName","getCreatorBirthdayInfo","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 {
|
|
1
|
+
{"version":3,"file":"creator.service.js","names":["fetchPage","creatorUrl","getCreatorName","getCreatorBirthdayInfo","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 { creatorUrl } from '../vars';\n\nexport class CreatorScraper {\n public async creator(creatorId: number, optionsRequest?: RequestInit): 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);\n const response = await fetchPage(url, { ...optionsRequest });\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 return {\n id,\n name: getCreatorName(asideEl),\n birthday: getCreatorBirthdayInfo(asideEl)?.birthday,\n birthplace: getCreatorBirthdayInfo(asideEl)?.birthPlace,\n photo: getCreatorPhoto(asideEl),\n age: getCreatorBirthdayInfo(asideEl)?.age || null,\n bio: getCreatorBio(asideEl),\n films: getCreatorFilms(filmsNode)\n };\n }\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,iBAAb,MAA4B;CAC1B,MAAa,QAAQ,WAAmB,gBAAoD;EAC1F,MAAM,KAAK,OAAO,UAAU;AAC5B,MAAI,MAAM,GAAG,CACX,OAAM,IAAI,MAAM,kDAAkD;EAKpE,MAAM,0CAFW,MAAMA,wBADXC,wBAAW,GAAG,EACY,EAAE,GAAG,gBAAgB,CAAC,CAEzB;EAEnC,MAAM,YAAY,YAAY,cAAc,iBAAiB;EAC7D,MAAM,YAAY,YAAY,cAAc,uBAAuB;AACnE,SAAO,KAAK,aAAa,CAAC,WAAW,WAAW,UAAU;;CAG5D,AAAQ,aAAa,IAAY,SAAsB,WAAqC;AAC1F,SAAO;GACL;GACA,MAAMC,sCAAe,QAAQ;GAC7B,UAAUC,8CAAuB,QAAQ,EAAE;GAC3C,YAAYA,8CAAuB,QAAQ,EAAE;GAC7C,OAAOC,uCAAgB,QAAQ;GAC/B,KAAKD,8CAAuB,QAAQ,EAAE,OAAO;GAC7C,KAAKE,qCAAc,QAAQ;GAC3B,OAAOC,uCAAgB,UAAU;GAClC"}
|
|
@@ -11,11 +11,10 @@ var CreatorScraper = class {
|
|
|
11
11
|
const creatorHtml = parse(await fetchPage(creatorUrl(id), { ...optionsRequest }));
|
|
12
12
|
const asideNode = creatorHtml.querySelector(".creator-about");
|
|
13
13
|
const filmsNode = creatorHtml.querySelector(".creator-filmography");
|
|
14
|
-
this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
15
|
-
return this.person;
|
|
14
|
+
return this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
16
15
|
}
|
|
17
16
|
buildCreator(id, asideEl, filmsNode) {
|
|
18
|
-
|
|
17
|
+
return {
|
|
19
18
|
id,
|
|
20
19
|
name: getCreatorName(asideEl),
|
|
21
20
|
birthday: getCreatorBirthdayInfo(asideEl)?.birthday,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.service.mjs","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 {
|
|
1
|
+
{"version":3,"file":"creator.service.mjs","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 { creatorUrl } from '../vars';\n\nexport class CreatorScraper {\n public async creator(creatorId: number, optionsRequest?: RequestInit): 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);\n const response = await fetchPage(url, { ...optionsRequest });\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 return {\n id,\n name: getCreatorName(asideEl),\n birthday: getCreatorBirthdayInfo(asideEl)?.birthday,\n birthplace: getCreatorBirthdayInfo(asideEl)?.birthPlace,\n photo: getCreatorPhoto(asideEl),\n age: getCreatorBirthdayInfo(asideEl)?.age || null,\n bio: getCreatorBio(asideEl),\n films: getCreatorFilms(filmsNode)\n };\n }\n}\n"],"mappings":";;;;;;AAYA,IAAa,iBAAb,MAA4B;CAC1B,MAAa,QAAQ,WAAmB,gBAAoD;EAC1F,MAAM,KAAK,OAAO,UAAU;AAC5B,MAAI,MAAM,GAAG,CACX,OAAM,IAAI,MAAM,kDAAkD;EAKpE,MAAM,cAAc,MAFH,MAAM,UADX,WAAW,GAAG,EACY,EAAE,GAAG,gBAAgB,CAAC,CAEzB;EAEnC,MAAM,YAAY,YAAY,cAAc,iBAAiB;EAC7D,MAAM,YAAY,YAAY,cAAc,uBAAuB;AACnE,SAAO,KAAK,aAAa,CAAC,WAAW,WAAW,UAAU;;CAG5D,AAAQ,aAAa,IAAY,SAAsB,WAAqC;AAC1F,SAAO;GACL;GACA,MAAM,eAAe,QAAQ;GAC7B,UAAU,uBAAuB,QAAQ,EAAE;GAC3C,YAAY,uBAAuB,QAAQ,EAAE;GAC7C,OAAO,gBAAgB,QAAQ;GAC/B,KAAK,uBAAuB,QAAQ,EAAE,OAAO;GAC7C,KAAK,cAAc,QAAQ;GAC3B,OAAO,gBAAgB,UAAU;GAClC"}
|
|
@@ -15,11 +15,10 @@ var MovieScraper = class {
|
|
|
15
15
|
const asideNode = movieHtml.querySelector(".aside-movie-profile");
|
|
16
16
|
const movieNode = movieHtml.querySelector(".main-movie-profile");
|
|
17
17
|
const jsonLd = movieHtml.querySelector("script[type=\"application/ld+json\"]").innerText;
|
|
18
|
-
this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
19
|
-
return this.film;
|
|
18
|
+
return this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
20
19
|
}
|
|
21
20
|
buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
|
|
22
|
-
|
|
21
|
+
return {
|
|
23
22
|
id: movieId,
|
|
24
23
|
title: require_movie_helper.getMovieTitle(el),
|
|
25
24
|
year: require_movie_helper.getMovieYear(jsonLd),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movie.service.js","names":["fetchPage","movieUrl","getMovieTitle","getMovieYear","getMovieDuration","getMovieDescriptions","getMovieGenres","getMovieType","getMovieOrigins","getMovieColorRating","getMovieRating","getMovieRatingCount","getMovieTitlesOther","getMoviePoster","getMovieRandomPhoto","getMovieTrivia","getMovieGroup","getMovieVods","getMovieTags","getMoviePremieres","getMovieBoxMovies"],"sources":["../../src/services/movie.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovie } from '../dto/movie';\nimport { fetchPage } from '../fetchers';\nimport {\n getMovieBoxMovies,\n getMovieColorRating,\n getMovieDescriptions,\n getMovieDuration,\n getMovieGenres,\n getMovieGroup,\n getMovieOrigins,\n getMoviePoster,\n getMoviePremieres,\n getMovieRandomPhoto,\n getMovieRating,\n getMovieRatingCount,\n getMovieTags,\n getMovieTitle,\n getMovieTitlesOther,\n getMovieTrivia,\n getMovieType,\n getMovieVods,\n getMovieYear\n} from '../helpers/movie.helper';\nimport { movieUrl } from '../vars';\n\nexport class MovieScraper {\n
|
|
1
|
+
{"version":3,"file":"movie.service.js","names":["fetchPage","movieUrl","getMovieTitle","getMovieYear","getMovieDuration","getMovieDescriptions","getMovieGenres","getMovieType","getMovieOrigins","getMovieColorRating","getMovieRating","getMovieRatingCount","getMovieTitlesOther","getMoviePoster","getMovieRandomPhoto","getMovieTrivia","getMovieGroup","getMovieVods","getMovieTags","getMoviePremieres","getMovieBoxMovies"],"sources":["../../src/services/movie.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovie } from '../dto/movie';\nimport { fetchPage } from '../fetchers';\nimport {\n getMovieBoxMovies,\n getMovieColorRating,\n getMovieDescriptions,\n getMovieDuration,\n getMovieGenres,\n getMovieGroup,\n getMovieOrigins,\n getMoviePoster,\n getMoviePremieres,\n getMovieRandomPhoto,\n getMovieRating,\n getMovieRatingCount,\n getMovieTags,\n getMovieTitle,\n getMovieTitlesOther,\n getMovieTrivia,\n getMovieType,\n getMovieVods,\n getMovieYear\n} from '../helpers/movie.helper';\nimport { movieUrl } from '../vars';\n\nexport class MovieScraper {\n public async movie(movieId: number, optionsRequest?: RequestInit): Promise<CSFDMovie> {\n const id = Number(movieId);\n if (isNaN(id)) {\n throw new Error('node-csfd-api: movieId must be a valid number');\n }\n const url = movieUrl(id);\n const response = await fetchPage(url, { ...optionsRequest });\n\n const movieHtml = parse(response);\n\n const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');\n const asideNode = movieHtml.querySelector('.aside-movie-profile');\n const movieNode = movieHtml.querySelector('.main-movie-profile');\n const jsonLd = movieHtml.querySelector('script[type=\"application/ld+json\"]').innerText;\n return this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);\n }\n\n private buildMovie(\n movieId: number,\n el: HTMLElement,\n asideEl: HTMLElement,\n pageClasses: string[],\n jsonLd: string\n ): CSFDMovie {\n return {\n id: movieId,\n title: getMovieTitle(el),\n year: getMovieYear(jsonLd),\n duration: getMovieDuration(jsonLd, el),\n descriptions: getMovieDescriptions(el),\n genres: getMovieGenres(el),\n type: getMovieType(el) as CSFDFilmTypes,\n url: movieUrl(movieId),\n origins: getMovieOrigins(el),\n colorRating: getMovieColorRating(pageClasses),\n rating: getMovieRating(asideEl),\n ratingCount: getMovieRatingCount(asideEl),\n titlesOther: getMovieTitlesOther(el),\n poster: getMoviePoster(el),\n photo: getMovieRandomPhoto(el),\n trivia: getMovieTrivia(el),\n creators: {\n directors: getMovieGroup(el, 'Režie'),\n writers: getMovieGroup(el, 'Scénář'),\n cinematography: getMovieGroup(el, 'Kamera'),\n music: getMovieGroup(el, 'Hudba'),\n actors: getMovieGroup(el, 'Hrají'),\n basedOn: getMovieGroup(el, 'Předloha'),\n producers: getMovieGroup(el, 'Produkce'),\n filmEditing: getMovieGroup(el, 'Střih'),\n costumeDesign: getMovieGroup(el, 'Kostýmy'),\n productionDesign: getMovieGroup(el, 'Scénografie')\n },\n vod: getMovieVods(asideEl),\n tags: getMovieTags(asideEl),\n premieres: getMoviePremieres(asideEl),\n related: getMovieBoxMovies(asideEl, 'Související'),\n similar: getMovieBoxMovies(asideEl, 'Podobné')\n };\n }\n}\n"],"mappings":";;;;;;;;AA2BA,IAAa,eAAb,MAA0B;CACxB,MAAa,MAAM,SAAiB,gBAAkD;EACpF,MAAM,KAAK,OAAO,QAAQ;AAC1B,MAAI,MAAM,GAAG,CACX,OAAM,IAAI,MAAM,gDAAgD;EAKlE,MAAM,wCAFW,MAAMA,wBADXC,sBAAS,GAAG,EACc,EAAE,GAAG,gBAAgB,CAAC,CAE3B;EAEjC,MAAM,cAAc,UAAU,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI;EAClF,MAAM,YAAY,UAAU,cAAc,uBAAuB;EACjE,MAAM,YAAY,UAAU,cAAc,sBAAsB;EAChE,MAAM,SAAS,UAAU,cAAc,uCAAqC,CAAC;AAC7E,SAAO,KAAK,WAAW,CAAC,SAAS,WAAW,WAAW,aAAa,OAAO;;CAG7E,AAAQ,WACN,SACA,IACA,SACA,aACA,QACW;AACX,SAAO;GACL,IAAI;GACJ,OAAOC,mCAAc,GAAG;GACxB,MAAMC,kCAAa,OAAO;GAC1B,UAAUC,sCAAiB,QAAQ,GAAG;GACtC,cAAcC,0CAAqB,GAAG;GACtC,QAAQC,oCAAe,GAAG;GAC1B,MAAMC,kCAAa,GAAG;GACtB,KAAKN,sBAAS,QAAQ;GACtB,SAASO,qCAAgB,GAAG;GAC5B,aAAaC,yCAAoB,YAAY;GAC7C,QAAQC,oCAAe,QAAQ;GAC/B,aAAaC,yCAAoB,QAAQ;GACzC,aAAaC,yCAAoB,GAAG;GACpC,QAAQC,oCAAe,GAAG;GAC1B,OAAOC,yCAAoB,GAAG;GAC9B,QAAQC,oCAAe,GAAG;GAC1B,UAAU;IACR,WAAWC,mCAAc,IAAI,QAAQ;IACrC,SAASA,mCAAc,IAAI,SAAS;IACpC,gBAAgBA,mCAAc,IAAI,SAAS;IAC3C,OAAOA,mCAAc,IAAI,QAAQ;IACjC,QAAQA,mCAAc,IAAI,QAAQ;IAClC,SAASA,mCAAc,IAAI,WAAW;IACtC,WAAWA,mCAAc,IAAI,WAAW;IACxC,aAAaA,mCAAc,IAAI,QAAQ;IACvC,eAAeA,mCAAc,IAAI,UAAU;IAC3C,kBAAkBA,mCAAc,IAAI,cAAc;IACnD;GACD,KAAKC,kCAAa,QAAQ;GAC1B,MAAMC,kCAAa,QAAQ;GAC3B,WAAWC,uCAAkB,QAAQ;GACrC,SAASC,uCAAkB,SAAS,cAAc;GAClD,SAASA,uCAAkB,SAAS,UAAU;GAC/C"}
|
|
@@ -13,11 +13,10 @@ var MovieScraper = class {
|
|
|
13
13
|
const asideNode = movieHtml.querySelector(".aside-movie-profile");
|
|
14
14
|
const movieNode = movieHtml.querySelector(".main-movie-profile");
|
|
15
15
|
const jsonLd = movieHtml.querySelector("script[type=\"application/ld+json\"]").innerText;
|
|
16
|
-
this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
17
|
-
return this.film;
|
|
16
|
+
return this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
18
17
|
}
|
|
19
18
|
buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
|
|
20
|
-
|
|
19
|
+
return {
|
|
21
20
|
id: movieId,
|
|
22
21
|
title: getMovieTitle(el),
|
|
23
22
|
year: getMovieYear(jsonLd),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movie.service.mjs","names":[],"sources":["../../src/services/movie.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovie } from '../dto/movie';\nimport { fetchPage } from '../fetchers';\nimport {\n getMovieBoxMovies,\n getMovieColorRating,\n getMovieDescriptions,\n getMovieDuration,\n getMovieGenres,\n getMovieGroup,\n getMovieOrigins,\n getMoviePoster,\n getMoviePremieres,\n getMovieRandomPhoto,\n getMovieRating,\n getMovieRatingCount,\n getMovieTags,\n getMovieTitle,\n getMovieTitlesOther,\n getMovieTrivia,\n getMovieType,\n getMovieVods,\n getMovieYear\n} from '../helpers/movie.helper';\nimport { movieUrl } from '../vars';\n\nexport class MovieScraper {\n
|
|
1
|
+
{"version":3,"file":"movie.service.mjs","names":[],"sources":["../../src/services/movie.service.ts"],"sourcesContent":["import { HTMLElement, parse } from 'node-html-parser';\nimport { CSFDFilmTypes } from '../dto/global';\nimport { CSFDMovie } from '../dto/movie';\nimport { fetchPage } from '../fetchers';\nimport {\n getMovieBoxMovies,\n getMovieColorRating,\n getMovieDescriptions,\n getMovieDuration,\n getMovieGenres,\n getMovieGroup,\n getMovieOrigins,\n getMoviePoster,\n getMoviePremieres,\n getMovieRandomPhoto,\n getMovieRating,\n getMovieRatingCount,\n getMovieTags,\n getMovieTitle,\n getMovieTitlesOther,\n getMovieTrivia,\n getMovieType,\n getMovieVods,\n getMovieYear\n} from '../helpers/movie.helper';\nimport { movieUrl } from '../vars';\n\nexport class MovieScraper {\n public async movie(movieId: number, optionsRequest?: RequestInit): Promise<CSFDMovie> {\n const id = Number(movieId);\n if (isNaN(id)) {\n throw new Error('node-csfd-api: movieId must be a valid number');\n }\n const url = movieUrl(id);\n const response = await fetchPage(url, { ...optionsRequest });\n\n const movieHtml = parse(response);\n\n const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');\n const asideNode = movieHtml.querySelector('.aside-movie-profile');\n const movieNode = movieHtml.querySelector('.main-movie-profile');\n const jsonLd = movieHtml.querySelector('script[type=\"application/ld+json\"]').innerText;\n return this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);\n }\n\n private buildMovie(\n movieId: number,\n el: HTMLElement,\n asideEl: HTMLElement,\n pageClasses: string[],\n jsonLd: string\n ): CSFDMovie {\n return {\n id: movieId,\n title: getMovieTitle(el),\n year: getMovieYear(jsonLd),\n duration: getMovieDuration(jsonLd, el),\n descriptions: getMovieDescriptions(el),\n genres: getMovieGenres(el),\n type: getMovieType(el) as CSFDFilmTypes,\n url: movieUrl(movieId),\n origins: getMovieOrigins(el),\n colorRating: getMovieColorRating(pageClasses),\n rating: getMovieRating(asideEl),\n ratingCount: getMovieRatingCount(asideEl),\n titlesOther: getMovieTitlesOther(el),\n poster: getMoviePoster(el),\n photo: getMovieRandomPhoto(el),\n trivia: getMovieTrivia(el),\n creators: {\n directors: getMovieGroup(el, 'Režie'),\n writers: getMovieGroup(el, 'Scénář'),\n cinematography: getMovieGroup(el, 'Kamera'),\n music: getMovieGroup(el, 'Hudba'),\n actors: getMovieGroup(el, 'Hrají'),\n basedOn: getMovieGroup(el, 'Předloha'),\n producers: getMovieGroup(el, 'Produkce'),\n filmEditing: getMovieGroup(el, 'Střih'),\n costumeDesign: getMovieGroup(el, 'Kostýmy'),\n productionDesign: getMovieGroup(el, 'Scénografie')\n },\n vod: getMovieVods(asideEl),\n tags: getMovieTags(asideEl),\n premieres: getMoviePremieres(asideEl),\n related: getMovieBoxMovies(asideEl, 'Související'),\n similar: getMovieBoxMovies(asideEl, 'Podobné')\n };\n }\n}\n"],"mappings":";;;;;;AA2BA,IAAa,eAAb,MAA0B;CACxB,MAAa,MAAM,SAAiB,gBAAkD;EACpF,MAAM,KAAK,OAAO,QAAQ;AAC1B,MAAI,MAAM,GAAG,CACX,OAAM,IAAI,MAAM,gDAAgD;EAKlE,MAAM,YAAY,MAFD,MAAM,UADX,SAAS,GAAG,EACc,EAAE,GAAG,gBAAgB,CAAC,CAE3B;EAEjC,MAAM,cAAc,UAAU,cAAc,gBAAgB,CAAC,WAAW,MAAM,IAAI;EAClF,MAAM,YAAY,UAAU,cAAc,uBAAuB;EACjE,MAAM,YAAY,UAAU,cAAc,sBAAsB;EAChE,MAAM,SAAS,UAAU,cAAc,uCAAqC,CAAC;AAC7E,SAAO,KAAK,WAAW,CAAC,SAAS,WAAW,WAAW,aAAa,OAAO;;CAG7E,AAAQ,WACN,SACA,IACA,SACA,aACA,QACW;AACX,SAAO;GACL,IAAI;GACJ,OAAO,cAAc,GAAG;GACxB,MAAM,aAAa,OAAO;GAC1B,UAAU,iBAAiB,QAAQ,GAAG;GACtC,cAAc,qBAAqB,GAAG;GACtC,QAAQ,eAAe,GAAG;GAC1B,MAAM,aAAa,GAAG;GACtB,KAAK,SAAS,QAAQ;GACtB,SAAS,gBAAgB,GAAG;GAC5B,aAAa,oBAAoB,YAAY;GAC7C,QAAQ,eAAe,QAAQ;GAC/B,aAAa,oBAAoB,QAAQ;GACzC,aAAa,oBAAoB,GAAG;GACpC,QAAQ,eAAe,GAAG;GAC1B,OAAO,oBAAoB,GAAG;GAC9B,QAAQ,eAAe,GAAG;GAC1B,UAAU;IACR,WAAW,cAAc,IAAI,QAAQ;IACrC,SAAS,cAAc,IAAI,SAAS;IACpC,gBAAgB,cAAc,IAAI,SAAS;IAC3C,OAAO,cAAc,IAAI,QAAQ;IACjC,QAAQ,cAAc,IAAI,QAAQ;IAClC,SAAS,cAAc,IAAI,WAAW;IACtC,WAAW,cAAc,IAAI,WAAW;IACxC,aAAa,cAAc,IAAI,QAAQ;IACvC,eAAe,cAAc,IAAI,UAAU;IAC3C,kBAAkB,cAAc,IAAI,cAAc;IACnD;GACD,KAAK,aAAa,QAAQ;GAC1B,MAAM,aAAa,QAAQ;GAC3B,WAAW,kBAAkB,QAAQ;GACrC,SAAS,kBAAkB,SAAS,cAAc;GAClD,SAAS,kBAAkB,SAAS,UAAU;GAC/C"}
|
|
@@ -2,7 +2,6 @@ import { CSFDUserRatingConfig, CSFDUserRatings } from "../dto/user-ratings.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/services/user-ratings.service.d.ts
|
|
4
4
|
declare class UserRatingsScraper {
|
|
5
|
-
private films;
|
|
6
5
|
userRatings(user: string | number, config?: CSFDUserRatingConfig, optionsRequest?: RequestInit): Promise<CSFDUserRatings[]>;
|
|
7
6
|
private getPage;
|
|
8
7
|
private buildUserRatings;
|
|
@@ -2,7 +2,6 @@ import { CSFDUserRatingConfig, CSFDUserRatings } from "../dto/user-ratings.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/services/user-ratings.service.d.ts
|
|
4
4
|
declare class UserRatingsScraper {
|
|
5
|
-
private films;
|
|
6
5
|
userRatings(user: string | number, config?: CSFDUserRatingConfig, optionsRequest?: RequestInit): Promise<CSFDUserRatings[]>;
|
|
7
6
|
private getPage;
|
|
8
7
|
private buildUserRatings;
|
|
@@ -7,9 +7,6 @@ node_html_parser = require_rolldown_runtime.__toESM(node_html_parser);
|
|
|
7
7
|
|
|
8
8
|
//#region src/services/user-ratings.service.ts
|
|
9
9
|
var UserRatingsScraper = class {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.films = [];
|
|
12
|
-
}
|
|
13
10
|
async userRatings(user, config, optionsRequest) {
|
|
14
11
|
let allMovies = [];
|
|
15
12
|
const url = require_vars.userRatingsUrl(user);
|
|
@@ -24,7 +21,7 @@ var UserRatingsScraper = class {
|
|
|
24
21
|
for (let i = 2; i <= pages; i++) {
|
|
25
22
|
console.log("Fetching page", i, "out of", pages, "...");
|
|
26
23
|
const movies$1 = (0, node_html_parser.parse)(await require_index.fetchPage(require_vars.userRatingsUrl(user, i), { ...optionsRequest })).querySelectorAll(".box-user-rating .table-container tbody tr");
|
|
27
|
-
allMovies = [...this.getPage(config, movies$1)];
|
|
24
|
+
allMovies = [...allMovies, ...this.getPage(config, movies$1)];
|
|
28
25
|
if (config.allPagesDelay) await require_user_ratings_helper.sleep(config.allPagesDelay);
|
|
29
26
|
}
|
|
30
27
|
return allMovies;
|
|
@@ -32,6 +29,7 @@ var UserRatingsScraper = class {
|
|
|
32
29
|
return allMovies;
|
|
33
30
|
}
|
|
34
31
|
getPage(config, movies) {
|
|
32
|
+
const films = [];
|
|
35
33
|
if (config) {
|
|
36
34
|
if (config.includesOnly?.length && config.excludes?.length) console.warn(`node-csfd-api:
|
|
37
35
|
You can not use both parameters 'includesOnly' and 'excludes'.
|
|
@@ -40,15 +38,15 @@ var UserRatingsScraper = class {
|
|
|
40
38
|
for (const el of movies) {
|
|
41
39
|
const type = require_user_ratings_helper.getUserRatingType(el);
|
|
42
40
|
if (config?.includesOnly?.length) {
|
|
43
|
-
if (config.includesOnly.some((include) => type === include)) this.buildUserRatings(el);
|
|
41
|
+
if (config.includesOnly.some((include) => type === include)) films.push(this.buildUserRatings(el));
|
|
44
42
|
} else if (config?.excludes?.length) {
|
|
45
|
-
if (!config.excludes.some((exclude) => type === exclude)) this.buildUserRatings(el);
|
|
46
|
-
} else this.buildUserRatings(el);
|
|
43
|
+
if (!config.excludes.some((exclude) => type === exclude)) films.push(this.buildUserRatings(el));
|
|
44
|
+
} else films.push(this.buildUserRatings(el));
|
|
47
45
|
}
|
|
48
|
-
return
|
|
46
|
+
return films;
|
|
49
47
|
}
|
|
50
48
|
buildUserRatings(el) {
|
|
51
|
-
|
|
49
|
+
return {
|
|
52
50
|
id: require_user_ratings_helper.getUserRatingId(el),
|
|
53
51
|
title: require_user_ratings_helper.getUserRatingTitle(el),
|
|
54
52
|
year: require_user_ratings_helper.getUserRatingYear(el),
|
|
@@ -57,7 +55,7 @@ var UserRatingsScraper = class {
|
|
|
57
55
|
colorRating: require_user_ratings_helper.getUserRatingColorRating(el),
|
|
58
56
|
userDate: require_user_ratings_helper.getUserRatingDate(el),
|
|
59
57
|
userRating: require_user_ratings_helper.getUserRating(el)
|
|
60
|
-
}
|
|
58
|
+
};
|
|
61
59
|
}
|
|
62
60
|
};
|
|
63
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-ratings.service.js","names":["allMovies: CSFDUserRatings[]","userRatingsUrl","fetchPage","movies","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 {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear,\n sleep\n} from '../helpers/user-ratings.helper';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n
|
|
1
|
+
{"version":3,"file":"user-ratings.service.js","names":["allMovies: CSFDUserRatings[]","userRatingsUrl","fetchPage","movies","sleep","films: CSFDUserRatings[]","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 {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear,\n sleep\n} from '../helpers/user-ratings.helper';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n optionsRequest?: RequestInit\n ): Promise<CSFDUserRatings[]> {\n let allMovies: CSFDUserRatings[] = [];\n const url = userRatingsUrl(user);\n const response = await fetchPage(url, { ...optionsRequest });\n const items = parse(response);\n const movies = items.querySelectorAll('.box-user-rating .table-container tbody 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);\n const response = await fetchPage(url, { ...optionsRequest });\n\n const items = parse(response);\n const movies = items.querySelectorAll('.box-user-rating .table-container tbody 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 exludes\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":";;;;;;;;AAiBA,IAAa,qBAAb,MAAgC;CAC9B,MAAa,YACX,MACA,QACA,gBAC4B;EAC5B,IAAIA,YAA+B,EAAE;EACrC,MAAM,MAAMC,4BAAe,KAAK;EAEhC,MAAM,oCADW,MAAMC,wBAAU,KAAK,EAAE,GAAG,gBAAgB,CAAC,CAC/B;EAC7B,MAAM,SAAS,MAAM,iBAAiB,6CAA6C;EAGnF,MAAM,YAAY,MAAM,cAAc,cAAc;EACpD,MAAM,QAAQ,CAAC,WAAW,WAAW,UAAU,WAAW,SAAS,GAAG,WAAW;AAEjF,cAAY,KAAK,QAAQ,QAAQ,OAAO;AAExC,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,MAAMC,uCAHW,MAAMD,wBADXD,4BAAe,MAAM,EAAE,EACG,EAAE,GAAG,gBAAgB,CAAC,CAE/B,CACR,iBAAiB,6CAA6C;AACnF,gBAAY,CAAC,GAAG,WAAW,GAAG,KAAK,QAAQ,QAAQE,SAAO,CAAC;AAG3D,QAAI,OAAO,cACT,OAAMC,kCAAM,OAAO,cAAc;;AAGrC,UAAO;;AAGT,SAAO;;CAGT,AAAQ,QAAQ,QAA8B,QAAuB;EACnE,MAAMC,QAA2B,EAAE;AACnC,MAAI,QACF;OAAI,OAAO,cAAc,UAAU,OAAO,UAAU,OAClD,SAAQ,KACN;;qDAGA,OAAO,aACR;;AAIL,OAAK,MAAM,MAAM,QAAQ;GACvB,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,0CAAc,GAAG;GAC9B"}
|
|
@@ -5,9 +5,6 @@ import { parse } from "node-html-parser";
|
|
|
5
5
|
|
|
6
6
|
//#region src/services/user-ratings.service.ts
|
|
7
7
|
var UserRatingsScraper = class {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.films = [];
|
|
10
|
-
}
|
|
11
8
|
async userRatings(user, config, optionsRequest) {
|
|
12
9
|
let allMovies = [];
|
|
13
10
|
const url = userRatingsUrl(user);
|
|
@@ -22,7 +19,7 @@ var UserRatingsScraper = class {
|
|
|
22
19
|
for (let i = 2; i <= pages; i++) {
|
|
23
20
|
console.log("Fetching page", i, "out of", pages, "...");
|
|
24
21
|
const movies$1 = parse(await fetchPage(userRatingsUrl(user, i), { ...optionsRequest })).querySelectorAll(".box-user-rating .table-container tbody tr");
|
|
25
|
-
allMovies = [...this.getPage(config, movies$1)];
|
|
22
|
+
allMovies = [...allMovies, ...this.getPage(config, movies$1)];
|
|
26
23
|
if (config.allPagesDelay) await sleep(config.allPagesDelay);
|
|
27
24
|
}
|
|
28
25
|
return allMovies;
|
|
@@ -30,6 +27,7 @@ var UserRatingsScraper = class {
|
|
|
30
27
|
return allMovies;
|
|
31
28
|
}
|
|
32
29
|
getPage(config, movies) {
|
|
30
|
+
const films = [];
|
|
33
31
|
if (config) {
|
|
34
32
|
if (config.includesOnly?.length && config.excludes?.length) console.warn(`node-csfd-api:
|
|
35
33
|
You can not use both parameters 'includesOnly' and 'excludes'.
|
|
@@ -38,15 +36,15 @@ var UserRatingsScraper = class {
|
|
|
38
36
|
for (const el of movies) {
|
|
39
37
|
const type = getUserRatingType(el);
|
|
40
38
|
if (config?.includesOnly?.length) {
|
|
41
|
-
if (config.includesOnly.some((include) => type === include)) this.buildUserRatings(el);
|
|
39
|
+
if (config.includesOnly.some((include) => type === include)) films.push(this.buildUserRatings(el));
|
|
42
40
|
} else if (config?.excludes?.length) {
|
|
43
|
-
if (!config.excludes.some((exclude) => type === exclude)) this.buildUserRatings(el);
|
|
44
|
-
} else this.buildUserRatings(el);
|
|
41
|
+
if (!config.excludes.some((exclude) => type === exclude)) films.push(this.buildUserRatings(el));
|
|
42
|
+
} else films.push(this.buildUserRatings(el));
|
|
45
43
|
}
|
|
46
|
-
return
|
|
44
|
+
return films;
|
|
47
45
|
}
|
|
48
46
|
buildUserRatings(el) {
|
|
49
|
-
|
|
47
|
+
return {
|
|
50
48
|
id: getUserRatingId(el),
|
|
51
49
|
title: getUserRatingTitle(el),
|
|
52
50
|
year: getUserRatingYear(el),
|
|
@@ -55,7 +53,7 @@ var UserRatingsScraper = class {
|
|
|
55
53
|
colorRating: getUserRatingColorRating(el),
|
|
56
54
|
userDate: getUserRatingDate(el),
|
|
57
55
|
userRating: getUserRating(el)
|
|
58
|
-
}
|
|
56
|
+
};
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-ratings.service.mjs","names":["allMovies: CSFDUserRatings[]","movies"],"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 {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear,\n sleep\n} from '../helpers/user-ratings.helper';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n
|
|
1
|
+
{"version":3,"file":"user-ratings.service.mjs","names":["allMovies: CSFDUserRatings[]","movies","films: CSFDUserRatings[]"],"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 {\n getUserRating,\n getUserRatingColorRating,\n getUserRatingDate,\n getUserRatingId,\n getUserRatingTitle,\n getUserRatingType,\n getUserRatingUrl,\n getUserRatingYear,\n sleep\n} from '../helpers/user-ratings.helper';\nimport { userRatingsUrl } from '../vars';\n\nexport class UserRatingsScraper {\n public async userRatings(\n user: string | number,\n config?: CSFDUserRatingConfig,\n optionsRequest?: RequestInit\n ): Promise<CSFDUserRatings[]> {\n let allMovies: CSFDUserRatings[] = [];\n const url = userRatingsUrl(user);\n const response = await fetchPage(url, { ...optionsRequest });\n const items = parse(response);\n const movies = items.querySelectorAll('.box-user-rating .table-container tbody 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);\n const response = await fetchPage(url, { ...optionsRequest });\n\n const items = parse(response);\n const movies = items.querySelectorAll('.box-user-rating .table-container tbody 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 exludes\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":";;;;;;AAiBA,IAAa,qBAAb,MAAgC;CAC9B,MAAa,YACX,MACA,QACA,gBAC4B;EAC5B,IAAIA,YAA+B,EAAE;EACrC,MAAM,MAAM,eAAe,KAAK;EAEhC,MAAM,QAAQ,MADG,MAAM,UAAU,KAAK,EAAE,GAAG,gBAAgB,CAAC,CAC/B;EAC7B,MAAM,SAAS,MAAM,iBAAiB,6CAA6C;EAGnF,MAAM,YAAY,MAAM,cAAc,cAAc;EACpD,MAAM,QAAQ,CAAC,WAAW,WAAW,UAAU,WAAW,SAAS,GAAG,WAAW;AAEjF,cAAY,KAAK,QAAQ,QAAQ,OAAO;AAExC,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,MAAMC,WADQ,MAFG,MAAM,UADX,eAAe,MAAM,EAAE,EACG,EAAE,GAAG,gBAAgB,CAAC,CAE/B,CACR,iBAAiB,6CAA6C;AACnF,gBAAY,CAAC,GAAG,WAAW,GAAG,KAAK,QAAQ,QAAQA,SAAO,CAAC;AAG3D,QAAI,OAAO,cACT,OAAM,MAAM,OAAO,cAAc;;AAGrC,UAAO;;AAGT,SAAO;;CAGT,AAAQ,QAAQ,QAA8B,QAAuB;EACnE,MAAMC,QAA2B,EAAE;AACnC,MAAI,QACF;OAAI,OAAO,cAAc,UAAU,OAAO,UAAU,OAClD,SAAQ,KACN;;qDAGA,OAAO,aACR;;AAIL,OAAK,MAAM,MAAM,QAAQ;GACvB,MAAM,OAAO,kBAAkB,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,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"}
|