Metadata-Version: 2.4
Name: thememasterchat
Version: 0.1.1.1
Summary: a python library for fetching youtube live chat (fork of pytchat-ng, imports as thememasterchat).
Author: Theme Master
License-Expression: MIT
Project-URL: Homepage, https://github.com/ThemeMasterOS/ThemeMasterChat
Keywords: youtube,livechat,asyncio
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx[http2]
Provides-Extra: test
Requires-Dist: pytest-mock; extra == "test"
Requires-Dist: pytest-httpx; extra == "test"
Dynamic: license-file

# ThemeMasterChat

ThemeMasterChat is a python library for fetching youtube live chat.

> Forked from [pytchat-ng](https://github.com/revertical/pytchat-ng) (revertical), itself forked from [pytchat](https://github.com/taizan-hokuto/pytchat) (taizan-hokuto). As of v0.1.1.0, the Python import package is `thememasterchat` (previously `pytchat`).
> Upgrading from an older ThemeMasterChat release? `pip install -U thememasterchat` replaces its old `pytchat` import directory. You no longer need to uninstall the original `pytchat` / `pytchat-ng` to use ThemeMasterChat, but if they remain installed, `import pytchat` will resolve to those packages.

> [!WARNING]
> **Breaking change in v0.1.1.0:** the primary Python import changes from `pytchat` to `thememasterchat`.
>
> Before: `import pytchat`
> After: `import thememasterchat`
>
> Existing scripts using `import pytchat` may need to be updated. If the original `pytchat` package is installed, `import pytchat` will load that package, not ThemeMasterChat. See [Compatibility alias](#compatibility-alias-for-existing-pytchat-code).

<br><br><br>
## Description
ThemeMasterChat 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>

## Install
```python
pip install thememasterchat
```

## Import name and compatibility alias
The installed package is ThemeMasterChat, imported from `thememasterchat`:
```python
import thememasterchat
chat = thememasterchat.create(video_id="VIDEO_ID")
```

### Compatibility alias for existing `pytchat` code
If you do not want to rename your existing `pytchat` references, use a local Python import alias:
```python
import thememasterchat as pytchat
chat = pytchat.create(video_id="VIDEO_ID")
```
This is only a local Python import alias. The installed package is still ThemeMasterChat, imported from `thememasterchat`; the alias does not install or re-export the original `pytchat` package.

## Examples


### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))
```python
import thememasterchat
chat = thememasterchat.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 thememasterchat
import time

chat = thememasterchat.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>Native emojis use Unicode where available; custom emojis use ":(shortcut text):". Full URLs are restored from navigation metadata when reliable, including destinations decoded from YouTube redirect URLs.</td>
  </tr>
  <tr>
    <td>messageEx</td>
    <td>str</td>
    <td>list of message texts and emoji dicts(id, txt, url). Emoji txt uses shortcut text for compatibility.</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)


