Name | async-pixiv JSON |
Version |
1.1.0
JSON |
| download |
home_page | None |
Summary | Async Pixiv API for Python. |
upload_time | 2025-01-20 14:31:35 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | MIT |
keywords |
pixiv
async
pixiv-api
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Async-Pixiv
[](https://www.python.org/downloads/release/python-3100/)
[](https://github.com/ArkoClub/async-pixiv)
[](https://pypi.org/project/async-pixivr/)
[](./LICENSE)
[](https://pypi.org/project/async-pixiv/)
[](https://hits.sh/github.com/ArkoClub/async-pixiv)
异步调用 Pixiv API
# Building...
此项目的开发者很忙,所以没啥时间修 bug ,写文档什么的
### 特点
1. 支持 API 请求速率限制([RateLimiter](https://aiolimiter.readthedocs.io/en/latest/))
2. 自动将请求后的数据转为 Model ,再也不用以字典形式调用获取数据了(pydantic typed)
3. 支持多种代理模式(http/https/socks5)
4. 支持下载 gif 帧序列文件,并将其转为 gif 或 mp4 (需要 [ffmpeg](https://ffmpeg.org))
5. 。。。(想到再写)
## 安装
使用 `pip`
```bash
pip install --upgrade async-pixiv
# 安装额外依赖(用于提升数据解析速度)
pip install --upgrade async-pixiv[speedups]
```
## 使用
```python
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__()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "async-pixiv",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "Karako <karako@karako.moe>",
"keywords": "pixiv, async, pixiv-api",
"author": null,
"author_email": "Arko <arko.space.cc@gmail.com>, Karako <karako@karako.moe>",
"download_url": "https://files.pythonhosted.org/packages/de/a9/b52d1e809707733d592b9364cea58f5afeaf88ee30b64b7c500ab56b5d5c/async_pixiv-1.1.0.tar.gz",
"platform": null,
"description": "# Async-Pixiv\n\n[](https://www.python.org/downloads/release/python-3100/)\n[](https://github.com/ArkoClub/async-pixiv)\n[](https://pypi.org/project/async-pixivr/)\n[](./LICENSE)\n\n[](https://pypi.org/project/async-pixiv/)\n[](https://hits.sh/github.com/ArkoClub/async-pixiv)\n\n\u5f02\u6b65\u8c03\u7528 Pixiv API\n\n# Building...\n\u6b64\u9879\u76ee\u7684\u5f00\u53d1\u8005\u5f88\u5fd9\uff0c\u6240\u4ee5\u6ca1\u5565\u65f6\u95f4\u4fee bug \uff0c\u5199\u6587\u6863\u4ec0\u4e48\u7684\n\n### \u7279\u70b9\n1. \u652f\u6301 API \u8bf7\u6c42\u901f\u7387\u9650\u5236\uff08[RateLimiter](https://aiolimiter.readthedocs.io/en/latest/)\uff09\n2. \u81ea\u52a8\u5c06\u8bf7\u6c42\u540e\u7684\u6570\u636e\u8f6c\u4e3a Model \uff0c\u518d\u4e5f\u4e0d\u7528\u4ee5\u5b57\u5178\u5f62\u5f0f\u8c03\u7528\u83b7\u53d6\u6570\u636e\u4e86\uff08pydantic typed\uff09\n3. \u652f\u6301\u591a\u79cd\u4ee3\u7406\u6a21\u5f0f\uff08http/https/socks5\uff09\n4. \u652f\u6301\u4e0b\u8f7d gif \u5e27\u5e8f\u5217\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u8f6c\u4e3a gif \u6216 mp4 \uff08\u9700\u8981 [ffmpeg](https://ffmpeg.org)\uff09 \n5. \u3002\u3002\u3002\uff08\u60f3\u5230\u518d\u5199\uff09\n\n## \u5b89\u88c5\n\n\u4f7f\u7528 `pip` \n\n```bash\npip install --upgrade async-pixiv\n\n# \u5b89\u88c5\u989d\u5916\u4f9d\u8d56\uff08\u7528\u4e8e\u63d0\u5347\u6570\u636e\u89e3\u6790\u901f\u5ea6\uff09\npip install --upgrade async-pixiv[speedups]\n```\n\n## \u4f7f\u7528\n\n```python\nfrom async_pixiv import PixivClient # \u5bfc\u5165\nfrom async_pixiv.utils.rate_limiter import RateLimiter\n\n\n# \u521d\u59cb\u5316 Client\nclient = PixivClient(\n limiter=RateLimiter(100, 60), # API \u8bf7\u6c42\u901f\u7387\u9650\u5236, \u9650\u5236\u4e3a 60 \u79d2\u5185\u6700\u591a\u8bf7\u6c42 100 \u6b21\u3002\u9ed8\u8ba4\u6ca1\u6709\u9650\u5236\n timeout=10, # \u9ed8\u8ba4\u8d85\u65f6\u79d2\u6570\n proxy=None, # \u4ee3\u7406\u914d\u7f6e\n trust_env=False, # \u662f\u5426\u4ece\u73af\u5883\u53d8\u91cf\u4e2d\u83b7\u53d6\u4ee3\u7406\u914d\u7f6e\n retry_times=5, # \u9ed8\u8ba4\u8bf7\u6c42\u91cd\u8bd5\u6b21\u6570\n retry_sleep=1, # \u9ed8\u8ba4\u91cd\u590d\u8bf7\u6c42\u95f4\u9694\u79d2\u6570\n)\n\n\nasync def main():\n user = await client.login_with_token('TOKEN') # \u4f7f\u7528 token \u767b\u5f55 pixiv\n print(user.name)\n\n # \u83b7\u53d6\u4f5c\u54c1\u8be6\u60c5\n detail_result = await client.ILLUST.detail(91725675)\n illust = detail_result.illust\n print(\n f\"\u94fe\u63a5\uff1a{illust.link}\", \n f\"\u6807\u9898\uff1a{illust.title}\", \n f\"\u4f5c\u8005\uff1a{illust.user.name}\", \n f\"\u6807\u7b7e\uff1a#{' #'.join(map(str, illust.tags))}\", \n f\"\u662f\u5426\u4e3a AI \u4f5c\u54c1\uff1a{'\u662f' if illust.ai_type else '\u5426'}\",\n f\"\u662f\u5426\u4e3a R18 \u4f5c\u54c1\uff1a{'\u662f' if await illust.is_r18() else '\u5426'}\",\n sep='\\n'\n )\n file_data = illust.link.download() # \u4e0b\u8f7d\n breakpoint()\n\n # \u4e0b\u8f7d\u52a8\u56fe\n bytes_data = await illust.download_ugoira(result_type='mp4') # bytes\n gif_data = await illust.download_ugoira(result_type='gif')\n breakpoint()\n\n # \u5c0f\u8bf4\n novel_result = await client.NOVEL.detail(15739859)\n novel = novel_result.novel\n print(f\"\u6807\u9898\uff1a{novel.title}\", f\"\u5b57\u6570\uff1a{novel.text_length}\", sep='\\n')\n breakpoint()\n \n # \u6f2b\u753b\n # \u4e0b\u6b21\u518d\u5199\n\ndef __main__():\n import asyncio\n\n asyncio.run(main())\n\n\nif __name__ == '__main__':\n __main__()\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Async Pixiv API for Python.",
"version": "1.1.0",
"project_urls": {
"homepage": "https://github.com/ArkoClub/async-pixiv",
"repository": "https://github.com/ArkoClub/async-pixiv"
},
"split_keywords": [
"pixiv",
" async",
" pixiv-api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "303e384fa7275d871da13ba0692461e95d9e80b0d7e0db61c6e1d714b8ce82ce",
"md5": "c53e715c604638562d18cdfea2f50f7d",
"sha256": "37baf0f999eb781b2a3bd3d466d3f1b60bb0be4e8af0fd3b63ba7e2d55787b2a"
},
"downloads": -1,
"filename": "async_pixiv-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c53e715c604638562d18cdfea2f50f7d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 50829,
"upload_time": "2025-01-20T14:31:33",
"upload_time_iso_8601": "2025-01-20T14:31:33.073580Z",
"url": "https://files.pythonhosted.org/packages/30/3e/384fa7275d871da13ba0692461e95d9e80b0d7e0db61c6e1d714b8ce82ce/async_pixiv-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dea9b52d1e809707733d592b9364cea58f5afeaf88ee30b64b7c500ab56b5d5c",
"md5": "8f74cc0f78277cd48240ff34f1b9dc5d",
"sha256": "edc676712cd07417d88ec61df27e0118c6902fbabb5d362238b146729acadae0"
},
"downloads": -1,
"filename": "async_pixiv-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "8f74cc0f78277cd48240ff34f1b9dc5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 40397,
"upload_time": "2025-01-20T14:31:35",
"upload_time_iso_8601": "2025-01-20T14:31:35.730106Z",
"url": "https://files.pythonhosted.org/packages/de/a9/b52d1e809707733d592b9364cea58f5afeaf88ee30b64b7c500ab56b5d5c/async_pixiv-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-20 14:31:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ArkoClub",
"github_project": "async-pixiv",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "async-pixiv"
}