项目文档优化、文档网站重构并改用material主题。(#250)

This commit is contained in:
hect0x7 2024-06-15 02:40:06 +08:00 committed by GitHub
parent 3c0a27bd19
commit 826be95865
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 136 additions and 162 deletions

107
README.md
View File

@ -12,24 +12,26 @@
## 项目介绍
本项目的核心功能是下载本子,基于此,设计了一套方便使用、便于扩展,能满足一些特殊下载需求的框架。
本项目的核心功能是下载本子。
基于此,设计了一套方便使用、便于扩展,能满足一些特殊下载需求的框架。
目前核心功能实现较为稳定,项目也处于维护阶段。
除了下载功能以外,也实现了其他的一些禁漫接口,按需实现,具体如下。
### 已实现的禁漫API
除了下载功能以外,也实现了其他的一些禁漫接口,按需实现。目前已有功能:
- 登录
- 搜本
- 分类 (排行榜)
- 本子章节详情
- 搜索本子(支持所有搜索项)
- 图片下载解码
- 收藏夹
- 移动端接口加解密
- 分类/排行榜
- 本子/章节详情
- 个人收藏夹
- 接口加解密APP的接口
## 安装教程
> ⚠如果你没有安装过Python需要先安装Python再执行下面的步骤且版本需要>=3.7[点我去python官网下载](https://www.python.org/downloads/)
* 通过pip官方源安装推荐并且更新也是这个命令
```shell
@ -44,7 +46,9 @@
## 快速上手
### 1. 下载本子方法
只需要使用如下代码,就可以下载本子`JM422866`的所有章节的图片:
```python
import jmcomic # 导入此模块,需要先安装.
jmcomic.download_album('422866') # 传入要下载的album的id即可下载整个album到本地.
@ -57,10 +61,10 @@ jmcomic.download_album('422866') # 传入要下载的album的id即可下载
### 2. 使用option配置来下载本子
1. 首先,创建一个配置文件,假设文件名为 `option.yml`
该文件有特定的写法,你需要参考这个文档 → [option配置](./assets/docs/sources/option_file_syntax.md)
下面做一个演示假设你需要把下载的图片转为png格式你应该把以下内容写进`option.yml`
该文件有特定的写法,你需要参考这个文档 → [配置文件指南](./assets/docs/sources/option_file_syntax.md)
下面做一个演示假设你需要把下载的图片转为png格式你应该把以下内容写进`option.yml`
```yml
download:
@ -69,6 +73,7 @@ download:
```
2. 第二步运行下面的python代码
```python
import jmcomic
@ -76,24 +81,14 @@ import jmcomic
option = jmcomic.create_option_by_file('你的配置文件路径,例如 D:/option.yml')
# 使用option对象来下载本子
jmcomic.download_album(422866, option)
# 等价写法: option.download_album(422866)
```
## 进阶使用
文档网站:[jmcomic.readthedocs.io](https://jmcomic.readthedocs.io/en/latest)
请查阅文档首页→[jmcomic.readthedocs.io](https://jmcomic.readthedocs.io/zh-cn/latest)
首先就下载功能jmcomic提供了很多配置项大部分的下载需求你都可以通过上文介绍的配置文件来配置。
如果你不满足于下载,还有其他的使用需求,推荐你先看看以下文档:
* [jmcomic常用类和方法演示](assets/docs/sources/tutorial/0_demo.md)
* [option配置文件语法包含插件配置](./assets/docs/sources/option_file_syntax.md)
* [GitHub Actions使用教程](./assets/docs/sources/tutorial/1_github_actions.md)
* [命令行使用教程](assets/docs/sources/tutorial/2_command_line.md)
* [插件机制](assets/docs/sources/tutorial/6_plugin.md)
* [下载过滤器机制](assets/docs/sources/tutorial/5_filter.md)
提示jmcomic提供了很多下载配置项大部分的下载需求你都可以尝试寻找相关配置项或插件来实现。
## 项目特点
@ -101,35 +96,35 @@ jmcomic.download_album(422866, option)
- **实现禁漫APP接口最新的加解密算法 (1.6.3)**
- 用法多样:
- GitHub
Actions网页上直接输入本子id就能下载[教程使用GitHub Actions下载禁漫本子](./assets/docs/sources/tutorial/1_github_actions.md)
- 命令行无需写Python代码简单易用[教程:使用命令行下载禁漫本子](./assets/docs/sources/tutorial/2_command_line.md)
- Python代码最本质、最强大的使用方式需要你有一定的python编程基础
- GitHub
Actions网页上直接输入本子id就能下载[教程使用GitHub Actions下载禁漫本子](./assets/docs/sources/tutorial/1_github_actions.md)
- 命令行无需写Python代码简单易用[教程:使用命令行下载禁漫本子](./assets/docs/sources/tutorial/2_command_line.md)
- Python代码最本质、最强大的使用方式需要你有一定的python编程基础
- 支持**网页端**和**移动端**两种客户端实现,可通过配置切换(**移动端不限ip兼容性好网页端限制ip地区但效率高**
- 支持**自动重试和域名切换**机制
- **多线程下载**(可细化到一图一线程,效率极高)
- **可配置性强**
- 不配置也能使用,十分方便
- 配置可以从配置文件生成,支持多种文件格式
- 配置点有:`请求域名` `客户端实现` `是否使用磁盘缓存` `同时下载的章节/图片数量` `图片格式转换` `下载路径规则` `请求元信息headers,cookies,proxies`
- 不配置也能使用,十分方便
- 配置可以从配置文件生成,支持多种文件格式
- 配置点有:`请求域名` `客户端实现` `是否使用磁盘缓存` `同时下载的章节/图片数量` `图片格式转换` `下载路径规则` `请求元信息headers,cookies,proxies`
- **可扩展性强**
- 支持自定义本子/章节/图片下载前后的回调函数
- 支持自定义类:`Downloader负责调度` `Option负责配置` `Client负责请求` `实体类`
- 支持自定义日志、异常监听器
- **支持Plugin插件可以方便地扩展功能以及使用别人的插件目前内置插件有**
- `登录插件`
- `硬件占用监控插件`
- `只下载新章插件`
- `压缩文件插件`
- `下载特定后缀图片插件`
- `发送QQ邮件插件`
- `日志主题过滤插件`
- `自动使用浏览器cookies插件`
- `jpg图片合成为一个pdf插件`
- `导出收藏夹为csv文件插件`
- 支持自定义本子/章节/图片下载前后的回调函数
- 支持自定义类:`Downloader负责调度` `Option负责配置` `Client负责请求` `实体类`
- 支持自定义日志、异常监听器
- **支持Plugin插件可以方便地扩展功能以及使用别人的插件目前内置插件有**
- `登录插件`
- `硬件占用监控插件`
- `只下载新章插件`
- `压缩文件插件`
- `下载特定后缀图片插件`
- `发送QQ邮件插件`
- `日志主题过滤插件`
- `自动使用浏览器cookies插件`
- `jpg图片合成为一个pdf插件`
- `导出收藏夹为csv文件插件`
## 使用小说明
@ -141,13 +136,11 @@ jmcomic.download_album(422866, option)
* .githubGitHub Actions配置文件
* assets存放一些非代码的资源文件
* docs项目文档
* option存放配置文件
* docs项目文档
* option存放配置文件
* src存放源代码
* jmcomic`jmcomic`模块
* jmcomic`jmcomic`模块
* tests测试目录存放测试代码使用unittest
* usage用法目录存放示例/使用代码
@ -155,4 +148,10 @@ jmcomic.download_album(422866, option)
### 图片分割算法代码+禁漫移动端API
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=tonquer&repo=JMComic-qt)](https://github.com/tonquer/JMComic-qt)
<a href="https://github.com/tonquer/JMComic-qt">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github-readme-stats.vercel.app/api/pin/?username=tonquer&repo=JMComic-qt&theme=radical" />
<source media="(prefers-color-scheme: light)" srcset="https://github-readme-stats.vercel.app/api/pin/?username=tonquer&repo=JMComic-qt" />
<img alt="Repo Card" src="https://github-readme-stats.vercel.app/api/pin/?username=tonquer&repo=JMComic-qt" />
</picture>
</a>

View File

@ -1,7 +1,36 @@
repo_url: https://github.com/hect0x7/JMComic-Crawler-Python
site_name: jmcomic
theme:
name: readthedocs
highlightjs: true
palette:
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: 切换到浅色主题
- media: "(prefers-color-scheme: light)"
scheme: default
primary: indigo
accent: indigo
toggle:
icon: material/brightness-7
name: 切换到深色主题
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: indigo
toggle:
icon: material/brightness-4
name: 主题跟随系统
name: material
features:
- navigation.sections
- content.code.copy
- content.code.select
- search.suggest
- search.highlight
- search.share
- navigation.tabs
- navigation.top
plugins:
- search
- mkdocstrings:
@ -14,8 +43,19 @@ plugins:
markdown_extensions:
- markdown_include.include:
base_path: .
- admonition
- attr_list
- toc:
permalink: true
- pymdownx.highlight
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
docs_dir: sources

View File

@ -1,102 +1,39 @@
# jmcomic
首页
=====================================
Python API for JMComic禁漫天堂
## Features
- Bypasses Cloudflare anti-bot measures.
- Multiple usage ways:
> jmcomic库封装了一套可用于爬取禁漫的Python API.
>
> 你可以通过简单的几行Python代码访问禁漫的接口以及下载禁漫的本子。
>
> [查看项目更新计划](TODO.md)
- GitHub Actions: Requires only a GitHub account. (See
tutorial → [Tutorial - Download Album via GitHub Actions](./tutorial/1_github_actions.md))
- Command line: No need to write Python code, simple and easy to use. (See
tutorial → [Tutorial - Download Album via Command Line](./tutorial/2_command_line.md))
- Python code: The most flexible and powerful way, requires some basic knowledge of Python programming.
- Supports two client implementations: web-based and mobile-based. Switchable through configuration (mobile-based has
better IP compatibility, web-based has higher efficiency).
- Supports automatic request retry and domain switching mechanism.
- Multi-threaded downloading (can be fine-tuned to one thread per image, highly efficient).
- Highly configurable:
- Can be used without configuration, very convenient.
- Configuration can be generated from a configuration file, supports multiple file formats.
- Configuration options
include: `request domain`, `client implementation`, `number of chapters/images downloaded simultaneously`, `image format conversion`, `download path rules`, `request metadata (headers, cookies, proxies)`,
and more.
## 入门
- Highly extensible:
- [快速上手(GitHub README)](https://github.com/hect0x7/JMComic-Crawler-Python/tree/master?tab=readme-ov-file#%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B)
- [常用类和方法演示](tutorial/0_common_usage)
- [option配置以及插件写法](./option_file_syntax.md)
- Supports Plugin for easy functionality extension and use of other plugins.
- Currently built-in
plugins: `login plugin`, `hardware usage monitoring plugin`, `only download new chapters plugin`, `zip compression plugin`, `image suffix filter plugin` `send qq email plugin` `logging topic filter plugin` `auto set browser cookies plugin`.
- Supports custom callback functions before and after downloading album/chapter/images.
- Supports custom logging.
- Supports custom core
classes: `Downloader (responsible for scheduling)`, `Option (responsible for configuration)`, `Client (responsible for requests)`, `entity classes`,
and more.
## Install
- Install via official pip source (recommended, and also used for updates):
## 特殊用法教程
- [GitHub Actions使用教程](./tutorial/1_github_actions.md)
- [命令行使用教程](tutorial/2_command_line.md)
- [导出收藏夹教程](tutorial/10_export_favorites.md)
```
pip install jmcomic -i https://pypi.org/project --upgrade
```
- Install via GitHub code:
```
pip install git+https://github.com/hect0x7/JMComic-Crawler-Python
```
## 核心机制
- [下载过滤器机制](tutorial/5_filter.md)
- [插件机制](tutorial/6_plugin.md)
## Getting Started
### 1. Download album:
- Python code
## 自定义
- [下载文件夹名](tutorial/9_custom_download_dir_name.md)
- [日志](tutorial/9_custom_download_dir_name.md)
- [模块](tutorial/4_module_custom.md)
```python
import jmcomic
# Pass the ID of the album you want to download, and it will download all chapters of the album to your local machine.
jmcomic.download_album('422866')
```
- Command line
```
jmcomic 422866
```
### 2. Customize download behavior using an option:
For example, if you want to convert all downloaded images to the .jpg format, you can create a YAML file with the
following content (refer to [option file syntax](./option_file_syntax.md)):
```yml
download:
image:
suffix: .jpg # Don't forget the '.'
```
Then, use one of the following ways:
* Python code
```python
from jmcomic import download_album, create_option
option = create_option('/path/to/your/optionfile')
download_album('422866', option)
```
* Command line
```
jmcomic 422866 --option="/path/to/your/optionfile"
```
## Acknowledgement
### Image Segmentation Algorithm Code + JMComic Mobile API
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=tonquer&repo=JMComic-qt)](https://github.com/tonquer/JMComic-qt)

View File

@ -2,11 +2,9 @@
## 1. 配置前需知
* option有`默认值`当你使用配置文件来创建option时你配置文件中的值会覆盖`默认值`
* option有`默认值`你配置文件中的配置项会覆盖`默认值`。因此你只需要添加感兴趣的配置项即可
因此在配置option时不需要配置全部的值只需要配置特定部分即可。
* 你可以使用下面的代码来得到option的默认值你可以删除其中的大部分配置项只保留你要覆盖的配置项
* 你也可以使用下面的代码来得到option的默认值。你可以删除其中的大部分配置项只保留你要覆盖的配置项。
```python
from jmcomic import JmOption
@ -15,7 +13,7 @@ JmOption.default().to_file('./option.yml') # 创建默认option导出为optio
## 2. option常规配置项
```yml
```yaml
# 开启jmcomic的日志输出默认为true
# 对日志有需求的可进一步参考文档 → https://jmcomic.readthedocs.io/en/latest/tutorial/11_log_custom/
log: true
@ -110,7 +108,7 @@ dir_rule:
* **插件配置中的kwargs参数支持引用环境变量语法为 ${环境变量名}**
```yml
```yaml
# 插件的配置示例
plugins:
after_init:

View File

@ -1,4 +1,4 @@
# jmcomic 常用类和方法演示
# 常用类和方法
## 下载本子/章节

View File

@ -15,7 +15,7 @@ disable_jm_log()
使用配置:
```yml
```yaml
log: false
```
@ -23,7 +23,7 @@ log: false
使用插件配置
```yml
```yaml
log: true
plugins:
@ -40,7 +40,7 @@ plugins:
给插件配置加上一个`log`配置项即可
```yml
```yaml
plugins:
after_init:
- plugin: client_proxy # 提高移动端的请求效率的插件

View File

@ -1,4 +1,4 @@
# GitHub Actions教程
# GitHub Actions使用教程
一共需要三步:

View File

@ -1,4 +1,4 @@
# jmcomic 模块自定义
# 模块自定义

View File

@ -20,7 +20,7 @@ plugin的机制为可在`特定时间` 回调 `特定插件`。
首先你需要在option配置文件当中配置如下内容来实现在after_init时调用login插件。
```yml
```yaml
plugins:
after_init: # 时机
- plugin: login # 插件的key
@ -69,7 +69,7 @@ JmModuleConfig.register_plugin(MyPlugin)
接下来在option中配置如下内容来使用你的插件
```yml
```yaml
# 3. 在配置文件中使用plugin
plugins:
after_init: # 时机

View File

@ -20,7 +20,7 @@ create_option('myoption.yml')
```
#### 2. 配置option调用1的脚本即可
```yml
```yaml
dir_rule: # 下载路径规则
rule: Bd_Aid
base_dir: D:/jmcomic

View File

@ -8,7 +8,7 @@
你可以使用配置文件定制DirRule例如下面的例子
```yml
```yaml
dir_rule:
base_dir: D:/a/b/c/
# 规则含义: 根目录 / 章节标题 / 图片文件
@ -36,7 +36,7 @@ D:/a/b/c/ddd/00003.webp
1. 给你的自定义字段取个名
```yml
```yaml
dir_rule: # 忽略base_dir配置项
rule: Bd_Amyname # A表示本子myname表示本子的一个自定义字段
```
@ -102,7 +102,7 @@ JmModuleConfig.PFIELD_ADVICE['myname'] = lambda photo: f'【{photo.id}】{photo.
### 文件夹名=第x话+标题
```yml
```yaml
# 直接使用内置字段 indextitle 即可
dir_rule:
rule: Bd_Pindextitle