A Python script that fetches metadata from pixiv and generates a static HTML embed card ufal.nekoweb.org/pixivembed/index.html
pixiv python embed html
0

Configure Feed

Select the types of activity you want to include in your feed.

HTML 99.0%
Python 0.9%
CSS 0.1%
6 1 0

Clone this repository

https://tangled.org/ufal.my.id/pixivembed https://tangled.org/did:plc:xghswh4pml3rwa2gqo5rewo2
git@tangled.org:ufal.my.id/pixivembed git@tangled.org:did:plc:xghswh4pml3rwa2gqo5rewo2

For self-hosted knots, clone URLs may differ based on your setup.



README.md

pixivembed.py Documentation#

pixivembed.py is a Python script that fetches metadata from pixiv and generates a static HTML embed card. By default, the script runs silently, automatically copies the generated HTML to your clipboard, and saves it to a file named pixivembed.html in the same directory.

Maintained by Ufal Salman.

The documentation is also available here and here.

Based on PixivPy3 API

Output Examples#

Download#

Get it here.

CSS#

You can use the CSS template here if you want to modify and host it yourself.

Important Notice#

Note: You must create a text file named token.txt in the same directory as the script and paste your own pixiv token inside it before running the script, otherwise authentication will fail. See this guide for further information.

Prerequisites#

Make sure you have the required libraries installed on your system:

pip install pixivpy3 Pillow

Note: The Pillow library is only required if you plan to use the local image download/conversion option (-l).

Usage#

python pixivembed.py <URL-or-ID> [options]

Basic Examples#

python pixivembed.py 11223344
python pixivembed.py https://www.pixiv.net/en/artworks/11223344

Available Options#

  • -nc : Generates raw HTML without the inline <style> block.
  • -lc : Replaces the style block with a <link rel="stylesheet"> tag pointing to an external CSS file from this website.
  • -l : Downloads the illustrations locally, converts them to WebP format, and embeds them directly into the HTML code as Base64 strings.
  • -g4 : Arranges the images in a grid layout and limits the output to a maximum of 4 images.
  • -s : Sets a fixed maximum height (400px) and makes the image container scrollable.
  • -b : Applies a blur effect to all images. Hover over the image to unblur.
  • -p <pages> : Includes only specific page numbers (1-based index, e.g., -p 1,3,4).
  • -pa <start> : Sets the starting page for a range (e.g., -pa 2).
  • -pb <end> : Sets the ending page for a range (e.g., -pb 5).

OS-Specific Guidelines#

1. Windows#

  • Open Command Prompt (CMD) or PowerShell.
  • Run the script using the standard commands.
  • The automatic clipboard functionality uses the native Windows API via ctypes, so it works out of the box with no extra software required.

2. macOS#

  • Open Terminal.
  • The clipboard functionality automatically channels the output through the native pbcopy command.
  • No additional configuration is needed.

3. Linux#

  • Open your system Terminal.
  • To allow the script to automatically copy the HTML to your clipboard, your system needs either xclip or xsel installed.
  • You can install xclip via your package manager (e.g., on Debian/Ubuntu):
sudo apt install xclip

Note for Linux Users: If neither xclip nor xsel is present, the script will still run perfectly fine and output the code to the terminal, but the automatic copy-to-clipboard step will be skipped.