Skip to main content

Pure Python 3 Async Pixiv API

Project description

PixivPy-Async

Build Status PyPI version codecov

Async Pixiv API for Python 3(with Auth supported)

Based on PixivPy: https://github.com/upbit/pixivpy

PixivPy-Async is an asyncio Python 3 library of Pixiv API(with Auth supported).

Installing

pip install pixivpy-async

Import

Import async pixivpy:

from pixivpy_async import *

...or sync pixivpy(Sync Support):

from pixivpy_async.sync import *

Login

# For Public Pixiv API
papi = PixivAPI()
await papi.login(username, password)

# For App Pixiv API
aapi = AppPixivAPI()
await papi.login(username, password)

Doing stuff

await aapi.illust_detail(59580629)
await aapi.illust_comments(59580629)
await aapi.ugoira_metadata(51815717)

await aapi.illust_recommended(bookmark_illust_ids=[59580629])
aapi.parse_qs(json_result.next_url) # page down in some case
await aapi.illust_recommended(**next_qs)

await aapi.illust_related(59580629)
await aapi.user_detail(275527)
await aapi.user_illusts(275527)
await aapi.user_bookmarks_illust(2088434)
await aapi.user_following(7314824)
await aapi.user_follower(275527)
await aapi.user_mypixiv(275527)

await aapi.trending_tags_illust()
await aapi.search_illust(first_tag, search_target='partial_match_for_tags')
await aapi.illust_ranking('day_male')
await aapi.illust_follow(req_auth=True)
await aapi.illust_recommended(req_auth=True)

await aapi.illust_ranking('day', date='2016-08-01')
await aapi.download(image_url, path=directory, name=name)

await papi.works(46363414)
await papi.users(1184799)
await papi.me_feeds(show_r18=0)
await papi.me_favorite_works(publicity='private')
await papi.me_following_works()
await papi.me_following()

await papi.users_works(1184799)
await papi.users_favorite_works(1184799)
await papi.users_feeds(1184799, show_r18=0)
await papi.users_following(4102577)
await papi.ranking('illust', 'weekly', 1)
await papi.ranking(ranking_type='all', mode='daily', page=1, date='2015-05-01')

await papi.search_works("五航戦 姉妹", page=1, mode='text')
await papi.latest_works()

Nest steps

Read docs for more information

Read demos for more usage

Sync support

(Inspired by telethon)

The moment you import any of these:

from pixivpy_async import sync, ...
# or
from pixivpy_async.sync import ...
# or
import pixivpy_async.sync

The sync module rewrites most async def methods in pixivpy_async to something similar to this:

def new_method():
    result = original_method()
    if loop.is_running():
        # the loop is already running, return the await-able to the user
        return result
    else:
        # the loop is not running yet, so we can run it for the user
        return loop.run_until_complete(result)

That means you can do thing like this:

aapi = AppPixivAPI()
aapi.login(username, password)

Update

  • [2019/09/13] First Version

License

Feel free to use, reuse and abuse the code in this project.

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

PixivPy-Async-1.1.7.tar.gz (10.8 kB view hashes)

Uploaded Source

Built Distribution

PixivPy_Async-1.1.7-py3-none-any.whl (14.0 kB view hashes)

Uploaded Python 3

Supported by

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