Async-Pixiv
异步调用 Pixiv API
Building...
此项目的开发者很忙,所以没啥时间修 bug ,写文档什么的
特点
- 支持 API 请求速率限制(RateLimiter)
- 自动将请求后的数据转为 Model ,再也不用以字典形式调用获取数据了(pydantic typed)
- 支持多种代理模式(http/https/socks5)
- 支持下载 gif 帧序列文件,并将其转为 gif 或 mp4 (需要 ffmpeg)
- 。。。(想到再写)
安装
使用 pip
pip install --upgrade async-pixiv
# 安装额外依赖(用于提升数据解析速度)
pip install --upgrade async-pixiv[speedups]
使用
from async_pixiv import PixivClient # 导入
from async_pixiv.utils.rate_limiter import RateLimiter
# 初始化 Client
client = PixivClient(
limiter=RateLimiter(100, 60), # API 请求速率限制, 限制为 60 秒内最多请求 100 次。默认没有限制
timeout=10, # 默认超时秒数
proxy=None, # 代理配置
trust_env=False, # 是否从环境变量中获取代理配置
retry_times=5, # 默认请求重试次数
retry_sleep=1, # 默认重复请求间隔秒数
)
async def main():
user = await client.login_with_token('TOKEN') # 使用 token 登录 pixiv
print(user.name)
# 获取作品详情
detail_result = await client.ILLUST.detail(91725675)
illust = detail_result.illust
print(
f"链接:{illust.link}",
f"标题:{illust.title}",
f"作者:{illust.user.name}",
f"标签:#{' #'.join(map(str, illust.tags))}",
f"是否为 AI 作品:{'是' if illust.ai_type else '否'}",
f"是否为 R18 作品:{'是' if await illust.is_r18() else '否'}",
sep='\n'
)
file_data = illust.link.download() # 下载
breakpoint()
# 下载动图
bytes_data = await illust.download_ugoira(result_type='mp4') # bytes
gif_data = await illust.download_ugoira(result_type='gif')
breakpoint()
# 小说
novel_result = await client.NOVEL.detail(15739859)
novel = novel_result.novel
print(f"标题:{novel.title}", f"字数:{novel.text_length}", sep='\n')
breakpoint()
# 漫画
# 下次再写
def __main__():
import asyncio
asyncio.run(main())
if __name__ == '__main__':
__main__()
Metadata
Release files for async-pixiv 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| async_pixiv-1.1.2.tar.gz | 40.4 kB | Without provenance | Details for async_pixiv-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| async_pixiv-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for async_pixiv-1.1.2-py3-none-any.whl |
Total release size: 91.3 kB
Release files / async_pixiv-1.1.2.tar.gz
| Download URL | async_pixiv-1.1.2.tar.gz |
|---|---|
| Size | 40.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86db1c16f05b6d904f0f34cf741c6816717afa79b52d41c117df21c30d2af5e1
|
|
BLAKE2b-256 checksum How to use checksums |
a7fdf4f1a05bdb4a4a313889f5640b9344d9ab7632be1fbf92e9cdbba490ce0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.22.2 CPython/3.12.8 Linux/6.8.0-1020-azure
|
Release files / async_pixiv-1.1.2-py3-none-any.whl
| Download URL | async_pixiv-1.1.2-py3-none-any.whl |
|---|---|
| Size | 50.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c479ae144da884ae55999cc124b9f82fc8ef158396f44b9af342d471a9072add
|
|
BLAKE2b-256 checksum How to use checksums |
573f084f8db47b7ba9317a06636c9609a1b15fe2fae7aca428ca6c06cc859634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.22.2 CPython/3.12.8 Linux/6.8.0-1020-azure
|
Security for async-pixiv 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.