tystream


Nametystream JSON
Version 1.6.1.1 PyPI version JSON
download
home_pagehttps://github.com/Mantouisyummy/TYStream
SummaryA Python library for Twitch & Youtube Stream Notification.
upload_time2025-02-27 11:57:48
maintainerNone
docs_urlNone
authorMantouisyummy
requires_python>=3.10
licenseGNU
keywords twitch youtube stream stream notification notification
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]  
[![PyPI - Version][pypi-version-shield]][pypi-url]
[![PyPI - PyVersion][pypi-pyversion-shield]][pypi-url]
# TYStream
TYStream is A Python library for Twitch & Youtube Stream Notification.

## 安裝套件
```sh
# Windows
pip install tystream

# Linux/MacOS
python3 -m pip install tystream
```

## 註冊API
### Twitch
1. 前往 [Twitch Developers](https://dev.twitch.tv/) 並登入你的帳號,接著點擊右上角的 `Your Console`。
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/8d4137a2-fb1c-4c01-8c1a-a03ea181a1b3)
1. 點選左側欄位的應用程式,再點選 `註冊您的應用程式`。
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/06011479-aa80-4def-a34a-a5f220ad971c)
3. 為你的應用程式取一個自己的名字!其餘的照圖填入並按下`建立`即可。
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/12f4e911-abe4-4367-954f-96cacc44f30a)
4. 回到第三步驟的畫面後,點選剛建立好的應用程式最右側按鈕`管理`再點選最底下的 `新密碼`  底下便會多出`用戶端ID`和`用戶端密碼`兩個欄位的金鑰。  
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/1b8a0c62-31c6-4f00-a456-96c7bf4a46b4)
5. 很好,你已經完成了所有步驟!請將剛拿到的兩組金鑰記好,不要隨意外洩!
### Youtube
1. 前往 [Google Cloud Platform](https://console.cloud.google.com/?hl=zh-tw) 並登入你的帳號。
2. 點選最上方欄位的 `選取專案`,再點選右上角的`新增專案`。
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/ae2bd559-6a55-4bf8-95d4-86b1e46619b8)
3. 按下`建立`後,依照圖片的搜尋方法找到 `YouTube Data API v3`
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/2697cab3-3ce5-412c-85b8-64abfad8f91d)
> [!WARNING]
> 如果這步驟沒有正確啟用,那麼在使用套件的途中就會出現狀況。
4. 點選 `啟用`
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/8fd69240-88db-4d7e-b212-28892b142ade)

5. 啟用完成後,點選左側欄位中的 `憑證`,再點選上方的 `建立憑證`,選擇 `API 金鑰`
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/47666706-c172-4301-a48c-07108e3926c8)
6. 複製彈出視窗的API金鑰,並將此金鑰記下來,大功告成(ノ>ω<)ノ
![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/1b7c2f35-440d-475e-a2d5-ee4a5125a5ea)

## 如何使用

### Twitch
`client_id` 和 `client_secret` 分別為你在 <a href="#twitch">註冊API教學 (Twitch)</a> 中拿到的 `用戶端ID`和`用戶端密碼`   
`streamer_name` 為 `twitch.tv/...` 後的名稱
### 同步方法
```py
from tystream import SyncTwitch
twitch = SyncTwitch("client_id", "client_secret")
stream = twitch.check_stream_live("streamer_name")
print(stream)
```
### 非同步方法
```py
from tystream.async_api import AsyncTwitch
import asyncio

async def main():
    async with AsyncTwitch("client_id", "client_secret") as twitch:
        stream = await twitch.check_stream_live("streamer_name")
        print(stream)

asyncio.run(main())
```

### Youtube
`api_key` 為你在 <a href="#youtube">註冊API教學 (Youtube)</a> 中拿到的 `API金鑰`  
`streamer_name` 為實況主頻道網址 `https://www.youtube.com/...` 後的名稱 (有無`@`都亦可)
### 同步方法
```py
from tystream import SyncYoutube
youtube = SyncYoutube("api_key")
stream = youtube.check_stream_live("streamer_name")
print(stream)
```
### 非同步方法
```py
from tystream.async_api import AsyncYoutube
import asyncio

async def main():
    async with AsyncYoutube("api_key") as youtube:
        stream = await youtube.check_stream_live("streamer_name")
        print(stream)

asyncio.run(main())
```
### 使用 yt_dlp 方式
```py
from tystream.async_api import AsyncYoutube # or SyncYoutube
import asyncio

async def main():
    async with AsyncYoutube() as youtube:
        stream = await youtube.check_stream_live("streamer_name", use_yt_dlp=True) # default is False
        print(stream)

asyncio.run(main())
```

<!-- SHIELDS -->

[pypi-pyversion-shield]: https://img.shields.io/pypi/pyversions/tystream?style=for-the-badge

[pypi-version-shield]: https://img.shields.io/pypi/v/tystream?style=for-the-badge&color=green

[pypi-url]: https://pypi.org/project/tystream/

[contributors-shield]: https://img.shields.io/github/contributors/Mantouisyummy/TYStream.svg?style=for-the-badge

[contributors-url]: https://github.com/Mantouisyummy/TYStream/graphs/contributors

[forks-shield]: https://img.shields.io/github/forks/Mantouisyummy/TYStream.svg?style=for-the-badge

[forks-url]: https://github.com/Mantouisyummy/TYStream/network/members

[stars-shield]: https://img.shields.io/github/stars/Mantouisyummy/TYStream.svg?style=for-the-badge

[stars-url]: https://github.com/Mantouisyummy/TYStream/stargazers

[issues-shield]: https://img.shields.io/github/issues/Mantouisyummy/TYStream.svg?style=for-the-badge

[issues-url]: https://github.com/Mantouisyummy/TYStream/issues

[license-shield]: https://img.shields.io/github/license/Mantouisyummy/TYStream.svg?style=for-the-badge

[license-url]: https://github.com/Mantouisyummy/TYStream/blob/main/LICENSE.txt

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mantouisyummy/TYStream",
    "name": "tystream",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "Twitch, Youtube, stream, stream Notification, Notification",
    "author": "Mantouisyummy",
    "author_email": "opcantel@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/55/e7/1e45afd4af5a6c87ac94b4f5d30efa2ea1eb4523ff1c71a18e7f5279b782/tystream-1.6.1.1.tar.gz",
    "platform": null,
    "description": "[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]  \n[![PyPI - Version][pypi-version-shield]][pypi-url]\n[![PyPI - PyVersion][pypi-pyversion-shield]][pypi-url]\n# TYStream\nTYStream is A Python library for Twitch & Youtube Stream Notification.\n\n## \u5b89\u88dd\u5957\u4ef6\n```sh\n# Windows\npip install tystream\n\n# Linux/MacOS\npython3 -m pip install tystream\n```\n\n## \u8a3b\u518aAPI\n### Twitch\n1. \u524d\u5f80 [Twitch Developers](https://dev.twitch.tv/) \u4e26\u767b\u5165\u4f60\u7684\u5e33\u865f\uff0c\u63a5\u8457\u9ede\u64ca\u53f3\u4e0a\u89d2\u7684 `Your Console`\u3002\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/8d4137a2-fb1c-4c01-8c1a-a03ea181a1b3)\n1. \u9ede\u9078\u5de6\u5074\u6b04\u4f4d\u7684\u61c9\u7528\u7a0b\u5f0f\uff0c\u518d\u9ede\u9078 `\u8a3b\u518a\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f`\u3002\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/06011479-aa80-4def-a34a-a5f220ad971c)\n3. \u70ba\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u53d6\u4e00\u500b\u81ea\u5df1\u7684\u540d\u5b57\uff01\u5176\u9918\u7684\u7167\u5716\u586b\u5165\u4e26\u6309\u4e0b`\u5efa\u7acb`\u5373\u53ef\u3002\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/12f4e911-abe4-4367-954f-96cacc44f30a)\n4. \u56de\u5230\u7b2c\u4e09\u6b65\u9a5f\u7684\u756b\u9762\u5f8c\uff0c\u9ede\u9078\u525b\u5efa\u7acb\u597d\u7684\u61c9\u7528\u7a0b\u5f0f\u6700\u53f3\u5074\u6309\u9215`\u7ba1\u7406`\u518d\u9ede\u9078\u6700\u5e95\u4e0b\u7684 `\u65b0\u5bc6\u78bc`  \u5e95\u4e0b\u4fbf\u6703\u591a\u51fa`\u7528\u6236\u7aefID`\u548c`\u7528\u6236\u7aef\u5bc6\u78bc`\u5169\u500b\u6b04\u4f4d\u7684\u91d1\u9470\u3002  \n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/1b8a0c62-31c6-4f00-a456-96c7bf4a46b4)\n5. \u5f88\u597d\uff0c\u4f60\u5df2\u7d93\u5b8c\u6210\u4e86\u6240\u6709\u6b65\u9a5f\uff01\u8acb\u5c07\u525b\u62ff\u5230\u7684\u5169\u7d44\u91d1\u9470\u8a18\u597d\uff0c\u4e0d\u8981\u96a8\u610f\u5916\u6d29\uff01\n### Youtube\n1. \u524d\u5f80 [Google Cloud Platform](https://console.cloud.google.com/?hl=zh-tw) \u4e26\u767b\u5165\u4f60\u7684\u5e33\u865f\u3002\n2. \u9ede\u9078\u6700\u4e0a\u65b9\u6b04\u4f4d\u7684 `\u9078\u53d6\u5c08\u6848`\uff0c\u518d\u9ede\u9078\u53f3\u4e0a\u89d2\u7684`\u65b0\u589e\u5c08\u6848`\u3002\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/ae2bd559-6a55-4bf8-95d4-86b1e46619b8)\n3. \u6309\u4e0b`\u5efa\u7acb`\u5f8c\uff0c\u4f9d\u7167\u5716\u7247\u7684\u641c\u5c0b\u65b9\u6cd5\u627e\u5230 `YouTube Data API v3`\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/2697cab3-3ce5-412c-85b8-64abfad8f91d)\n> [!WARNING]\n> \u5982\u679c\u9019\u6b65\u9a5f\u6c92\u6709\u6b63\u78ba\u555f\u7528\uff0c\u90a3\u9ebc\u5728\u4f7f\u7528\u5957\u4ef6\u7684\u9014\u4e2d\u5c31\u6703\u51fa\u73fe\u72c0\u6cc1\u3002\n4. \u9ede\u9078 `\u555f\u7528`\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/8fd69240-88db-4d7e-b212-28892b142ade)\n\n5. \u555f\u7528\u5b8c\u6210\u5f8c\uff0c\u9ede\u9078\u5de6\u5074\u6b04\u4f4d\u4e2d\u7684 `\u6191\u8b49`\uff0c\u518d\u9ede\u9078\u4e0a\u65b9\u7684 `\u5efa\u7acb\u6191\u8b49`\uff0c\u9078\u64c7 `API \u91d1\u9470`\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/47666706-c172-4301-a48c-07108e3926c8)\n6. \u8907\u88fd\u5f48\u51fa\u8996\u7a97\u7684API\u91d1\u9470\uff0c\u4e26\u5c07\u6b64\u91d1\u9470\u8a18\u4e0b\u4f86\uff0c\u5927\u529f\u544a\u6210(\uff89>\u03c9<)\uff89\n![image](https://github.com/Mantouisyummy/TYStream/assets/51238168/1b7c2f35-440d-475e-a2d5-ee4a5125a5ea)\n\n## \u5982\u4f55\u4f7f\u7528\n\n### Twitch\n`client_id` \u548c `client_secret` \u5206\u5225\u70ba\u4f60\u5728 <a href=\"#twitch\">\u8a3b\u518aAPI\u6559\u5b78 (Twitch)</a> \u4e2d\u62ff\u5230\u7684 `\u7528\u6236\u7aefID`\u548c`\u7528\u6236\u7aef\u5bc6\u78bc`   \n`streamer_name` \u70ba `twitch.tv/...` \u5f8c\u7684\u540d\u7a31\n### \u540c\u6b65\u65b9\u6cd5\n```py\nfrom tystream import SyncTwitch\ntwitch = SyncTwitch(\"client_id\", \"client_secret\")\nstream = twitch.check_stream_live(\"streamer_name\")\nprint(stream)\n```\n### \u975e\u540c\u6b65\u65b9\u6cd5\n```py\nfrom tystream.async_api import AsyncTwitch\nimport asyncio\n\nasync def main():\n    async with AsyncTwitch(\"client_id\", \"client_secret\") as twitch:\n        stream = await twitch.check_stream_live(\"streamer_name\")\n        print(stream)\n\nasyncio.run(main())\n```\n\n### Youtube\n`api_key` \u70ba\u4f60\u5728 <a href=\"#youtube\">\u8a3b\u518aAPI\u6559\u5b78 (Youtube)</a> \u4e2d\u62ff\u5230\u7684 `API\u91d1\u9470`  \n`streamer_name` \u70ba\u5be6\u6cc1\u4e3b\u983b\u9053\u7db2\u5740 `https://www.youtube.com/...` \u5f8c\u7684\u540d\u7a31 (\u6709\u7121`@`\u90fd\u4ea6\u53ef)\n### \u540c\u6b65\u65b9\u6cd5\n```py\nfrom tystream import SyncYoutube\nyoutube = SyncYoutube(\"api_key\")\nstream = youtube.check_stream_live(\"streamer_name\")\nprint(stream)\n```\n### \u975e\u540c\u6b65\u65b9\u6cd5\n```py\nfrom tystream.async_api import AsyncYoutube\nimport asyncio\n\nasync def main():\n    async with AsyncYoutube(\"api_key\") as youtube:\n        stream = await youtube.check_stream_live(\"streamer_name\")\n        print(stream)\n\nasyncio.run(main())\n```\n### \u4f7f\u7528 yt_dlp \u65b9\u5f0f\n```py\nfrom tystream.async_api import AsyncYoutube # or SyncYoutube\nimport asyncio\n\nasync def main():\n    async with AsyncYoutube() as youtube:\n        stream = await youtube.check_stream_live(\"streamer_name\", use_yt_dlp=True) # default is False\n        print(stream)\n\nasyncio.run(main())\n```\n\n<!-- SHIELDS -->\n\n[pypi-pyversion-shield]: https://img.shields.io/pypi/pyversions/tystream?style=for-the-badge\n\n[pypi-version-shield]: https://img.shields.io/pypi/v/tystream?style=for-the-badge&color=green\n\n[pypi-url]: https://pypi.org/project/tystream/\n\n[contributors-shield]: https://img.shields.io/github/contributors/Mantouisyummy/TYStream.svg?style=for-the-badge\n\n[contributors-url]: https://github.com/Mantouisyummy/TYStream/graphs/contributors\n\n[forks-shield]: https://img.shields.io/github/forks/Mantouisyummy/TYStream.svg?style=for-the-badge\n\n[forks-url]: https://github.com/Mantouisyummy/TYStream/network/members\n\n[stars-shield]: https://img.shields.io/github/stars/Mantouisyummy/TYStream.svg?style=for-the-badge\n\n[stars-url]: https://github.com/Mantouisyummy/TYStream/stargazers\n\n[issues-shield]: https://img.shields.io/github/issues/Mantouisyummy/TYStream.svg?style=for-the-badge\n\n[issues-url]: https://github.com/Mantouisyummy/TYStream/issues\n\n[license-shield]: https://img.shields.io/github/license/Mantouisyummy/TYStream.svg?style=for-the-badge\n\n[license-url]: https://github.com/Mantouisyummy/TYStream/blob/main/LICENSE.txt\n",
    "bugtrack_url": null,
    "license": "GNU",
    "summary": "A Python library for Twitch & Youtube Stream Notification.",
    "version": "1.6.1.1",
    "project_urls": {
        "Homepage": "https://github.com/Mantouisyummy/TYStream",
        "Issue Tracker": "https://github.com/Mantouisyummy/TYStream"
    },
    "split_keywords": [
        "twitch",
        " youtube",
        " stream",
        " stream notification",
        " notification"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d5f450744dd181c6a2291092d4b087411fc9162bf45d794670791b93f3d3ada4",
                "md5": "c9f835b43db5bd396faf0d23240c4356",
                "sha256": "43138f774383cb66dfd87d73b7742ca3468fffc3f0a3e0af93aadfb3e7792c67"
            },
            "downloads": -1,
            "filename": "tystream-1.6.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c9f835b43db5bd396faf0d23240c4356",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 21204,
            "upload_time": "2025-02-27T11:57:47",
            "upload_time_iso_8601": "2025-02-27T11:57:47.052204Z",
            "url": "https://files.pythonhosted.org/packages/d5/f4/50744dd181c6a2291092d4b087411fc9162bf45d794670791b93f3d3ada4/tystream-1.6.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "55e71e45afd4af5a6c87ac94b4f5d30efa2ea1eb4523ff1c71a18e7f5279b782",
                "md5": "95b9b573cd14c4f97b74b3b4f9c3dd02",
                "sha256": "dabf9f35f6cb34161e29fd5367a62c8b74cc1575752dbf041d0709cdd154dcb3"
            },
            "downloads": -1,
            "filename": "tystream-1.6.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "95b9b573cd14c4f97b74b3b4f9c3dd02",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 18524,
            "upload_time": "2025-02-27T11:57:48",
            "upload_time_iso_8601": "2025-02-27T11:57:48.039032Z",
            "url": "https://files.pythonhosted.org/packages/55/e7/1e45afd4af5a6c87ac94b4f5d30efa2ea1eb4523ff1c71a18e7f5279b782/tystream-1.6.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-27 11:57:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Mantouisyummy",
    "github_project": "TYStream",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tystream"
}
        
Elapsed time: 1.08442s