Skip to main content

根据标签下载Pixiv用户作品的工具

Project description

Pixiv Tag Downloader

根据标签下载Pixiv用户作品的工具,支持图片、插画、漫画和小说的下载,并提供标签过滤功能。

功能特点

  • 🖼️ 支持下载Pixiv用户的所有类型作品(图片、插画、漫画、小说)
  • 🏷️ 支持按标签过滤作品,支持AND/OR逻辑
  • 🚀 多线程下载,提高下载效率
  • 📂 支持自定义输出目录结构和文件命名规则
  • 📝 为每个作品生成包含元数据的文件
  • 🌐 支持多种下载方式:直接下载、aria2c命令行和aria2 RPC(包括WSS协议)
  • 🖥️ 提供交互式命令行界面和命令行参数两种使用方式
  • 🧩 可作为Python模块导入使用
  • 🌍 支持配置代理
  • 🔄 内置随机延迟功能,降低被封风险

安装方法

从PyPI安装

pip install pixiv-tag-downloader

从源码安装

git clone https://github.com/example/pixiv_tag_downloader.git
cd pixiv_tag_downloader
pip install -e .

使用方法

准备Cookie

  1. 在浏览器中登录Pixiv

  2. 使用浏览器开发者工具导出Cookie

  3. 将Cookie保存为程序运行目录下的cookie.txt文件,格式为:

    key1=value1; key2=value2; ...
    

交互式使用

pixiv-tag-downloader

程序将引导您完成下载流程:

  1. 输入Pixiv用户ID(UID)
  2. 选择是否查看所有可用标签
  3. 选择要下载的标签和过滤逻辑
  4. 确认下载信息

命令行参数

pixiv-tag-downloader -u 用户ID -t 标签1,标签2 -l and --output-dir ./下载目录 --download-method direct --threads 4

主要参数:

  • -u, --uid: 指定Pixiv用户ID
  • -t, --tags: 指定要下载的标签,多个标签用逗号分隔
  • -l, --logic: 标签过滤逻辑,可选值为andor
  • --output-dir: 指定输出目录,覆盖配置文件中的设置
  • --threads: 指定下载线程数
  • --download-method: 指定下载方式,可选值为directaria2caria2-rpc
  • --aria2-rpc-url: 指定Aria2 RPC服务地址
  • --config: 指定配置文件路径

配置文件

程序支持通过配置文件自定义设置,详见配置文件示例

配置文件可放置于以下位置:

  • 当前目录下的config.yamlconfig.yml
  • 用户目录下的~/.pixiv_tag_downloader/config.yaml
  • 通过--config参数指定的路径

作为模块使用

from pixiv_tag_downloader.auth.cookie import get_cookie_manager
from pixiv_tag_downloader.api.pixiv import get_pixiv_api
from pixiv_tag_downloader.download.aria2 import create_downloader
from pixiv_tag_downloader.utils.path_formatter import get_path_formatter
from pixiv_tag_downloader.utils.file_utils import get_file_utils

# 初始化Cookie
cookie_manager = get_cookie_manager()
success, message = cookie_manager.load_cookie()
if not success:
    print(f"Cookie加载失败: {message}")
    exit(1)

# 获取用户作品
pixiv_api = get_pixiv_api()
user_info = pixiv_api.get_user_info("12345678")
artworks = pixiv_api.get_user_artworks_ids("12345678")

# 下载作品
downloader = create_downloader("direct")
path_formatter = get_path_formatter()
file_utils = get_file_utils()

# 下载示例
for pid in artworks['illustrations'][:5]:  # 只下载前5个作品
    artwork = pixiv_api.get_artwork_details(pid)
    img_url = artwork.get('urls', {}).get('original')
    if img_url:
        save_path = path_formatter.format_artwork_path(artwork)
        downloader.download_file(img_url, save_path)
        metadata_path = path_formatter.format_metadata_path(save_path)
        file_utils.write_metadata_file(metadata_path, artwork)

系统要求

  • Python 3.8 或更高版本
  • 如需使用Aria2下载功能,请安装Aria2

许可证

本项目采用MIT许可证,详见LICENSE文件。

免责声明

本工具仅供学习和研究使用,请勿用于非法用途。使用本工具下载的作品仅可用于个人备份,禁止用于商业用途或公开分发。用户需遵守Pixiv的服务条款,并对自己的行为负全部责任。作者不对因使用本工具可能导致的任何问题承担责任。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixiv_tag_downloader-1.0.0.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixiv_tag_downloader-1.0.0-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file pixiv_tag_downloader-1.0.0.tar.gz.

File metadata

  • Download URL: pixiv_tag_downloader-1.0.0.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.19

File hashes

Hashes for pixiv_tag_downloader-1.0.0.tar.gz
Algorithm Hash digest
SHA256 440ff454c99ad4c64503098c78709c025a557b5241faba63159be05a0f2cf743
MD5 2e4473bb9a11462d3407d20d6dc13ddd
BLAKE2b-256 934626cc6483f8046ef551d1a9760d2f1c2b68f7158bd25b4d2bdce7cbe1c52c

See more details on using hashes here.

File details

Details for the file pixiv_tag_downloader-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pixiv_tag_downloader-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 529e9b04884986c685817f19daa68b76a3386aca67d09d745f98381e9d8c642a
MD5 b19f206e5ffd9b31eaf980af3b30606e
BLAKE2b-256 c424780d34a5881264993c8f02fb2e0eef31bea397b9af2f378eed0fc19cd783

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page