# TYStream
TYStream is A Python library for Twitch & Youtube Stream Notification.
[![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-shield]][pypi-url]
## 安裝套件
```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.url)
```
### 非同步方法
```py
from tystream.async_api import Twitch
import asyncio
async def main():
twitch = Twitch("client_id", "client_secret")
stream = await twitch.check_stream_live("kannazukilubee")
print(stream.url)
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.url)
```
### 非同步方法
```py
from tystream.async_api import Youtube
import asyncio
async def main():
youtube = Youtube("api_key")
stream = await youtube.check_stream_live("kannazukilubee")
print(stream.url)
asyncio.run(main())
```
<!-- SHIELDS -->
[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/Mantou-9487/Mantouisyummy/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/master/LICENSE.md
[pypi-shield]: https://img.shields.io/pypi/v/tystream?style=for-the-badge
[pypi-url]: https://pypi.org/project/tystream/
Raw data
{
"_id": null,
"home_page": "https://github.com/Mantouisyummy/TYStream",
"name": "tystream",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "Twitch,Youtube,stream,stream Notification,Notification",
"author": "Mantouisyummy",
"author_email": "opcantel@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/17/10/043cca529a3412a45c85d78dff9e615cceb5d93954fc6af07439efa7055e/tystream-1.3.1.tar.gz",
"platform": null,
"description": "# TYStream\nTYStream is A Python library for Twitch & Youtube Stream Notification.\n\n[![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-shield]][pypi-url]\n\n\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.url)\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(\"kannazukilubee\")\n print(stream.url)\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.url)\n```\n### \u975e\u540c\u6b65\u65b9\u6cd5\n```py\nfrom tystream.async_api import Youtube\nimport asyncio\n\nasync def main():\n youtube = Youtube(\"api_key\")\n stream = await youtube.check_stream_live(\"kannazukilubee\")\n print(stream.url)\n\nasyncio.run(main())\n\n```\n<!-- SHIELDS -->\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/Mantou-9487/Mantouisyummy/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/master/LICENSE.md\n\n[pypi-shield]: https://img.shields.io/pypi/v/tystream?style=for-the-badge\n\n[pypi-url]: https://pypi.org/project/tystream/\n",
"bugtrack_url": null,
"license": "GNU",
"summary": "A Python library for Twitch & Youtube Stream Notification.",
"version": "1.3.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": "9acdfce66e167501b8de24c358b8edde9b375a735a2195aec21562af6abf3f13",
"md5": "9010af1c9fd8d2f0a80127b9ec9ebc9a",
"sha256": "ac3e5d2fd50d0e9e57905ad35bb0ef97a24b0b802a554ff0f98c7607e7d2ff9f"
},
"downloads": -1,
"filename": "tystream-1.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9010af1c9fd8d2f0a80127b9ec9ebc9a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 11664,
"upload_time": "2024-03-08T07:06:06",
"upload_time_iso_8601": "2024-03-08T07:06:06.351824Z",
"url": "https://files.pythonhosted.org/packages/9a/cd/fce66e167501b8de24c358b8edde9b375a735a2195aec21562af6abf3f13/tystream-1.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1710043cca529a3412a45c85d78dff9e615cceb5d93954fc6af07439efa7055e",
"md5": "fc3d9aa4fad7621ba7587694d2d0c052",
"sha256": "44ace86892e7db605b31bdf6331cc6a6129ce0d85e66407ebd74feddf74940a8"
},
"downloads": -1,
"filename": "tystream-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "fc3d9aa4fad7621ba7587694d2d0c052",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11857,
"upload_time": "2024-03-08T07:06:07",
"upload_time_iso_8601": "2024-03-08T07:06:07.975769Z",
"url": "https://files.pythonhosted.org/packages/17/10/043cca529a3412a45c85d78dff9e615cceb5d93954fc6af07439efa7055e/tystream-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-08 07:06:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Mantouisyummy",
"github_project": "TYStream",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tystream"
}