Compare commits

..

No commits in common. "31f1f792f4a02ad614c2c42a8769db3d3c30ab2e" and "e5e7cf914d9e7af058d6dcb27798e313a9416d0e" have entirely different histories.

3 changed files with 84 additions and 28 deletions

View File

@ -4,13 +4,14 @@ type: docker
steps:
- name: epub
image: node
image: node:14.17.5
commands:
- npm i
- ./node_modules/.bin/eslint *.js
- node livres
- node livres_fr
- node livres_en
- name: pdf
image: linuxserver/calibre
image: linuxserver/calibre:v5.23.0-ls121
commands:
- bash -x convert.sh
- bash -x upload.sh

View File

@ -3,23 +3,24 @@ 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, author, tocTitle, description) => ({
title: `${title} - Volume ${volume}`,
author,
const metadata = (volume) => ({
title: `The Wandering Inn - Volume ${volume}`,
author: ['Pirateaba'],
cover: 'https://i.pinimg.com/originals/0b/fd/cf/0bfdcfb42ba3ff0a22f4a7bc52928af4.png',
output: `output/${title} - Volume ${volume}.epub`,
output: `output/The Wandering Inn - Volume ${volume}.epub`,
version: 3,
lang: 'fr',
tocTitle,
lang: 'en',
appendChapterTitles: true,
content: [],
links: [],
verbose: true,
description,
description: 'A tale of a girl, an inn, and a world full of levels',
})
const fetchPage = async (url) => {
@ -41,23 +42,18 @@ const fetchPage = async (url) => {
}
}
const run = async (url, authors) => {
const books = []
const response = await fetch(url)
(async () => {
const response = await fetch('https://wanderinginn.com/table-of-contents/')
const responseHtml = await response.text()
const html = cheerio.load(responseHtml)
const content = html('div.entry-content > p')
const title = html('#site-title > span > a').text()
const summary = html('h1.entry-title').text()
const description = html('#site-description').text()
let volume = 0;
content.each((i, el) => {
if (i % 2 === 0) {
volume = html(el).text().replace(/Volume /, '').trim()
if (volume === '') return
books.push(metadata(volume, title, authors, summary, description))
books.push(metadata(volume))
} else {
html('a', el).each((i, el) => {
books[volume - 1].links.push(html(el).attr('href'))
@ -72,13 +68,4 @@ const run = async (url, authors) => {
new epub(book)
})
}
run(
'https://aubergevagabonde.wordpress.com/sommaire/',
['Maroti', 'ElliVia', 'Pirateaba']
)
run(
'https://wanderinginn.com/table-of-contents/',
['Pirateaba']
)
})()

68
livres_fr.js Normal file
View File

@ -0,0 +1,68 @@
const fs = require('fs')
const cheerio = require('cheerio')
const fetch = require('node-fetch')
const epub = require('epub-gen')
let post = 0
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) => ({
title: `L'auberge Vagabonde - Volume ${volume}`,
author: ['Maroti', 'ElliVia', 'Pirateaba'],
cover: 'https://i.pinimg.com/originals/0b/fd/cf/0bfdcfb42ba3ff0a22f4a7bc52928af4.png',
output: `output/L'auberge Vagabonde - Volume ${volume}.epub`,
version: 3,
lang: 'fr',
tocTitle: 'Table des matières',
appendChapterTitles: true,
content: [],
verbose: true,
description: "L'histoire d'une fille, d'une auberge et d'un monde plein de niveaux",
})
for (let i = 1; i <= MAX_VOLUME; i++) {
books.push(metadata(i))
}
(async () => {
while (true) {
const response = await fetch(`https://www.jeunesecrivains.com/t53075p${page++ * 15}-the-wandering-inn-fan-traduction-fantastique-aventure`)
const responseHtml = await response.text()
const html = cheerio.load(responseHtml)
const postBody = html('div.postbody')
if (postBody.html() === null) break
postBody.each((i, el) => {
if (++post === 1) return
const title = html('div[align=center]', el)
if (title.html() === null) return
let text = html('div > div', el)
text.attr('style', '')
const titleFirst = title.first()
titleFirst.find('br').replaceWith(' ')
const titleText = titleFirst.text().replace(/\*/g, '')
titleFirst.empty()
console.log(`${post} - ${titleText}`)
books[volume(post) - 1].content.push({
title: titleText,
data: text.html(),
})
})
}
books.map(book => new epub(book))
})()