Async-Pixiv
![License](https://img.shields.io/github/license/ArkoClub/async-pixiv?label=License&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB0PSIxNjUxMjEyODQ2ODY0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE1MDAiIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48cGF0aCBkPSJNOTQ3LjIgOTIxLjZsLTg3MC40IDBjLTQyLjM0MjQgMC03Ni44LTM0LjQ1NzYtNzYuOC03Ni44bDAtNjY1LjZjMC00Mi4zNDI0IDM0LjQ1NzYtNzYuOCA3Ni44LTc2LjhsODcwLjQgMGM0Mi4zNDI0IDAgNzYuOCAzNC40NTc2IDc2LjggNzYuOGwwIDY2NS42YzAgNDIuMzQyNC0zNC40NTc2IDc2LjgtNzYuOCA3Ni44ek03Ni44IDE1My42Yy0xNC4xMzEyIDAtMjUuNiAxMS40Njg4LTI1LjYgMjUuNmwwIDY2NS42YzAgMTQuMTMxMiAxMS40Njg4IDI1LjYgMjUuNiAyNS42bDg3MC40IDBjMTQuMTMxMiAwIDI1LjYtMTEuNDY4OCAyNS42LTI1LjZsMC02NjUuNmMwLTE0LjEzMTItMTEuNDY4OC0yNS42LTI1LjYtMjUuNmwtODcwLjQgMHoiIHAtaWQ9IjE1MDEiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF0aCBkPSJNNDg2LjQgMzA3LjJsLTMwNy4yIDBjLTE0LjEzMTIgMC0yNS42LTExLjQ2ODgtMjUuNi0yNS42czExLjQ2ODgtMjUuNiAyNS42LTI1LjZsMzA3LjIgMGMxNC4xMzEyIDAgMjUuNiAxMS40Njg4IDI1LjYgMjUuNnMtMTEuNDY4OCAyNS42LTI1LjYgMjUuNnoiIHAtaWQ9IjE1MDIiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF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yLTE5MiAxOTJ6IiBwLWlkPSIzNDcwIiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+)
异步调用 Pixiv API
Building...
此项目的开发者很忙,所以没啥时间修 bug ,写文档什么的
特点
- 支持 API 请求速率限制(RateLimiter)
- 可使用账号和密码直接登录 Pixiv(注:可能会因为遇到 Cloudflare 验证而登录失败)
- 自动将请求后的数据转为 Model ,再也不用以字典形式调用获取数据了(pydantic typed)
- 支持多种代理模式(http/https/socks5)
- 支持下载 gif 帧序列文件,并将其转为 gif 或 mp4 (需要 ffmpeg)
- 。。。(想到再写)
安装
使用 pip
(任选一行指令进行安装)
pip install --upgrade async-pixiv
pip install --upgrade async-pixiv[extra]
pip install --upgrade async-pixiv[playwright]
pip install --upgrade async-pixiv[full]
使用 poetry
poetry add async-pixiv
poetry add async-pixiv[extra]
poetry add async-pixiv[playwright]
poetry add async-pixiv[full]
使用
from async_pixiv import PixivClient
client = PixivClient(
max_rate=100,
rate_time_period=60,
timeout=10,
proxies=None,
trust_env=False,
retry=5,
retry_sleep=1,
)
async def main():
user = await client.login_with_token('TOKEN')
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.download()
breakpoint()
bytes_data = await client.ILLUST.download_ugoira(105369892, type='mp4')
gif_data = await client.ILLUST.download_ugoira(105369892, 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__()