![PyPI - Version](https://img.shields.io/pypi/v/tystream?style=for-the-badge&color=green&link=https%3A%2F%2Fpypi.org%2Fproject%2Ftystream%2F)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tystream?style=for-the-badge&link=https%3A%2F%2Fpypi.org%2Fproject%2Ftystream%2F)
# TYStream
TYStream is A Python library for Twitch & Youtube Stream Notification.
## 安裝套件
```python
# 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 Twitch
twitch = Twitch("client_id", "client_secret")
stream = twitch.check_stream_live("streamer_name")
print(stream)
```
### 非同步方法
```py
from tystream.async_api import Twitch
import asyncio
async def main():
twitch = Twitch("client_id", "client_secret")
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 Youtube
youtube = Youtube("api_key")
stream = youtube.check_stream_live("streamer_name")
print(stream)
```
### 非同步方法
```py
from tystream.async_api import Youtube
import asyncio
async def main():
youtube = Youtube("")
stream = await youtube.check_stream_live("streamer_name")
print(stream)
asyncio.run(main())
```
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/cd/1a/715988bf8d5b94d27507d9a13d7c8e8f5d827d08f301c934650320763531/tystream-1.5.1.tar.gz",
"platform": null,
"description": "![PyPI - Version](https://img.shields.io/pypi/v/tystream?style=for-the-badge&color=green&link=https%3A%2F%2Fpypi.org%2Fproject%2Ftystream%2F)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tystream?style=for-the-badge&link=https%3A%2F%2Fpypi.org%2Fproject%2Ftystream%2F)\n# TYStream\nTYStream is A Python library for Twitch & Youtube Stream Notification.\n\n## \u5b89\u88dd\u5957\u4ef6\n```python\n# Windows\npip install tystream\n\n# Linux/MacOS\n\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 Twitch\ntwitch = Twitch(\"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 Twitch\nimport asyncio\n\nasync def main():\n twitch = Twitch(\"client_id\", \"client_secret\")\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 Youtube\nyoutube = Youtube(\"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 Youtube\nimport asyncio\n\nasync def main():\n youtube = Youtube(\"\")\n stream = await youtube.check_stream_live(\"streamer_name\")\n print(stream)\n\nasyncio.run(main())\n```\n",
"bugtrack_url": null,
"license": "GNU",
"summary": "A Python library for Twitch & Youtube Stream Notification.",
"version": "1.5.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": "",
"digests": {
"blake2b_256": "c934de39a4018499936dbdc769fdbd30cd3a83d5b07e0cb1f43e82c508984d8e",
"md5": "87cbcbdc85a1cc97159675dd7fd0b02a",
"sha256": "2672df61c165af466da31d2c1bc310da8a44f928a12746a80caa0e332d2df80f"
},
"downloads": -1,
"filename": "tystream-1.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "87cbcbdc85a1cc97159675dd7fd0b02a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9402,
"upload_time": "2024-07-16T09:00:28",
"upload_time_iso_8601": "2024-07-16T09:00:28.169910Z",
"url": "https://files.pythonhosted.org/packages/c9/34/de39a4018499936dbdc769fdbd30cd3a83d5b07e0cb1f43e82c508984d8e/tystream-1.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cd1a715988bf8d5b94d27507d9a13d7c8e8f5d827d08f301c934650320763531",
"md5": "2874558982f903ad7e5c59904efd32ac",
"sha256": "83cc00c7e69ba69a66c7ebd5a33a5beecdebcd358764226cbe11aa76fe22b925"
},
"downloads": -1,
"filename": "tystream-1.5.1.tar.gz",
"has_sig": false,
"md5_digest": "2874558982f903ad7e5c59904efd32ac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 9725,
"upload_time": "2024-07-16T09:00:29",
"upload_time_iso_8601": "2024-07-16T09:00:29.682953Z",
"url": "https://files.pythonhosted.org/packages/cd/1a/715988bf8d5b94d27507d9a13d7c8e8f5d827d08f301c934650320763531/tystream-1.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-16 09:00:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Mantouisyummy",
"github_project": "TYStream",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tystream"
}