UNPKG

bedetheque-scraper

Version:

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

47 lines (46 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("./utils"); // image: https://www.bedetheque.com/media/Photos/${image} var Author = /** @class */ (function () { function Author($) { var info = $('.auteur-info').text(); var match = info.match(/Identifiant :([0-9]+)/); this.authorId = match ? parseInt(match[1], 10) : null; this.name = $('.auteur-nom').text(); this.image = this.getImage($); match = info.match(/Naissance :le ([0-9]+\/[0-9]+\/[0-9]+)/); this.birthDate = match ? match[1] : null; match = info.match(/Décès :le ([0-9]+\/[0-9]+\/[0-9]+)/); this.deathDate = match ? match[1] : null; var series = $('table') .filter(function (i, e) { return $(e).find('thead #tri0').text() === 'Séries principales'; }) .find('tbody tr') .filter(function (i, e) { return $(e).find('img').attr('src') === 'https://www.bdgest.com/skin/flags/France.png'; }); this.seriesIdBoth = this.getSeriesId($, series, true, true); this.seriesIdScenario = this.getSeriesId($, series, true, false); this.seriesIdDrawing = this.getSeriesId($, series, false, true); } Author.prototype.getSeriesId = function ($, series, isScen, isDraw) { return series.filter(function (i, e) { var icons = $(e).find('.parution i'); var scen = isScen ? icons.hasClass('icon-scen') : !icons.hasClass('icon-scen'); var draw = isDraw ? icons.hasClass('icon-dess') : !icons.hasClass('icon-dess'); return scen && draw; }) .map(function (i, e) { return $(e).find('.serie a').attr('href'); }) .get() .map(function (url) { return utils_1.Utils.urlToSerieID(url); }); }; Author.prototype.getImage = function ($) { var image = $('.auteur-image img').attr('src'); if (!image) return null; return image !== 'https://www.bdgest.com/skin/nophoto.png' ? image.replace('https://www.bedetheque.com/media/Photos/', '') : null; }; return Author; }()); exports.Author = Author;