Skip to content

Integrated Flow - Line Notification of Top Ranked Pixiv Illustrations

Notifications You must be signed in to change notification settings

der3318/daily-pixiv

Repository files navigation

📰 Daily Pixiv Notification

pixivpy3 line rich pillow license

The repo leverages pixivpy (Pixiv API) to download top ranked Pixiv illustrations into a Line chatroom (via Line Notify). A Github Actions job is also setup to test the flow and verify the integration (incl. API, endpoints, large payload requests) on a daily basis.

Sample.png

About Github Workflow Pipeline

schedule.yml has several predefined configurations. For Pixiv token, keyword (tag) and Line Notify bearer, they are provided as Github Action secrets:

ActionSecrets.png

Secret Name Description
LINE_BEARER the bearer used by Line Notify to interact with a chatroom (a str including alphabets and numbers)
PIXIV_KEYWORD the tag keyword to search (likely to be a Japanese term)
PIXIV_TOKEN a Pixiv refresh session token (usually a 43-charactered str including alphabets and numbers)

By default, the workflow is scheduled at 5AM (UTC+0) every day. It surfs the artworks and pushs a notification on success.

How to Get Pivix Refresh Token

See @ZipFile Pixiv OAuth Flow for detailed instructions and scripts.

TL;DR

  • Run python3 pixiv_auth.py login and the browser will open a Pixiv auth page asking for sign-in. Stay and do not proceed at the moment.

  • Open dev console (F12) and switch to network view. Enter callback?state in the filter box.

  • Now continue to proceed with Pixiv Login. A request will be captured. Copy its code parameter. (@AlttiRi's example)

    Capture.png

  • Go back to the python cmd prompt. Paste the code and hit the enter key.

  • access_token, refresh_token and expires_in will be displyed. refresh_token is exactly what we need.

It seems that refresh_token can be used for a very long period (months and even years). Do this once, keep the token as secrets and make it accessible for pipeline.

Local Run

To customize or add new features, run the scripts locally. It saves downloaded images to Images/ directly, using original resolution (unlike Line Notify which has a size limitation).

LocalRun.png

Known (and Mitigated) Issue

cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 Captcha challenge, This feature is not available in the opensource (free) version.

During handling of the above exception, another exception occurred:

pixivpy3.utils.PixivError: requests POST https://oauth.secure.pixiv.net/auth/token error: Detected a Cloudflare version 2 Captcha challenge, This feature is not available in the opensource (free) version.

According to upbit/pixivpy#166, retry is the most trivial solution. That's why the script has a RetryOnFailure module.

Github Terms and Agreement

See Acceptable Use Polices Regarding Actions:

  • This is NOT for commercial purposes.
  • Runs are low burden and will NOT deliver content publicly.
  • Activities are considered sort of software project testing.

About

Integrated Flow - Line Notification of Top Ranked Pixiv Illustrations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages