node-csfd-api 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helpers/movie.helper.js +9 -4
- package/package.json +1 -1
package/helpers/movie.helper.js
CHANGED
|
@@ -28,9 +28,10 @@ const getColorRating = (bodyClasses) => {
|
|
|
28
28
|
exports.getColorRating = getColorRating;
|
|
29
29
|
const getRating = (el) => {
|
|
30
30
|
const ratingRaw = el.querySelector('.film-rating-average').textContent;
|
|
31
|
-
const rating =
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const rating = ratingRaw === null || ratingRaw === void 0 ? void 0 : ratingRaw.replace(/%/g, '').trim();
|
|
32
|
+
const ratingInt = parseInt(rating);
|
|
33
|
+
if (Number.isInteger(ratingInt)) {
|
|
34
|
+
return ratingInt;
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
37
|
return null;
|
|
@@ -90,7 +91,10 @@ const getDuration = (jsonLdRaw, el) => {
|
|
|
90
91
|
exports.getDuration = getDuration;
|
|
91
92
|
const getTitlesOther = (el) => {
|
|
92
93
|
const namesNode = el.querySelectorAll('.film-names li');
|
|
93
|
-
|
|
94
|
+
if (!namesNode.length) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const titlesOther = namesNode.map((el) => {
|
|
94
98
|
const country = el.querySelector('img.flag').attributes.alt;
|
|
95
99
|
const title = el.textContent.trim().split('\n')[0];
|
|
96
100
|
if (country && title) {
|
|
@@ -103,6 +107,7 @@ const getTitlesOther = (el) => {
|
|
|
103
107
|
return null;
|
|
104
108
|
}
|
|
105
109
|
});
|
|
110
|
+
return titlesOther.filter((x) => x);
|
|
106
111
|
};
|
|
107
112
|
exports.getTitlesOther = getTitlesOther;
|
|
108
113
|
const getPoster = (el) => {
|