Skip to main content

A Python library for Twitch & Youtube Stream Notification.

Project description

Contributors Forks Stargazers Issues MIT License
PyPI - Version PyPI - PyVersion

TYStream

TYStream is A Python library for Twitch & Youtube Stream Notification.

安裝套件

# Windows
pip install tystream

# Linux/MacOS
python3 -m pip install tystream

註冊API

Twitch

  1. 前往 Twitch Developers 並登入你的帳號,接著點擊右上角的 Your Consoleimage
  2. 點選左側欄位的應用程式,再點選 註冊您的應用程式image
  3. 為你的應用程式取一個自己的名字!其餘的照圖填入並按下建立即可。 image
  4. 回到第三步驟的畫面後,點選剛建立好的應用程式最右側按鈕管理再點選最底下的 新密碼 底下便會多出用戶端ID用戶端密碼兩個欄位的金鑰。
    image
  5. 很好,你已經完成了所有步驟!請將剛拿到的兩組金鑰記好,不要隨意外洩!

Youtube

  1. 前往 Google Cloud Platform 並登入你的帳號。
  2. 點選最上方欄位的 選取專案,再點選右上角的新增專案image
  3. 按下建立後,依照圖片的搜尋方法找到 YouTube Data API v3 image

[!WARNING] 如果這步驟沒有正確啟用,那麼在使用套件的途中就會出現狀況。

  1. 點選 啟用 image

  2. 啟用完成後,點選左側欄位中的 憑證,再點選上方的 建立憑證,選擇 API 金鑰 image

  3. 複製彈出視窗的API金鑰,並將此金鑰記下來,大功告成(ノ>ω<)ノ image

如何使用

Twitch

client_idclient_secret 分別為你在 註冊API教學 (Twitch) 中拿到的 用戶端ID用戶端密碼
streamer_nametwitch.tv/... 後的名稱

同步方法

from tystream import SyncTwitch
twitch = SyncTwitch("client_id", "client_secret")
stream = twitch.check_stream_live("streamer_name")
print(stream)

非同步方法

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 為你在 註冊API教學 (Youtube) 中拿到的 API金鑰
streamer_name 為實況主頻道網址 https://www.youtube.com/... 後的名稱 (有無@都亦可)

同步方法

from tystream import SyncYoutube
youtube = SyncYoutube("api_key")
stream = youtube.check_stream_live("streamer_name")
print(stream)

非同步方法

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 方式

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tystream-1.6.1.1.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tystream-1.6.1.1-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file tystream-1.6.1.1.tar.gz.

File metadata

  • Download URL: tystream-1.6.1.1.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for tystream-1.6.1.1.tar.gz
Algorithm Hash digest
SHA256 dabf9f35f6cb34161e29fd5367a62c8b74cc1575752dbf041d0709cdd154dcb3
MD5 95b9b573cd14c4f97b74b3b4f9c3dd02
BLAKE2b-256 55e71e45afd4af5a6c87ac94b4f5d30efa2ea1eb4523ff1c71a18e7f5279b782

See more details on using hashes here.

File details

Details for the file tystream-1.6.1.1-py3-none-any.whl.

File metadata

  • Download URL: tystream-1.6.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for tystream-1.6.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 43138f774383cb66dfd87d73b7742ca3468fffc3f0a3e0af93aadfb3e7792c67
MD5 c9f835b43db5bd396faf0d23240c4356
BLAKE2b-256 d5f450744dd181c6a2291092d4b087411fc9162bf45d794670791b93f3d3ada4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page