First draft
This commit is contained in:
commit
7a15460cea
43
.drone.yml
Normal file
43
.drone.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
type: docker
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: flake8
|
||||||
|
image: python:slim
|
||||||
|
commands:
|
||||||
|
- pip install flake8
|
||||||
|
- flake8
|
||||||
|
- name: epub
|
||||||
|
image: python:slim
|
||||||
|
commands:
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
- python livres_fr.py
|
||||||
|
- python livres_en.py
|
||||||
|
- name: pdf
|
||||||
|
image: svensp/ebook-convert
|
||||||
|
commands:
|
||||||
|
- ebook-convert "output/L'auberge Vagabonde - Volume 1.epub" "output/L'auberge Vagabonde - Volume 1.pdf"
|
||||||
|
- ebook-convert "output/L'auberge Vagabonde - Volume 2.epub" "output/L'auberge Vagabonde - Volume 2.pdf"
|
||||||
|
- ebook-convert "output/The Wandering Inn - Volume 3.epub" "output/The Wandering Inn - Volume 3.pdf"
|
||||||
|
- ebook-convert "output/The Wandering Inn - Volume 4.epub" "output/The Wandering Inn - Volume 4.pdf"
|
||||||
|
- ebook-convert "output/The Wandering Inn - Volume 5.epub" "output/The Wandering Inn - Volume 5.pdf"
|
||||||
|
- ebook-convert "output/The Wandering Inn - Volume 6.epub" "output/The Wandering Inn - Volume 6.pdf"
|
||||||
|
- ebook-convert "output/The Wandering Inn - Volume 7.epub" "output/The Wandering Inn - Volume 7.pdf"
|
||||||
|
- name: upload
|
||||||
|
image: curlimages/curl
|
||||||
|
commands:
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/L'auberge Vagabonde - Volume 1.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/L'auberge Vagabonde - Volume 1.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/L'auberge Vagabonde - Volume 1.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/L'auberge Vagabonde - Volume 1.pdf"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/L'auberge Vagabonde - Volume 2.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/L'auberge Vagabonde - Volume 2.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/L'auberge Vagabonde - Volume 2.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/L'auberge Vagabonde - Volume 2.pdf"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 3.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 3.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 3.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 3.pdf"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 4.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 4.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 4.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 4.pdf"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 5.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 5.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 5.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 5.pdf"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 6.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 6.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 6.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 6.pdf"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 7.epub" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 7.epub"
|
||||||
|
- curl -Ss -u "$USER":"$PASS" -T "output/The Wandering Inn - Volume 7.pdf" "https://cloud.crystalyx.net/remote.php/dav/files/$USER/Public/TWI/The Wandering Inn - Volume 7.pdf"
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.idea
|
||||||
|
.venv
|
||||||
|
output
|
52
livres_en.py
Normal file
52
livres_en.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from pypub import Epub, create_chapter_from_string
|
||||||
|
|
||||||
|
if not os.path.exists('output'):
|
||||||
|
os.makedirs('output')
|
||||||
|
|
||||||
|
html = requests.get('https://wanderinginn.com/table-of-contents/')
|
||||||
|
soup = BeautifulSoup(html.text, 'html.parser')
|
||||||
|
|
||||||
|
tags = soup.select('div.entry-content > p')
|
||||||
|
proceed = True
|
||||||
|
volume = 0
|
||||||
|
volumes = [None, None, None]
|
||||||
|
|
||||||
|
for volume_tag in tags:
|
||||||
|
if not proceed:
|
||||||
|
proceed = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if 'Volume' in volume_tag.get_text() and int(volume_tag.get_text().replace('Volume ', '')) < 3:
|
||||||
|
proceed = False
|
||||||
|
continue
|
||||||
|
|
||||||
|
if 'Volume' in volume_tag.get_text():
|
||||||
|
volume = int(volume_tag.get_text().replace('Volume ', ''))
|
||||||
|
volumes.append(Epub("The Wandering Inn - Volume %d" % volume, cover='cover.png'))
|
||||||
|
continue
|
||||||
|
|
||||||
|
for link_tag in volume_tag:
|
||||||
|
if link_tag.name == 'a':
|
||||||
|
chapter = requests.get(link_tag['href'])
|
||||||
|
chapter_soup = soup = BeautifulSoup(chapter.text, 'html.parser')
|
||||||
|
|
||||||
|
title = chapter_soup.select_one('h1.entry-title').get_text()
|
||||||
|
text = chapter_soup.select_one('div.entry-content')
|
||||||
|
|
||||||
|
for pagination in text.find_all('a'):
|
||||||
|
pagination.decompose()
|
||||||
|
|
||||||
|
print(title)
|
||||||
|
|
||||||
|
chapter = create_chapter_from_string(str(text), title)
|
||||||
|
volumes[volume].add_chapter(chapter)
|
||||||
|
|
||||||
|
for ebook in volumes:
|
||||||
|
if ebook is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
ebook.create_epub('output')
|
51
livres_fr.py
Normal file
51
livres_fr.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from pypub import Epub, create_chapter_from_string
|
||||||
|
|
||||||
|
if not os.path.exists('output'):
|
||||||
|
os.makedirs('output')
|
||||||
|
|
||||||
|
post = 0
|
||||||
|
volumes = [
|
||||||
|
None,
|
||||||
|
Epub("L'auberge Vagabonde - Volume 1", cover='cover.png'),
|
||||||
|
Epub("L'auberge Vagabonde - Volume 2", cover='cover.png')
|
||||||
|
]
|
||||||
|
|
||||||
|
for page in range(12):
|
||||||
|
html = requests.get(
|
||||||
|
'https://www.jeunesecrivains.com/t53075p%s-the-wandering-inn-fan-traduction-fantastique-aventure' % (page * 15))
|
||||||
|
soup = BeautifulSoup(html.text, 'html.parser')
|
||||||
|
tags = soup.select('div.postbody')
|
||||||
|
|
||||||
|
for tag in tags:
|
||||||
|
post = post + 1
|
||||||
|
volume = 1 if post <= 69 else 2
|
||||||
|
|
||||||
|
if post == 1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
title_test = tag.div.select_one('div[align=center]')
|
||||||
|
|
||||||
|
if not title_test:
|
||||||
|
continue
|
||||||
|
|
||||||
|
title = title_test.contents[0]
|
||||||
|
title_test.decompose()
|
||||||
|
|
||||||
|
text = tag.div.div
|
||||||
|
|
||||||
|
if text.get_text() == '':
|
||||||
|
text = tag.div
|
||||||
|
|
||||||
|
del text['style']
|
||||||
|
|
||||||
|
print(title)
|
||||||
|
|
||||||
|
chapter = create_chapter_from_string(str(text), title)
|
||||||
|
volumes[volume].add_chapter(chapter)
|
||||||
|
|
||||||
|
volumes[1].create_epub('output')
|
||||||
|
volumes[2].create_epub('output')
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
requests==2.25.1
|
||||||
|
beautifulsoup4==4.9.3
|
||||||
|
git+git://github.com/Xefir/pypub@fix/py3#egg=pypub
|
Reference in New Issue
Block a user