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: steps:
- name: epub - name: epub
image: node image: node:14.17.5
commands: commands:
- npm i - npm i
- ./node_modules/.bin/eslint *.js - ./node_modules/.bin/eslint *.js
- node livres - node livres_fr
- node livres_en
- name: pdf - name: pdf
image: linuxserver/calibre image: linuxserver/calibre:v5.23.0-ls121
commands: commands:
- bash -x convert.sh - bash -x convert.sh
- bash -x upload.sh - bash -x upload.sh

View File

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