pytchat


Namepytchat JSON
Version 0.5.5 PyPI version JSON
download
home_pagehttps://github.com/taizan-hokuto/pytchat
Summarya python library for fetching youtube live chat.
upload_time2021-07-24 14:04:31
maintainer
docs_urlNone
authortaizan-hokuto
requires_python
licenseMIT
keywords youtube livechat asyncio
VCS
bugtrack_url
requirements httpx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pytchat
=======

pytchat is a python library for fetching youtube live chat.


<br><br><br>
## Description
pytchat is a python library for fetching youtube live chat
without using Selenium or BeautifulSoup.

Other features:
+ Customizable [chat data processors](https://github.com/taizan-hokuto/pytchat/wiki/ChatProcessor) including youtube api compatible one.
+ Available on asyncio context. 
+ Quick fetching of initial chat data by generating continuation params
instead of web scraping.

For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki). <br>
[wiki (Japanese)](https://github.com/taizan-hokuto/pytchat/wiki/Home_jp)

## Install
```python
pip install pytchat
```
## Examples


### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))
```python
import pytchat
chat = pytchat.create(video_id="uIx8l2xlYVY")
while chat.is_alive():
    for c in chat.get().sync_items():
        print(f"{c.datetime} [{c.author.name}]- {c.message}")
```


### Output JSON format string (feature of [DefaultProcessor](https://github.com/taizan-hokuto/pytchat/wiki/DefaultProcessor))
```python
import pytchat
import time

chat = pytchat.create(video_id="uIx8l2xlYVY")
while chat.is_alive():
    print(chat.get().json())
    time.sleep(5)
    '''
    # Each chat item can also be output in JSON format.
    for c in chat.get().items:
        print(c.json())
    '''     
```


### other
+ Fetch chat with a buffer ([LiveChat](https://github.com/taizan-hokuto/pytchat/wiki/LiveChat))

+ Use with asyncio ([LiveChatAsync](https://github.com/taizan-hokuto/pytchat/wiki/LiveChatAsync))

+ YT API compatible chat processor ([CompatibleProcessor](https://github.com/taizan-hokuto/pytchat/wiki/CompatibleProcessor))


## Structure of Default Processor
Each item can be got with `sync_items()` function.
<table>
  <tr>
    <th>name</th>
    <th>type</th>
    <th>remarks</th>
  </tr>
  <tr>
    <td>type</td>
    <td>str</td>
    <td>"superChat","textMessage","superSticker","newSponsor"</td>
  </tr>
  <tr>
    <td>id</td>
    <td>str</td>
    <td></td>
  </tr>
  <tr>
    <td>message</td>
    <td>str</td>
    <td>emojis are represented by ":(shortcut text):"</td>
  </tr>
  <tr>
    <td>messageEx</td>
    <td>str</td>
    <td>list of message texts and emoji dicts(id, txt, url).</td>
  </tr>
  <tr>
    <td>timestamp</td>
    <td>int</td>
    <td>unixtime milliseconds</td>
  </tr>
  <tr>
    <td>datetime</td>
    <td>str</td>
    <td>e.g. "2019-10-10 12:34:56"</td>
  </tr>
    <td>elapsedTime</td>
    <td>str</td>
    <td>elapsed time. (e.g. "1:02:27") *Replay Only.</td>
  </tr>
  <tr>
    <td>amountValue</td>
    <td>float</td>
    <td>e.g. 1,234.0</td>
  </tr>
  <tr>
    <td>amountString</td>
    <td>str</td>
    <td>e.g. "$ 1,234"</td>
  </tr>
  <tr>
    <td>currency</td>
    <td>str</td>
    <td><a href="https://en.wikipedia.org/wiki/ISO_4217">ISO 4217 currency codes</a> (e.g. "USD")</td>
  </tr>
  <tr>
    <td>bgColor</td>
    <td>int</td>
    <td>RGB Int</td>
  </tr>
  <tr>
    <td>author</td>
    <td>object</td>
    <td>see below</td>
  </tr>
</table>

Structure of author object.
<table>
  <tr>
    <th>name</th>
    <th>type</th>
    <th>remarks</th>
  </tr>
  <tr>
    <td>name</td>
    <td>str</td>
    <td></td>
  </tr>
  <tr>
    <td>channelId</td>
    <td>str</td>
    <td>*chatter's channel ID.</td>
  </tr>
  <tr>
    <td>channelUrl</td>
    <td>str</td>
    <td></td>
  </tr>
  <tr>
    <td>imageUrl</td>
    <td>str</td>
    <td></td>
  </tr>
  <tr>
    <td>badgeUrl</td>
    <td>str</td>
    <td></td>
  </tr>
  <tr>
    <td>isVerified</td>
    <td>bool</td>
    <td></td>
  </tr>
  <tr>
    <td>isChatOwner</td>
    <td>bool</td>
    <td></td>
  </tr>
  <tr>
    <td>isChatSponsor</td>
    <td>bool</td>
    <td></td>
  </tr>
  <tr>
    <td>isChatModerator</td>
    <td>bool</td>
    <td></td>
  </tr>
</table>

## Licence

[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/taizan-hokuto/pytchat",
    "name": "pytchat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "youtube livechat asyncio",
    "author": "taizan-hokuto",
    "author_email": "55448286+taizan-hokuto@users.noreply.github.com",
    "download_url": "",
    "platform": "",
    "description": "pytchat\n=======\n\npytchat is a python library for fetching youtube live chat.\n\n\n<br><br><br>\n## Description\npytchat is a python library for fetching youtube live chat\nwithout using Selenium or BeautifulSoup.\n\nOther features:\n+ Customizable [chat data processors](https://github.com/taizan-hokuto/pytchat/wiki/ChatProcessor) including youtube api compatible one.\n+ Available on asyncio context. \n+ Quick fetching of initial chat data by generating continuation params\ninstead of web scraping.\n\nFor more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki). <br>\n[wiki (Japanese)](https://github.com/taizan-hokuto/pytchat/wiki/Home_jp)\n\n## Install\n```python\npip install pytchat\n```\n## Examples\n\n\n### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))\n```python\nimport pytchat\nchat = pytchat.create(video_id=\"uIx8l2xlYVY\")\nwhile chat.is_alive():\n    for c in chat.get().sync_items():\n        print(f\"{c.datetime} [{c.author.name}]- {c.message}\")\n```\n\n\n### Output JSON format string (feature of [DefaultProcessor](https://github.com/taizan-hokuto/pytchat/wiki/DefaultProcessor))\n```python\nimport pytchat\nimport time\n\nchat = pytchat.create(video_id=\"uIx8l2xlYVY\")\nwhile chat.is_alive():\n    print(chat.get().json())\n    time.sleep(5)\n    '''\n    # Each chat item can also be output in JSON format.\n    for c in chat.get().items:\n        print(c.json())\n    '''     \n```\n\n\n### other\n+ Fetch chat with a buffer ([LiveChat](https://github.com/taizan-hokuto/pytchat/wiki/LiveChat))\n\n+ Use with asyncio ([LiveChatAsync](https://github.com/taizan-hokuto/pytchat/wiki/LiveChatAsync))\n\n+ YT API compatible chat processor ([CompatibleProcessor](https://github.com/taizan-hokuto/pytchat/wiki/CompatibleProcessor))\n\n\n## Structure of Default Processor\nEach item can be got with `sync_items()` function.\n<table>\n  <tr>\n    <th>name</th>\n    <th>type</th>\n    <th>remarks</th>\n  </tr>\n  <tr>\n    <td>type</td>\n    <td>str</td>\n    <td>\"superChat\",\"textMessage\",\"superSticker\",\"newSponsor\"</td>\n  </tr>\n  <tr>\n    <td>id</td>\n    <td>str</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>message</td>\n    <td>str</td>\n    <td>emojis are represented by \":(shortcut text):\"</td>\n  </tr>\n  <tr>\n    <td>messageEx</td>\n    <td>str</td>\n    <td>list of message texts and emoji dicts(id, txt, url).</td>\n  </tr>\n  <tr>\n    <td>timestamp</td>\n    <td>int</td>\n    <td>unixtime milliseconds</td>\n  </tr>\n  <tr>\n    <td>datetime</td>\n    <td>str</td>\n    <td>e.g. \"2019-10-10 12:34:56\"</td>\n  </tr>\n    <td>elapsedTime</td>\n    <td>str</td>\n    <td>elapsed time. (e.g. \"1:02:27\") *Replay Only.</td>\n  </tr>\n  <tr>\n    <td>amountValue</td>\n    <td>float</td>\n    <td>e.g. 1,234.0</td>\n  </tr>\n  <tr>\n    <td>amountString</td>\n    <td>str</td>\n    <td>e.g. \"$ 1,234\"</td>\n  </tr>\n  <tr>\n    <td>currency</td>\n    <td>str</td>\n    <td><a href=\"https://en.wikipedia.org/wiki/ISO_4217\">ISO 4217 currency codes</a> (e.g. \"USD\")</td>\n  </tr>\n  <tr>\n    <td>bgColor</td>\n    <td>int</td>\n    <td>RGB Int</td>\n  </tr>\n  <tr>\n    <td>author</td>\n    <td>object</td>\n    <td>see below</td>\n  </tr>\n</table>\n\nStructure of author object.\n<table>\n  <tr>\n    <th>name</th>\n    <th>type</th>\n    <th>remarks</th>\n  </tr>\n  <tr>\n    <td>name</td>\n    <td>str</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>channelId</td>\n    <td>str</td>\n    <td>*chatter's channel ID.</td>\n  </tr>\n  <tr>\n    <td>channelUrl</td>\n    <td>str</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>imageUrl</td>\n    <td>str</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>badgeUrl</td>\n    <td>str</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>isVerified</td>\n    <td>bool</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>isChatOwner</td>\n    <td>bool</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>isChatSponsor</td>\n    <td>bool</td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>isChatModerator</td>\n    <td>bool</td>\n    <td></td>\n  </tr>\n</table>\n\n## Licence\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "a python library for fetching youtube live chat.",
    "version": "0.5.5",
    "project_urls": {
        "Homepage": "https://github.com/taizan-hokuto/pytchat"
    },
    "split_keywords": [
        "youtube",
        "livechat",
        "asyncio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d3cffaf50b3b28680e424ea41bcad26ecd8b58421645d86173c8802a1ea8d48",
                "md5": "139d0e4470ada4aa6d6e4ca389bb59f4",
                "sha256": "2e3fba357320e7731c16e712084f536bf0e0e20b3b45a9c59865971d9907ad63"
            },
            "downloads": -1,
            "filename": "pytchat-0.5.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "139d0e4470ada4aa6d6e4ca389bb59f4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 69516,
            "upload_time": "2021-07-24T14:04:31",
            "upload_time_iso_8601": "2021-07-24T14:04:31.988433Z",
            "url": "https://files.pythonhosted.org/packages/6d/3c/ffaf50b3b28680e424ea41bcad26ecd8b58421645d86173c8802a1ea8d48/pytchat-0.5.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-07-24 14:04:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "taizan-hokuto",
    "github_project": "pytchat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": []
        }
    ],
    "lcname": "pytchat"
}
        
Elapsed time: 0.13374s