Metadata-Version: 2.1
Name: gppt
Version: 0.4
Summary: UNKNOWN
Home-page: https://github.com/eggplants/get-pixiv-token
Author: eggplants
License: MIT
Platform: UNKNOWN
Requires-Python: >=3.5
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: selenium
Requires-Dist: types-requests
Requires-Dist: types-selenium

# `gppt`: get-pixivpy-token

![PyPI](https://img.shields.io/pypi/v/gppt?color=blue) [![Maintainability]](https://codeclimate.com/github/eggplants/get-pixiv-token/maintainability)

- Get your Pixiv token (for running [upbit/pixivpy](https://github.com/upbit/pixivpy))
- Refine [pixiv_auth.py](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) + [its fork](https://gist.github.com/upbit/6edda27cb1644e94183291109b8a5fde)

## Install

```bash
❭ pip install gppt
```

## Run

- Note: _In advance, please setup google-chrome-stable + selenium + webdriver_
- On Ubuntu, my setup script is available

```bash
❭ ./setup.sh
```

### From Library

```python
from gppt import selenium as s
gpt = s.GetPixivToken(headless=True, user="...", pass_="...")
res = gpt.login()
```

- `res.response` returns

```json
{
    "access_token":"***",
    "expires_in":3600,
    "refresh_token":"***",
    "scope":"",
    "token_type":"bearer",
    "user":{
        "account":"***",
        "id":"***",
        "is_mail_authorized":"bool",
        "is_premium":"bool",
        "mail_address":"***@***",
        "name":"***",
        "profile_image_urls":{
            "px_16x16":"https://s.pximg.net/common/images/no_profile_ss.png",
            "px_170x170":"https://s.pximg.net/common/images/no_profile.png",
            "px_50x50":"https://s.pximg.net/common/images/no_profile_s.png"
        },
        "require_policy_agreement":"bool",
        "x_restrict":2
    }
}
```

### From CLI

```bash
❭ gppt login
[!]: The browser will start. Please login.
(Log in to Pixiv from the login screen that starts up.)
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600
```

## Help

```bash
❭ gppt -h
usage: gppt [-h] {login,l,login-headless,lh,refresh,r} ...

Get your Pixiv token (for running upbit/pixivpy)

positional arguments:
  {login,l,login-headless,lh,refresh,r}
    login (l)           retrieving auth token
    login-headless (lh)
                        `login` in headless mode
    refresh (r)         refresh tokens

optional arguments:
  -h, --help            show this help message and exit
```

```bash
❭ gppt l -h
usage: gppt l [-h] [-u USERNAME] [-p PASSWORD]

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        your E-mail address / pixiv ID
  -p PASSWORD, --password PASSWORD
                        your current pixiv password
```

```bash
❭ gppt lh -h
usage: gppt login-headless [-h] -u USERNAME -p PASSWORD

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        your E-mail address / pixiv ID
  -p PASSWORD, --password PASSWORD
                        your current pixiv password
```

```bash
❭ gppt r -h
usage: gppt refresh [-h] refresh_token

positional arguments:
  refresh_token

optional arguments:
  -h, --help     show this help message and exit
```

[maintainability]: https://api.codeclimate.com/v1/badges/b40b8fa2c9d71f869b9c/maintainability


