Skip to content

Commit

Permalink
更新 0.2.0!
Browse files Browse the repository at this point in the history
- 修复了若干Bug
- 更新了依赖
- 大幅度优化网络连接
- 加入--range和--group功能
  • Loading branch information
lihe07 committed Jun 15, 2022
1 parent 97cbbdd commit ae7b159
Show file tree
Hide file tree
Showing 8 changed files with 699 additions and 317 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bcdown"
version = "0.1.7"
version = "0.2.0"
edition = "2021"
authors = ["lihe07"]
description = "Bilibili漫画下载器,written in Rust,支持epub pdf zip格式"
Expand All @@ -12,18 +12,20 @@ license = "MIT"
[dependencies]
base64 = "0.13.0"
chrono = "0.4.19"
clap = "3.1.18"
clap = "3.2.4"
colorful = "0.2.1"
crossbeam = "0.8.1"
ctrlc = "3.2.2"
directories = "4.0.1"
enum_dispatch = "0.3.8"
epub-builder = "0.5.0"
futures = "0.3.21"
indicatif = "0.16.2"
md5 = "0.7.0"
paris = "1.5.13"
printpdf = { version = "0.5.2", features = ["embedded_images"] }
qrcode = "0.12.0"
reqwest = { version = "0.11.10", features = ["json"] }
reqwest = { version = "0.11.11", features = ["json"] }
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.81"
tokio = { version = "1.19.2", features = ["full"] }
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,23 @@
⠇ 等待确认...
```

> **备注**建议在现代的终端中执行,如*Windows Terminal*
> **备注**建议在支持色彩和符号终端中执行,如*Windows Terminal*
- `bcdown clear` - 清空缓存文件夹

- `bcdown search [链接或ID]` - 搜索某个漫画,列出它的全部章节

- `bcdown list` - 列出缓存中的漫画
- `bcdown fetch [链接或ID] <--from [从哪话开始]> <--to [到哪话结束]>` - 将一个漫画下载到本地
- `bcdown export [链接或ID] --format [epub或pdf] <--from [从哪话开始]> <--to [到哪话结束]> <-s 不合并pdf> <--output [输出位置]> ` - 导出一个本地漫画

- `bcdown fetch [链接或ID] <--range [开始]-[结束],[开始]-,-[结束]>` - 将一个漫画下载到本地

使用示例:

- `bcdown fetch mc29911 --range 1-20,40-50,60- ` 下载 *mc29911* 第1话到第20话,第40话到第50话 和 第60话之后的所有到本地

``

- `bcdown export [链接或ID] --format [epub或pdf] <--range [开始]-[结束],[开始]-,-[结束]> <-s 单独导出每一话> <--output [输出位置]> <-g [组大小>] ` - 导出一个本地漫画

## 构建,编译,安装

Expand Down Expand Up @@ -128,11 +138,13 @@
- 0.1.4 - 修复bug,优化网络模块
- 0.1.5 - 加入导出zip文件的支持,修复bug,优化任务处理
- 0.1.6 - 删除书签中的ORD编码,修复epub中的格式问题
- 0.1.7 - 修复bug,修改压缩方式为Stored
- 0.2.0 - 范围下载/导出,优化网络,加入分组导出功能,升级依赖项

## 补充

这个工具只是个爬虫,不能下载没有解锁的漫画,因此解决不了钞能力的问题(

如果发现了Bug(~~可能~~会有很多,已经发现了不少),欢迎创建Issue

这个工具的更新会很频繁,建议保持使用最新版
这个工具的更新会很频繁,建议保持使用最新版
30 changes: 29 additions & 1 deletion src/lib/cache.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::io::{Read, Write};
use std::path::Path;
use std::path::{Path, PathBuf};
use super::config::Config;

#[derive(serde::Serialize, serde::Deserialize)]
Expand All @@ -24,8 +24,28 @@ pub struct EpisodeCache {
// 文件顺序
pub host: String,
pub ord: f64,
pub root_dir: PathBuf,
}


// impl AsRef<EpisodeInfo> for EpisodeCache {
// fn as_ref(&self) -> &EpisodeInfo {
// EpisodeInfo {
// title: self.title.to_owned(),
// id: self.id,
// is_locked: true,
// ord: self.ord,
// }.as_ref()
// }
// }

impl crate::lib::HasOrd for &'_ EpisodeCache {
fn ord(&self) -> f64 {
self.ord
}
}


impl EpisodeCache {
pub fn load<T: AsRef<Path>>(path: T) -> Option<EpisodeCache> {
let meta_path = path.as_ref().join("meta.toml");
Expand All @@ -47,6 +67,7 @@ impl EpisodeCache {
paths: meta.paths,
host: meta.host,
ord: meta.ord,
root_dir: path.as_ref().to_path_buf(),
})
}
pub fn sync<T: AsRef<Path>>(&self, path: T) {
Expand Down Expand Up @@ -77,6 +98,13 @@ impl EpisodeCache {
}
not_downloaded
}

pub fn get_paths(&self) -> Vec<PathBuf> {
self.paths.iter().map(|link| {
let file_name = link.split("/").last().unwrap();
self.root_dir.join(file_name)
}).collect()
}
}

#[derive(serde::Serialize, serde::Deserialize)]
Expand Down
Loading

0 comments on commit ae7b159

Please sign in to comment.