node-csfd-api
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -9,3 +9,3 @@ "use strict"; | ||
const vars_1 = require("../vars"); | ||
exports.fetchUserRatings = async (user) => { | ||
const fetchUserRatings = async (user) => { | ||
const url = vars_1.userRatingsUrl(user); | ||
@@ -15,3 +15,4 @@ const response = await cross_fetch_1.default(url); | ||
}; | ||
exports.fetchMovie = async (movie) => { | ||
exports.fetchUserRatings = fetchUserRatings; | ||
const fetchMovie = async (movie) => { | ||
const url = vars_1.movieUrl(movie); | ||
@@ -21,1 +22,2 @@ const response = await cross_fetch_1.default(url); | ||
}; | ||
exports.fetchMovie = fetchMovie; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseIdFromUrl = void 0; | ||
exports.parseIdFromUrl = (url) => { | ||
const parseIdFromUrl = (url) => { | ||
const idSlug = url.split('/')[2]; | ||
@@ -9,1 +9,2 @@ const id = idSlug.split('-')[0]; | ||
}; | ||
exports.parseIdFromUrl = parseIdFromUrl; |
@@ -5,14 +5,17 @@ "use strict"; | ||
const global_helper_1 = require("./global.helper"); | ||
exports.getId = (el) => { | ||
const getId = (el) => { | ||
const url = el.querySelector('.navigation a').attributes.href; | ||
return global_helper_1.parseIdFromUrl(url); | ||
}; | ||
exports.getTitle = (el) => { | ||
exports.getId = getId; | ||
const getTitle = (el) => { | ||
return el.querySelector('h1').innerText.split(`(`)[0].trim(); | ||
}; | ||
exports.getGenres = (el) => { | ||
exports.getTitle = getTitle; | ||
const getGenres = (el) => { | ||
const genresRaw = el.querySelector('.genre').text; | ||
return genresRaw.split(' / '); | ||
}; | ||
exports.getOrigins = (el) => { | ||
exports.getGenres = getGenres; | ||
const getOrigins = (el) => { | ||
const originsRaw = el.querySelector('.origin').text; | ||
@@ -22,3 +25,4 @@ const origins = originsRaw.split(',')[0]; | ||
}; | ||
exports.getColorRating = (bodyClasses) => { | ||
exports.getOrigins = getOrigins; | ||
const getColorRating = (bodyClasses) => { | ||
const colorRatingClass = bodyClasses.find((cls) => cls.includes('th')); | ||
@@ -38,3 +42,4 @@ switch (colorRatingClass) { | ||
}; | ||
exports.getRating = (el) => { | ||
exports.getColorRating = getColorRating; | ||
const getRating = (el) => { | ||
const ratingRaw = el.querySelector('#rating .average').text; | ||
@@ -48,6 +53,8 @@ if (ratingRaw !== '') { | ||
}; | ||
exports.getYear = (el) => { | ||
exports.getRating = getRating; | ||
const getYear = (el) => { | ||
return el.querySelector('.origin span').innerText; | ||
}; | ||
exports.getOtherTitles = (el) => { | ||
exports.getYear = getYear; | ||
const getOtherTitles = (el) => { | ||
const namesNode = el.querySelectorAll('ul.names li'); | ||
@@ -68,9 +75,12 @@ return namesNode.map((el) => { | ||
}; | ||
exports.getPoster = (el) => { | ||
exports.getOtherTitles = getOtherTitles; | ||
const getPoster = (el) => { | ||
return el.querySelector('#poster img').attributes.src; | ||
}; | ||
exports.getDescriptions = (el) => { | ||
exports.getPoster = getPoster; | ||
const getDescriptions = (el) => { | ||
return el.querySelectorAll('#plots ul li').map((desc) => desc.text.trim()); | ||
}; | ||
exports.getDirectors = (el) => { | ||
exports.getDescriptions = getDescriptions; | ||
const getDirectors = (el) => { | ||
const creators = el.querySelectorAll('.creators span'); | ||
@@ -80,3 +90,4 @@ const directorsSpan = creators.filter((creator) => creator.attributes.itemprop === 'director')[0]; | ||
}; | ||
exports.parsePeople = (el) => { | ||
exports.getDirectors = getDirectors; | ||
const parsePeople = (el) => { | ||
const people = el.querySelectorAll('a'); | ||
@@ -91,3 +102,4 @@ return people.map((person) => { | ||
}; | ||
exports.getGroup = (el, group) => { | ||
exports.parsePeople = parsePeople; | ||
const getGroup = (el, group) => { | ||
const creators = el.querySelectorAll('.creators h4'); | ||
@@ -102,3 +114,4 @@ const element = creators.filter((elem) => elem.text.trim().includes(group))[0]; | ||
}; | ||
exports.getType = (el) => { | ||
exports.getGroup = getGroup; | ||
const getType = (el) => { | ||
var _a; | ||
@@ -108,5 +121,7 @@ const type = el.querySelector('.film-type'); | ||
}; | ||
exports.getTags = (el) => { | ||
exports.getType = getType; | ||
const getTags = (el) => { | ||
const tagsRaw = el.querySelectorAll('.tags .content a'); | ||
return tagsRaw.map((elem) => elem.text.trim()); | ||
}; | ||
exports.getTags = getTags; |
@@ -5,7 +5,8 @@ "use strict"; | ||
const global_helper_1 = require("./global.helper"); | ||
exports.getId = (el) => { | ||
const getId = (el) => { | ||
const url = el.querySelector('td a.film').rawAttributes.href; | ||
return global_helper_1.parseIdFromUrl(url); | ||
}; | ||
exports.getUserRating = (el) => { | ||
exports.getId = getId; | ||
const getUserRating = (el) => { | ||
const ratingText = el.querySelector('td .rating').attributes.alt; | ||
@@ -15,23 +16,30 @@ const rating = ratingText ? ratingText.length : 0; | ||
}; | ||
exports.getType = (el) => { | ||
exports.getUserRating = getUserRating; | ||
const getType = (el) => { | ||
const typeText = el.querySelector('td .film-type'); | ||
return (typeText ? typeText.innerText.slice(1, -1) : 'film'); | ||
}; | ||
exports.getTitle = (el) => { | ||
exports.getType = getType; | ||
const getTitle = (el) => { | ||
return el.querySelector('td .film').text; | ||
}; | ||
exports.getYear = (el) => { | ||
exports.getTitle = getTitle; | ||
const getYear = (el) => { | ||
return +el.querySelector('td .film-year').innerText.slice(1, -1); | ||
}; | ||
exports.getColorRating = (el) => { | ||
exports.getYear = getYear; | ||
const getColorRating = (el) => { | ||
return exports.parseColor(+el.querySelector('td a.film').classNames[1].slice(1, 2)); | ||
}; | ||
exports.getDate = (el) => { | ||
exports.getColorRating = getColorRating; | ||
const getDate = (el) => { | ||
return el.querySelectorAll('td')[2].rawText; | ||
}; | ||
exports.getUrl = (el) => { | ||
exports.getDate = getDate; | ||
const getUrl = (el) => { | ||
const url = el.querySelector('td a.film').rawAttributes.href; | ||
return `https://www.csfd.cz${url}`; | ||
}; | ||
exports.parseColor = (quality) => { | ||
exports.getUrl = getUrl; | ||
const parseColor = (quality) => { | ||
switch (quality) { | ||
@@ -50,1 +58,2 @@ case 0: | ||
}; | ||
exports.parseColor = parseColor; |
{ | ||
"name": "node-csfd-api", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Simple NPM library for scraping CSFD", | ||
@@ -23,3 +23,3 @@ "main": "./index.js", | ||
"cross-fetch": "^3.0.6", | ||
"node-html-parser": "^1.4.9" | ||
"node-html-parser": "^2.0.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "repository": { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.movieUrl = exports.userRatingsUrl = void 0; | ||
exports.userRatingsUrl = (user) => `https://www.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/`; | ||
exports.movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}`; | ||
const userRatingsUrl = (user) => `https://www.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/`; | ||
exports.userRatingsUrl = userRatingsUrl; | ||
const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}`; | ||
exports.movieUrl = movieUrl; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25230
478
+ Addednode-html-parser@2.2.1(transitive)
- Removednode-html-parser@1.4.9(transitive)
Updatednode-html-parser@^2.0.0