Fix folder creation
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Michel Roux 2021-06-12 00:13:15 +02:00
parent dbe61e793c
commit 2795609ec9
2 changed files with 14 additions and 7 deletions

View File

@ -1,9 +1,14 @@
const fs = require('fs')
const cheerio = require('cheerio')
const fetch = require('node-fetch')
const epub = require('epub-gen')
const books = []
if (!fs.existsSync('output')) {
fs.mkdirSync('output')
}
const metadata = (volume) => ({
title: `The Wandering Inn - Volume ${volume}`,
author: ['Pirateaba'],

View File

@ -1,3 +1,4 @@
const fs = require('fs')
const cheerio = require('cheerio')
const fetch = require('node-fetch')
const epub = require('epub-gen')
@ -7,6 +8,10 @@ let page = 0
const MAX_VOLUME = 3
const books = []
if (!fs.existsSync('output')) {
fs.mkdirSync('output')
}
const volume = (post) => post <= 69 ? 1 : post <= 168 ? 2 : MAX_VOLUME
const metadata = (volume) => ({
@ -24,7 +29,7 @@ const metadata = (volume) => ({
})
for (let i = 0; i <= MAX_VOLUME; i++) {
books.push(metadata(i))
books.push(metadata(i + 1))
}
(async () => {
@ -41,17 +46,14 @@ for (let i = 0; i <= MAX_VOLUME; i++) {
if (++post === 1) return
const title = html('div[align=center]', el)
if (title.html() === null) return
let text = html('div > div', el)
text = html(text).attr('style', '')
const titleText = title.first().html()
.replace(/<br>/g, ' ')
.replace(/<(\/|)strong>/g, '')
.replace(/\*/g, '')
const titleFirst = title.first()
titleFirst.find('br').replaceWith(' ')
const titleText = titleFirst.text().replace(/\*/g, '')
console.log(`${post} - ${titleText}`)