gppt


Namegppt JSON
Version 4.1.0 PyPI version JSON
download
home_pagehttps://github.com/eggplants/get-pixivpy-token
SummaryGet your Pixiv token (for running upbit/pixivpy)
upload_time2024-04-28 20:01:14
maintainerNone
docs_urlNone
authoreggplants
requires_python<4,>=3.8
licenseMIT
keywords pixiv api token
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `gppt`: get-pixivpy-token

[![PyPI](
  <https://img.shields.io/pypi/v/gppt?color=blue>
  )](
  <https://pypi.org/project/gppt/>
) [![ghcr](
  <https://ghcr-badge.deta.dev/eggplants/get-pixivpy-token/size>
  )](
  <https://github.com/eggplants/get-pixivpy-token/pkgs/container/get-pixivpy-token>
) [![Maintainability](
  <https://api.codeclimate.com/v1/badges/b40b8fa2c9d71f869b9c/maintainability>
  )](
  <https://codeclimate.com/github/eggplants/get-pixiv-token/maintainability>
) [![pre-commit.ci status](
  <https://results.pre-commit.ci/badge/github/eggplants/get-pixivpy-token/main.svg>
  )](
  <https://results.pre-commit.ci/latest/github/eggplants/get-pixivpy-token/main>
)

- 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
```

## Enable Proxy

Set `ALL_PROXY` or `HTTPS_PROXY` to your environment variables.

## Run

### Example

```python
from gppt import GetPixivToken
from pixivpy3 import AppPixivAPI

def get_refresh_token() -> str:
    with open("token.txt", "w+") as f:
        if refresh_token := f.read().strip():
            return refresh_token

        g = GetPixivToken(headless=True)
        refresh_token = g.login(username="...", password="...")["refresh_token"]
        f.write(refresh_token)
        return refresh_token

aapi = AppPixivAPI()
aapi.auth(refresh_token=get_refresh_token())
...
```

### From Docker

```shellsession
$ docker run --rm -it ghcr.io/eggplants/get-pixivpy-token lh -u <id> -p <pw>
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600
```

### From CLI

- Note: _In advance, please setup google-chrome-stable + selenium + webdriver_

```shellsession
# with browser
$ gppt login
[!]: Chrome browser will be launched. Please login.
(Log in to Pixiv from the login screen that starts up.)
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600
...

# with headless browser
$ gppt login-headless -u <id> -p <pw>
[!]: Chrome browser will be launched. Please login.
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600
```

### From Library

- Note: _In advance, please setup google-chrome-stable + selenium + webdriver_
If either username or password are missing, manual input will be required.

```python
from gppt import GetPixivToken

g = GetPixivToken(headless=False,username=None,password=None)
res = g.login(headless=None,username=None,password=None)
```

- `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
  }
}
```

## Help

```shellsession
$ gppt -h
usage: gppt [-h]
            {login,l,login-interactive,li,login-headless,lh,refresh,r} ...

Get your Pixiv token (for running upbit/pixivpy)

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

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

```shellsession
$ gppt l -h
usage: gppt login [-h] [-u USERNAME] [-p PASSWORD] [-j]

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
  -j, --json            output response as json
```

```shellsession
$ gppt li -h
usage: gppt login-interactive [-h] [-j]

optional arguments:
  -h, --help  show this help message and exit
  -j, --json  output response as json
```

```shellsession
$ gppt lh -h
usage: gppt login-headless [-h] -u USERNAME -p PASSWORD [-j]

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
  -j, --json            output response as json
```

```shellsession
$ gppt r -h
usage: gppt refresh [-h] [-j] refresh_token

positional arguments:
  refresh_token

optional arguments:
  -h, --help     show this help message and exit
  -j, --json     output response as json
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eggplants/get-pixivpy-token",
    "name": "gppt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": "pixiv, api, token",
    "author": "eggplants",
    "author_email": "w10776e8w@yahoo.co.jp",
    "download_url": "https://files.pythonhosted.org/packages/42/98/ee774e24be91e6f198d0aa30565db69d018bed01cdc2a7d97008906d0534/gppt-4.1.0.tar.gz",
    "platform": null,
    "description": "# `gppt`: get-pixivpy-token\n\n[![PyPI](\n  <https://img.shields.io/pypi/v/gppt?color=blue>\n  )](\n  <https://pypi.org/project/gppt/>\n) [![ghcr](\n  <https://ghcr-badge.deta.dev/eggplants/get-pixivpy-token/size>\n  )](\n  <https://github.com/eggplants/get-pixivpy-token/pkgs/container/get-pixivpy-token>\n) [![Maintainability](\n  <https://api.codeclimate.com/v1/badges/b40b8fa2c9d71f869b9c/maintainability>\n  )](\n  <https://codeclimate.com/github/eggplants/get-pixiv-token/maintainability>\n) [![pre-commit.ci status](\n  <https://results.pre-commit.ci/badge/github/eggplants/get-pixivpy-token/main.svg>\n  )](\n  <https://results.pre-commit.ci/latest/github/eggplants/get-pixivpy-token/main>\n)\n\n- Get your Pixiv token (for running [upbit/pixivpy](https://github.com/upbit/pixivpy))\n- Refine [pixiv_auth.py](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) + [its fork](https://gist.github.com/upbit/6edda27cb1644e94183291109b8a5fde)\n\n## Install\n\n```bash\npip install gppt\n```\n\n## Enable Proxy\n\nSet `ALL_PROXY` or `HTTPS_PROXY` to your environment variables.\n\n## Run\n\n### Example\n\n```python\nfrom gppt import GetPixivToken\nfrom pixivpy3 import AppPixivAPI\n\ndef get_refresh_token() -> str:\n    with open(\"token.txt\", \"w+\") as f:\n        if refresh_token := f.read().strip():\n            return refresh_token\n\n        g = GetPixivToken(headless=True)\n        refresh_token = g.login(username=\"...\", password=\"...\")[\"refresh_token\"]\n        f.write(refresh_token)\n        return refresh_token\n\naapi = AppPixivAPI()\naapi.auth(refresh_token=get_refresh_token())\n...\n```\n\n### From Docker\n\n```shellsession\n$ docker run --rm -it ghcr.io/eggplants/get-pixivpy-token lh -u <id> -p <pw>\n[+]: Success!\naccess_token: ***\nrefresh_token: ***\nexpires_in: 3600\n```\n\n### From CLI\n\n- Note: _In advance, please setup google-chrome-stable + selenium + webdriver_\n\n```shellsession\n# with browser\n$ gppt login\n[!]: Chrome browser will be launched. Please login.\n(Log in to Pixiv from the login screen that starts up.)\n[+]: Success!\naccess_token: ***\nrefresh_token: ***\nexpires_in: 3600\n...\n\n# with headless browser\n$ gppt login-headless -u <id> -p <pw>\n[!]: Chrome browser will be launched. Please login.\n[+]: Success!\naccess_token: ***\nrefresh_token: ***\nexpires_in: 3600\n```\n\n### From Library\n\n- Note: _In advance, please setup google-chrome-stable + selenium + webdriver_\nIf either username or password are missing, manual input will be required.\n\n```python\nfrom gppt import GetPixivToken\n\ng = GetPixivToken(headless=False,username=None,password=None)\nres = g.login(headless=None,username=None,password=None)\n```\n\n- `res.response` returns:\n\n```json\n{\n  \"access_token\": \"***\",\n  \"expires_in\": 3600,\n  \"refresh_token\": \"***\",\n  \"scope\": \"\",\n  \"token_type\": \"bearer\",\n  \"user\": {\n    \"account\": \"***\",\n    \"id\": \"***\",\n    \"is_mail_authorized\": <bool>,\n    \"is_premium\": <bool>,\n    \"mail_address\": \"***@***\",\n    \"name\": \"***\",\n    \"profile_image_urls\": {\n      \"px_16x16\": \"https://s.pximg.net/common/images/no_profile_ss.png\",\n      \"px_170x170\": \"https://s.pximg.net/common/images/no_profile.png\",\n      \"px_50x50\": \"https://s.pximg.net/common/images/no_profile_s.png\"\n    },\n    \"require_policy_agreement\": <bool>,\n    \"x_restrict\": 2\n  }\n}\n```\n\n## Help\n\n```shellsession\n$ gppt -h\nusage: gppt [-h]\n            {login,l,login-interactive,li,login-headless,lh,refresh,r} ...\n\nGet your Pixiv token (for running upbit/pixivpy)\n\npositional arguments:\n  {login,l,login-interactive,li,login-headless,lh,refresh,r}\n    login (l)           retrieving auth token\n    login-interactive (li)\n                        `login` in interactive mode\n    login-headless (lh)\n                        `login` in headless mode\n    refresh (r)         refresh tokens\n\noptional arguments:\n  -h, --help            show this help message and exit\n```\n\n```shellsession\n$ gppt l -h\nusage: gppt login [-h] [-u USERNAME] [-p PASSWORD] [-j]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -u USERNAME, --username USERNAME\n                        your E-mail address / pixiv ID\n  -p PASSWORD, --password PASSWORD\n                        your current pixiv password\n  -j, --json            output response as json\n```\n\n```shellsession\n$ gppt li -h\nusage: gppt login-interactive [-h] [-j]\n\noptional arguments:\n  -h, --help  show this help message and exit\n  -j, --json  output response as json\n```\n\n```shellsession\n$ gppt lh -h\nusage: gppt login-headless [-h] -u USERNAME -p PASSWORD [-j]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -u USERNAME, --username USERNAME\n                        your E-mail address / pixiv ID\n  -p PASSWORD, --password PASSWORD\n                        your current pixiv password\n  -j, --json            output response as json\n```\n\n```shellsession\n$ gppt r -h\nusage: gppt refresh [-h] [-j] refresh_token\n\npositional arguments:\n  refresh_token\n\noptional arguments:\n  -h, --help     show this help message and exit\n  -j, --json     output response as json\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Get your Pixiv token (for running upbit/pixivpy)",
    "version": "4.1.0",
    "project_urls": {
        "Homepage": "https://github.com/eggplants/get-pixivpy-token",
        "Repository": "https://github.com/eggplants/get-pixivpy-token"
    },
    "split_keywords": [
        "pixiv",
        " api",
        " token"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e0a06bbf9ed7218eb90b8770db195bdc2dbcabbaaa53a835cd9aa3605c288f2",
                "md5": "926bc5746383f58162dc76b6ca1f5b63",
                "sha256": "c33bf1235f29e55759a4388189b1c5cb242488a9b92eae960037384815caa58d"
            },
            "downloads": -1,
            "filename": "gppt-4.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "926bc5746383f58162dc76b6ca1f5b63",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 10734,
            "upload_time": "2024-04-28T20:01:12",
            "upload_time_iso_8601": "2024-04-28T20:01:12.977780Z",
            "url": "https://files.pythonhosted.org/packages/3e/0a/06bbf9ed7218eb90b8770db195bdc2dbcabbaaa53a835cd9aa3605c288f2/gppt-4.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4298ee774e24be91e6f198d0aa30565db69d018bed01cdc2a7d97008906d0534",
                "md5": "0c5565d33dbad7d376cbc1d88c14f369",
                "sha256": "8f16c1fd31e75ea3df080e9bb2a206dbf08fc4deb82242c5338aab010b48941a"
            },
            "downloads": -1,
            "filename": "gppt-4.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0c5565d33dbad7d376cbc1d88c14f369",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 9720,
            "upload_time": "2024-04-28T20:01:14",
            "upload_time_iso_8601": "2024-04-28T20:01:14.905530Z",
            "url": "https://files.pythonhosted.org/packages/42/98/ee774e24be91e6f198d0aa30565db69d018bed01cdc2a7d97008906d0534/gppt-4.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-28 20:01:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eggplants",
    "github_project": "get-pixivpy-token",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gppt"
}
        
Elapsed time: 0.88295s