Craw light novel from [哔哩轻小说(linovelib)](https://w.linovelib.com/) and convert to epub.
Project description
linovelib2epub
Crawl light novel from 哔哩轻小说(linovelib) and convert to epub.
Features
- flexible
has_illustration
anddivide_volume
option for epub output - built-in http request retry mechanism to improve network fault tolerance
- built-in random browser user_agent through fake_useragent library
- built-in strict integrity check about image download
- built-in mechanism for saving temporary book data by pickle library
- use multi-process to download images
- support add custom css style to epub
Usage
install from source
- clone this repo
git clone https://github.com/lightnovel-center/linovelib2epub.git
- set up a clean local python venv
See also: creating-virtual-environments
replace py
with your real python command if needed. e.g. python
or python3
.
# new a venv
py -m venv venv
# activate venv
.\venv\Scripts\activate
# install dependencies
py -m pip install -r requirements.txt
# install this package in local
# under project root folder: linovelib2epub/
python -m pip install -e .
- Now you can use this package as a pypi remote package.
from linovelib2epub.linovel import Linovelib2Epub
# warning!: must run within __main__ module guard due to process spawn issue.
if __name__ == '__main__':
linovelib_epub = Linovelib2Epub(book_id=3279)
linovelib_epub.run()
install from pypi
- Install this package from pypi:
pip install linovelib2epub
- create a python file and edit the content as follows:
from linovelib2epub.linovel import Linovelib2Epub
# warning!: must run within __main__ module guard due to process spawn issue.
if __name__ == '__main__':
linovelib_epub = Linovelib2Epub(book_id=3279)
linovelib_epub.run()
If it finished without errors, you can see the epub file is under the folder where your python file is located.
Options
Parameters | type | required | default | description |
---|---|---|---|---|
book_id | number | YES | None | 书籍ID。 |
base_url | string | NO | 'https://w.linovelib.com/novel' | 哔哩轻小说主页URL |
divide_volume | boolean | NO | False | 是否分卷 |
has_illustration | boolean | NO | True | 是否下载插图 |
image_download_folder | string | NO | "images" | 图片下载临时文件夹. 不允许以相对路径../开头。 |
pickle_temp_folder | string | NO | "pickle" | pickle临时数据保存的文件夹。 |
http_timeout | number | NO | 10 | 一个HTTP请求的超时等待时间(秒)。代表connect和read timeout。 |
http_retries | number | NO | 5 | 当一个HTTP请求失败后,重试的最大次数。 |
http_cookie | string | NO | '' | 自定义HTTP cookie。 |
custom_style_cover | string | NO | '' | 自定义cover.xhtml的样式 |
custom_style_nav | string | NO | '' | 自定义nav.xhtml的样式 |
custom_style_chapter | string | NO | '' | 自定义每章(?.xhtml)的样式 |
disable_proxy | boolean | NO | True | 是否禁用所在的代理环境,默认禁用 |
Todo
- (docs) add gif demo for preview
- (refactor) use multi-thread or asyncio coroutine to download images
- (refactor) refactor code to several abstract level(user-input/http/crawl/write ebook)
- (improvement) logging level info or succinct
- (feat) enable a download certain chapter of one book.
- refer: playground/test_rich/rich_prompt.py
- (quality) setup pytests and codecov
- (chore) support more data provider:
- lightnovel 轻之国度
- https://www.wenku8.net/ 轻小说文库 (简/繁) 【插图清晰度高】
- https://lnovel.org/ 轻小说百科(简/繁)【插图清晰度低】
- https://www.8novel.com/ 无限轻小说(繁)【插图清晰度高】
Contributors
GokouRuri 🐛 💻 |
Acknowledgements
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for linovelib2epub-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcb5c661bb00410700fc0f7a12e5a6087eb5094241175a5491aa3f97430942dd |
|
MD5 | 0f6e06464421d861be3f01a273afe0a1 |
|
BLAKE2b-256 | 73df698004adaec385f279d5ea66750dd7e41a5b1bc41e55107f87eaf78ca0c3 |