Skip to content

Commit

Permalink
Merge branch 'master' into pure-py
Browse files Browse the repository at this point in the history
# Conflicts:
#	poetry.lock
#	pyproject.toml
  • Loading branch information
Ljzd-PRO committed Dec 12, 2024
2 parents 9a1ed16 + ffc9c91 commit b526b9b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
18 changes: 11 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
## Changes

[//]: # (### 💡 Feature)
![Downloads](https://img.shields.io/github/downloads/Ljzd-PRO/KToolBox/v0.12.0/total)

### 🪲 Fix
### 💡 Feature

- Update the API for retrieving post information and fix the `get-post` and `download-post` commands (#198) (#180)
- Supports resuming downloads using temporary files to restore the download process - (#205) by @kgbq3nu6s9ptn3jr

[//]: # (### 💡 新特性)
[//]: # (### 🪲 Fix)

### 🪲 修复
- - -

- 更新获取作品信息的 API,修复 `get-post``download-post` 命令 (#198) (#180)
### 💡 新特性

**Full Changelog**: https://github.com/Ljzd-PRO/KToolBox/compare/v0.11.0...v0.11.1
- 支持断点续传,借助临时下载文件恢复下载 - (#205) by @kgbq3nu6s9ptn3jr

[//]: # (### 🪲 修复)

**Full Changelog**: https://github.com/Ljzd-PRO/KToolBox/compare/v0.11.1...v0.12.0
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
ljzd@office.ljzd-pro.asia.
[me@ljzd.link](mailto:me@ljzd.link).
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
2 changes: 1 addition & 1 deletion ktoolbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__title__ = "KToolBox"
# noinspection SpellCheckingInspection
__description__ = "A useful CLI tool for downloading posts in Kemono.party / .su"
__version__ = "v0.11.1"
__version__ = "v0.12.0"
14 changes: 9 additions & 5 deletions ktoolbox/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,17 @@ async def run(

tqdm_class: Type[std_tqdm] = tqdm_class or tqdm.asyncio.tqdm
async with self._lock:
temp_filepath = Path(f"{save_filepath}.{config.downloader.temp_suffix}")
temp_size = temp_filepath.stat().st_size if temp_filepath.exists() else 0

async with self.client.stream(
method="GET",
url=self._url,
follow_redirects=True,
timeout=config.downloader.timeout
timeout=config.downloader.timeout,
headers={"Range": f"bytes={temp_size}-"}
) as res: # type: httpx.Response
if res.status_code != httpx.codes.OK:
if res.status_code != httpx.codes.PARTIAL_CONTENT:
return DownloaderRet(
code=RetCodeEnum.GeneralFailure,
message=generate_msg(
Expand All @@ -206,13 +210,13 @@ async def run(
)

# Download
temp_filepath = Path(f"{save_filepath}.{config.downloader.temp_suffix}")
total_size = int(length_str) if (length_str := res.headers.get("Content-Length")) else None
async with aiofiles.open(str(temp_filepath), "wb", self._buffer_size) as f:
total_size = int(range_str.split("/")[-1]) if (range_str := res.headers.get("Content-Range")) else None
async with aiofiles.open(str(temp_filepath), "ab", self._buffer_size) as f:
chunk_iterator = res.aiter_bytes(self._chunk_size)
t = tqdm_class(
desc=self._save_filename,
total=total_size,
initial=temp_size,
disable=not progress,
unit="B",
unit_scale=True
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ktoolbox-pure-py"
version = "v0.11.1"
version = "v0.12.0"
description = "A useful CLI tool for downloading posts in Kemono.su / .party (Pure Python version)"
authors = ["Ljzd-PRO <ljzd@office.ljzd-pro.asia>"]
readme = "README.md"
Expand Down

0 comments on commit b526b9b

Please sign in to comment.