@rexxhayanasi/nhentai
Version:
A scraper for NHentai with types
42 lines (41 loc) • 1.74 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.List = void 0;
const axios_1 = __importDefault(require("axios"));
const cheerio_1 = require("cheerio");
const Parser_1 = require("../../Parser");
class List {
constructor(title, id, cover, url) {
this.title = title;
this.id = id;
this.cover = cover;
this.url = url;
}
/**
* Gets the contents of a doujin
* @returns The contents of the doujin
*/
getContents() {
return __awaiter(this, void 0, void 0, function* () {
return yield axios_1.default
.get(this.url)
.then(({ data }) => (0, Parser_1.parseDoujinInfo)((0, cheerio_1.load)(data), this.url.split('nhentai.')[1].split('/')[0]))
.catch((err) => {
throw new Error(err.message);
});
});
}
}
exports.List = List;