node-csfd-api-racintom 1.8.0 → 1.9.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/fetchers/fetch.polyfill.d.ts +1 -0
- package/fetchers/fetch.polyfill.js +9 -0
- package/fetchers/index.d.ts +1 -0
- package/fetchers/index.js +27 -0
- package/helpers/creator.helper.d.ts +17 -0
- package/helpers/creator.helper.js +87 -0
- package/helpers/global.helper.d.ts +17 -0
- package/helpers/global.helper.js +68 -0
- package/helpers/movie.helper.d.ts +26 -0
- package/helpers/movie.helper.js +270 -0
- package/helpers/search-user.helper.d.ts +5 -0
- package/helpers/search-user.helper.js +22 -0
- package/helpers/search.helper.d.ts +11 -0
- package/helpers/search.helper.js +62 -0
- package/helpers/user-ratings.helper.d.ts +13 -0
- package/helpers/user-ratings.helper.js +61 -0
- package/index.d.ts +24 -0
- package/index.js +39 -0
- package/interfaces/creator.interface.d.ts +12 -0
- package/interfaces/creator.interface.js +2 -0
- package/interfaces/global.d.ts +22 -0
- package/interfaces/global.js +2 -0
- package/interfaces/movie.interface.d.ts +73 -0
- package/interfaces/movie.interface.js +2 -0
- package/interfaces/search.interface.d.ts +27 -0
- package/interfaces/search.interface.js +2 -0
- package/interfaces/season.interface.d.ts +11 -0
- package/interfaces/season.interface.js +2 -0
- package/interfaces/user-ratings.interface.d.ts +18 -0
- package/interfaces/user-ratings.interface.js +2 -0
- package/package.json +62 -86
- package/services/creator.service.d.ts +6 -0
- package/services/creator.service.js +32 -0
- package/services/movie.service.d.ts +6 -0
- package/services/movie.service.js +59 -0
- package/services/search.service.d.ts +5 -0
- package/services/search.service.js +80 -0
- package/services/season.service.d.ts +9 -0
- package/services/season.service.js +43 -0
- package/services/user-ratings.service.d.ts +7 -0
- package/services/user-ratings.service.js +84 -0
- package/vars.d.ts +5 -0
- package/vars.js +13 -0
- package/.editorconfig +0 -13
- package/.eslintrc.json +0 -33
- package/.gitattributes +0 -2
- package/.github/FUNDING.yml +0 -8
- package/.github/pull_request_template.md +0 -19
- package/.github/workflows/main.yml +0 -40
- package/.github/workflows/publish.yml +0 -73
- package/.github/workflows/test.yml +0 -43
- package/.husky/pre-commit +0 -1
- package/.idea/codeStyles/Project.xml +0 -72
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/node-csfd-api.iml +0 -9
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -7
- package/.nvmrc +0 -1
- package/.prettierignore +0 -8
- package/.prettierrc +0 -10
- package/.vscode/settings.json +0 -16
- package/Dockerfile +0 -19
- package/demo.ts +0 -35
- package/eslint.config.mjs +0 -55
- package/server.ts +0 -66
- package/src/fetchers/fetch.polyfill.ts +0 -7
- package/src/fetchers/index.ts +0 -25
- package/src/helpers/creator.helper.ts +0 -95
- package/src/helpers/global.helper.ts +0 -70
- package/src/helpers/movie.helper.ts +0 -276
- package/src/helpers/search-user.helper.ts +0 -19
- package/src/helpers/search.helper.ts +0 -66
- package/src/helpers/user-ratings.helper.ts +0 -62
- package/src/index.ts +0 -50
- package/src/interfaces/creator.interface.ts +0 -14
- package/src/interfaces/global.ts +0 -36
- package/src/interfaces/movie.interface.ts +0 -157
- package/src/interfaces/search.interface.ts +0 -32
- package/src/interfaces/season.interface.ts +0 -12
- package/src/interfaces/user-ratings.interface.ts +0 -21
- package/src/services/creator.service.ts +0 -34
- package/src/services/movie.service.ts +0 -89
- package/src/services/search.service.ts +0 -101
- package/src/services/season.service.ts +0 -55
- package/src/services/user-ratings.service.ts +0 -106
- package/src/vars.ts +0 -16
- package/tests/creator.test.ts +0 -182
- package/tests/fetchers.test.ts +0 -109
- package/tests/global.test.ts +0 -35
- package/tests/helpers.test.ts +0 -59
- package/tests/mocks/creator-actor.html.ts +0 -2244
- package/tests/mocks/creator-composer-empty.html.ts +0 -683
- package/tests/mocks/creator-director.html.ts +0 -3407
- package/tests/mocks/movie1.html.ts +0 -1430
- package/tests/mocks/movie2.html.ts +0 -740
- package/tests/mocks/movie3.html.ts +0 -1843
- package/tests/mocks/movie4.html.ts +0 -1568
- package/tests/mocks/search.html.ts +0 -838
- package/tests/mocks/series1.html.ts +0 -1540
- package/tests/mocks/userRatings.html.ts +0 -1354
- package/tests/movie.test.ts +0 -606
- package/tests/search.test.ts +0 -379
- package/tests/season.test.ts +0 -115
- package/tests/services.test.ts +0 -106
- package/tests/user-ratings.test.ts +0 -142
- package/tests/vars.test.ts +0 -34
- package/tsconfig.json +0 -23
- package/vitest.config.mts +0 -10
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { HTMLElement, parse } from 'node-html-parser';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
import {
|
|
4
|
-
getColorRating,
|
|
5
|
-
getDate,
|
|
6
|
-
getId,
|
|
7
|
-
getTitle,
|
|
8
|
-
getType,
|
|
9
|
-
getUrl,
|
|
10
|
-
getUserRating,
|
|
11
|
-
getYear
|
|
12
|
-
} from '../src/helpers/user-ratings.helper';
|
|
13
|
-
import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../src/interfaces/global';
|
|
14
|
-
import { userRatingsMock } from './mocks/userRatings.html';
|
|
15
|
-
|
|
16
|
-
const items = parse(userRatingsMock);
|
|
17
|
-
const movies: HTMLElement[] = items.querySelectorAll('.box-user-rating .table-container tbody tr');
|
|
18
|
-
|
|
19
|
-
describe('Get Ratings', () => {
|
|
20
|
-
test('First rating', () => {
|
|
21
|
-
const movie = getUserRating(movies[0]);
|
|
22
|
-
expect(movie).toEqual<CSFDStars>(4);
|
|
23
|
-
});
|
|
24
|
-
test('Last rating', () => {
|
|
25
|
-
const movie = getUserRating(movies[movies.length - 1]);
|
|
26
|
-
expect(movie).toEqual<CSFDStars>(3);
|
|
27
|
-
});
|
|
28
|
-
// TODO
|
|
29
|
-
// test('Zero Rating', () => {
|
|
30
|
-
// const movie = getUserRating(movies[5]);
|
|
31
|
-
// expect(movie).toEqual<CSFDStars>(0);
|
|
32
|
-
// });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('Get ID', () => {
|
|
36
|
-
test('First ID', () => {
|
|
37
|
-
const movie = getId(movies[0]);
|
|
38
|
-
expect(movie).toEqual<number>(1254361);
|
|
39
|
-
});
|
|
40
|
-
test('Last ID', () => {
|
|
41
|
-
const movie = getId(movies[movies.length - 1]);
|
|
42
|
-
expect(movie).toEqual<number>(1169425);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('Get type', () => {
|
|
47
|
-
test('Film', () => {
|
|
48
|
-
const movie = getType(movies[0]);
|
|
49
|
-
expect(movie).toEqual<CSFDFilmTypes>('film');
|
|
50
|
-
});
|
|
51
|
-
test('TV series', () => {
|
|
52
|
-
const movie = getType(movies[23]);
|
|
53
|
-
expect(movie).toEqual<CSFDFilmTypes>('seriál');
|
|
54
|
-
});
|
|
55
|
-
test('Episode', () => {
|
|
56
|
-
const movie = getType(movies[4]);
|
|
57
|
-
expect(movie).toEqual<CSFDFilmTypes>('epizoda');
|
|
58
|
-
});
|
|
59
|
-
// test('TV film', () => {
|
|
60
|
-
// const movie = getType(movies[18]);
|
|
61
|
-
// expect(movie).toEqual<CSFDFilmTypes>('TV film');
|
|
62
|
-
// });
|
|
63
|
-
// test('Pořad', () => {
|
|
64
|
-
// const movie = getType(movies[6]);
|
|
65
|
-
// expect(movie).toEqual<CSFDFilmTypes>('pořad');
|
|
66
|
-
// });
|
|
67
|
-
test('Amateur film', () => {
|
|
68
|
-
const movie = getType(movies[31]);
|
|
69
|
-
expect(movie).toEqual<CSFDFilmTypes>('amatérský film');
|
|
70
|
-
});
|
|
71
|
-
test('Season', () => {
|
|
72
|
-
const movie = getType(movies[11]);
|
|
73
|
-
expect(movie).toEqual<CSFDFilmTypes>('série');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('Get title', () => {
|
|
78
|
-
test('First title', () => {
|
|
79
|
-
const movie = getTitle(movies[0]);
|
|
80
|
-
expect(movie).toEqual<string>('Stutz');
|
|
81
|
-
});
|
|
82
|
-
test('Last title', () => {
|
|
83
|
-
const movie = getTitle(movies[movies.length - 1]);
|
|
84
|
-
expect(movie).toEqual<string>('Kouření způsobuje kašel');
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('Get year', () => {
|
|
89
|
-
test('First year', () => {
|
|
90
|
-
const movie = getYear(movies[0]);
|
|
91
|
-
expect(movie).toEqual<number>(2022);
|
|
92
|
-
});
|
|
93
|
-
test('Some year', () => {
|
|
94
|
-
const movie = getYear(movies[7]);
|
|
95
|
-
expect(movie).toEqual<number>(2016);
|
|
96
|
-
});
|
|
97
|
-
test('Almost last year', () => {
|
|
98
|
-
const movie = getYear(movies[movies.length - 7]);
|
|
99
|
-
expect(movie).toEqual<number>(2000);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe('Get color rating', () => {
|
|
104
|
-
// test('Black', () => {
|
|
105
|
-
// const movie = getColorRating(movies[7]);
|
|
106
|
-
// expect(movie).toEqual<CSFDColorRating>('bad');
|
|
107
|
-
// });
|
|
108
|
-
// test('Gray', () => {
|
|
109
|
-
// const movie = getColorRating(movies[29]);
|
|
110
|
-
// expect(movie).toEqual<CSFDColorRating>('unknown');
|
|
111
|
-
// });
|
|
112
|
-
test('Blue', () => {
|
|
113
|
-
const movie = getColorRating(movies[3]);
|
|
114
|
-
expect(movie).toEqual<CSFDColorRating>('average');
|
|
115
|
-
});
|
|
116
|
-
test('Red', () => {
|
|
117
|
-
const movie = getColorRating(movies[1]);
|
|
118
|
-
expect(movie).toEqual<CSFDColorRating>('good');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('Get date', () => {
|
|
123
|
-
test('First date', () => {
|
|
124
|
-
const movie = getDate(movies[0]);
|
|
125
|
-
expect(movie).toEqual<string>('16.12.2022');
|
|
126
|
-
});
|
|
127
|
-
test('Last date', () => {
|
|
128
|
-
const movie = getDate(movies[movies.length - 1]);
|
|
129
|
-
expect(movie).toEqual<string>('05.07.2022');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('Get Url', () => {
|
|
134
|
-
test('First url', () => {
|
|
135
|
-
const movie = getUrl(movies[0]);
|
|
136
|
-
expect(movie).toEqual<string>('https://www.csfd.cz/film/1254361-stutz/');
|
|
137
|
-
});
|
|
138
|
-
test('Last url', () => {
|
|
139
|
-
const movie = getUrl(movies[movies.length - 1]);
|
|
140
|
-
expect(movie).toEqual<string>('https://www.csfd.cz/film/1169425-koureni-zpusobuje-kasel/');
|
|
141
|
-
});
|
|
142
|
-
});
|
package/tests/vars.test.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { creatorUrl, movieUrl, searchUrl, userRatingsUrl } from '../src/vars';
|
|
3
|
-
|
|
4
|
-
describe('Vars User Ratings', () => {
|
|
5
|
-
test('Assemble User rating url', () => {
|
|
6
|
-
const url = userRatingsUrl('912-bart');
|
|
7
|
-
expect(url).toBe('https://www.csfd.cz/uzivatel/912-bart/hodnoceni/');
|
|
8
|
-
});
|
|
9
|
-
test('Assemble User rating. Page 2', () => {
|
|
10
|
-
const url = userRatingsUrl('912-bart', 2);
|
|
11
|
-
expect(url).toBe('https://www.csfd.cz/uzivatel/912-bart/hodnoceni/?page=2');
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('Vars Movies', () => {
|
|
16
|
-
test('Assemble movieUrl', () => {
|
|
17
|
-
const url = movieUrl(535121);
|
|
18
|
-
expect(url).toBe('https://www.csfd.cz/film/535121/prehled/');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('Vars Search', () => {
|
|
23
|
-
test('Assemble searchUrl', () => {
|
|
24
|
-
const url = searchUrl('matrix');
|
|
25
|
-
expect(url).toBe('https://www.csfd.cz/hledat/?q=matrix');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('Vars Creator', () => {
|
|
30
|
-
test('Assemble creatorUrl', () => {
|
|
31
|
-
const url = creatorUrl('1');
|
|
32
|
-
expect(url).toBe('https://www.csfd.cz/tvurce/1');
|
|
33
|
-
});
|
|
34
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"lib": ["dom"],
|
|
5
|
-
"types": ["node"],
|
|
6
|
-
"baseUrl": "./src",
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"module": "commonjs",
|
|
9
|
-
"strictNullChecks": false,
|
|
10
|
-
"sourceMap": false,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"strict": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"pretty": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"alwaysStrict": true,
|
|
18
|
-
"noImplicitAny": true,
|
|
19
|
-
"noImplicitReturns": true
|
|
20
|
-
},
|
|
21
|
-
"include": ["src"],
|
|
22
|
-
"exclude": ["dist/**/*", "*/tests/**/*"]
|
|
23
|
-
}
|
package/vitest.config.mts
DELETED