1 个不稳定版本
0.1.0 | 2022 年 6 月 27 日 |
---|
#17 在 #manga
20KB
322 行
TCBScans 漫画查看器
检索输入章节和系列数据的漫画章节。也可以通过此工具检索系列和章节 ID。
免责声明:我不是 TCBScans 或 Viz Media 的授权或附属机构,此仓库仅供信息用途。请在阅读后删除检索到的页面。
安装
// Cargo.toml
[dependencies]
tcbscans = "0.1.0"
用法
可用方法
series::get_series()
:从 TCBScans 获取可用系列列表。chapters::get_chapters(...)
:获取系列的所有可用章节。manga::get_pages(...)
:从系列中检索章节的所有页面链接。download::save_chapter_pages(...)
:保存章节的漫画页面图片。
系列模块
series
模块负责查找 TCBScans 支持的所有系列。返回的 id
和 slug
参数可用于检索章节和漫画信息。
示例
use tcbscans::series::{self, Series};
let all_series: Vec<Series> = series::get_series();
for s in all_series {
println!("{:?}", &s);
}
结果
Series { id: "1", name: "Ace Novel - Manga Adaptation", slug: "ace-novel-manga-adaptation" }
Series { id: "8", name: "Attack on Titan", slug: "attack-on-titan" }
Series { id: "3", name: "Black Clover", slug: "black-clover" }
章节模块
chapters
模块负责查找系列的所有可用章节。对 chapters::get_chapters(..)
的选项
series_obj: &series::Series
= 要查找的Series
对象,主要包含slug
。其他字段可选用于报告。
示例
use tcbscans::series:Series;
use tcbscans::chapters::{self, Chapter};
let aot: Series = Series {
id: "8", name: "Attack on Titan", slug: "attack-on-titan"
};
let all_chapters: Vec<Chapter> = chapters::get_chapters(&aot);
for chapter in all_chapters {
println!("{:?}", &chapter);
}
结果
Chapter { id: "30", name: "Attack on Titan Chapter 139: Moving Towards that Tree on the Hill", slug: "attack-on-titan-chapter-139" }
漫画模块
manga
模块负责查找系列中章节的所有页面链接。对 manga::get_pages(...)
的选项是
章节: &chapters::Chapter
= 用于查找章节页面的Chapter
对象,主要包含章节的 slug。其他字段可选用于报告。
示例
use tcbscans::chapters::Chapter;
use tcbscans::manga;
let aot: Chapter = Chapter {
id: "", name: "", slug: "attack-on-titan-chapter-139"
};
let all_pages: Vec<String> = manga::get_pages(&aot);
for link in all_pages {
println!("{}", &link);
}
结果
https://cdn.onepiecechapters.com/file/CDN-M-A-N/aotv2_139_vol_01.png
https://cdn.onepiecechapters.com/file/CDN-M-A-N/aotv2_139_vol_02.png
https://cdn.onepiecechapters.com/file/CDN-M-A-N/aotv2_139_vol_03.png
下载模块
download
模块负责下载和最小化章节页面。章节页面将被下载到以章节 slug
命名的文件夹中。图片最小化使用 imagequant
crate。save_chapter_pages(...)
的选项包括
章节: &chapters::Chapter
= 用于查找章节页面,主要包含章节的 slug。其他字段可选用于报告。directory: &str
= 保存所有章节页面的父目录。在这个目录中将会创建一个以章节 slug 命名的文件夹。如果章节目录已创建,则章节不会重新下载。
示例
use tcbscans::chapters::Chapter;
use tcbscans::download;
let aot: Chapter = Chapter {
id: "", name: "", slug: "attack-on-titan-chapter-139"
};
let dir = "images/";
download::save_chapter_pages(&aot, dir);
结果
images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page28.png
images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page42.png
images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page49.png
命令行界面(CLI)使用方法
此 crate 还包含一个 CLI 工具,用于探索 TCBScans 数据。
Download manga chapters from TCBScans
USAGE:
tcbscans <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
-V, --version Print version information
SUBCOMMANDS:
chapters List all chapters for a supported series
help Print this message or the help of the given subcommand(s)
manga Save an entire chapter to disk
series List all supported series
获取系列
>>> tcbscans series
{"id":"1","name":"Ace Novel - Manga Adaptation","slug":"ace-novel-manga-adaptation"}
{"id":"8","name":"Attack on Titan","slug":"attack-on-titan"}
{"id":"3","name":"Black Clover","slug":"black-clover"}
获取章节
>>> tcbscans chapters --help
List all chapters for a supported series
USAGE:
tcbscans chapters [OPTIONS]
OPTIONS:
--download <DOWNLOAD> Download all chapters of the series to a directory
-h, --help Print help information
-i, --id <ID> Id of the series
-s, --slug <SLUG> Slug name of the series
>>> tcbscans chapters --id 8
{"id":"30","name":"Attack on Titan Chapter 139: Moving Towards that Tree on the Hill","slug":"attack-on-titan-chapter-139"}
下载漫画
>>> tcbscans manga --help
Save an entire chapter to disk
USAGE:
tcbscans manga [OPTIONS] <SERIES> <DIRECTORY>
ARGS:
<SERIES> Slug name of the series
<DIRECTORY> Directory to save the chapter
OPTIONS:
-h, --help Print help information
-i, --id <ID> Id of the chapter
-s, --slug <SLUG> Slug name of the chapter
>>> tcbscans manga attack-on-titan --id 30 images/
images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page28.png
images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page42.png
images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page49.png
Docker
CLI 可以通过 Docker 容器构建和运行。预构建的容器可以在以下位置找到: https://hub.docker.com/repository/docker/minormending/tcbscans
>>> docker build -t tcbscans .
>>> docker run -v /home/user/images/:/images/:rw tcbscans manga attack-on-titan --id 30 /images/
/images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page28.png
/images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page42.png
/images/attack-on-titan-chapter-139/attack-on-titan-chapter-139-page49.png
依赖项
~6.5–8.5MB
~157K SLoC