UNPKG

bedetheque-scraper

Version:

NodeJS script to scrap the entire database of dbgest.com / bedetheque.com (approx. 260.000+ albums)

28 lines (27 loc) 948 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Serie = /** @class */ (function () { function Serie($) { this.serieId = parseInt($('.idbel').text(), 10); this.serieTitle = $('h1 a').text(); } Serie.prototype.addAlbumsInfo = function (albums) { var _a; this.albumsId = albums.map(function (album) { return album.albumId; }); _a = this.getVoteAverage(albums), this.voteAverage = _a[0], this.voteCount = _a[1]; }; Serie.prototype.getVoteAverage = function (albums) { var voteAverage = 0; var voteCount = 0; albums.forEach(function (album) { voteAverage += album.voteAverage * album.voteCount; voteCount += album.voteCount; }); if (voteCount === 0) { return [0, 0]; } return [voteAverage / voteCount, voteCount]; }; return Serie; }()); exports.Serie = Serie;