v0.1 release date 2019/09/08
v0.2 預計加入 到達某時間才開始獲取request
支援一個 Youtube 頻道直播提醒
發布至 Discord 單一伺服器 指定文字頻道
1.安裝 Python 3.5 或以上版本
But還需安裝2個Library
- 開啟命令提示字元(cmd.exe) 輸入
python -m pip install discord.py
python -m pip install requests
並在同一目錄下建立 locallive.txt
內容預設為
live_status=0
若不小心終止機器人,狀態會保持在最後一次取得,特別注意
2.取得 Youtube Data Api Key
- 使用記事本(notepad.exe)紀錄備用
3.取得 Discord Bot token
- 使用記事本(notepad.exe)紀錄備用
Discord 開發者官網
Discord Bot 建立及取得 Bot Token 教學
Thanks for reactiflux
4.取得Youtube Channel ID
- 使用記事本(notepad.exe)紀錄備用
不清楚不知道就靠這個網站
Youtube Channel ID, info and statistics - Comment Picker
5.取得 Discord 伺服器指定文字頻道 ID
- 使用記事本(notepad.exe)紀錄備用
在 Discord 客戶端中啟用開發者模式,以獲得伺服器
指定文字頻道ID
使用者設定
->外觀
-> 在進階選項中勾選開發者模式
右鍵該文字頻道,然後單擊複製ID
,獲得頻道ID
*** ### 通知內容格式
預設開播通知顯示內容
@everyone
頻道名稱
直播主題
直播網址
預設結束直播通知
Stream is off ,thank you for your watching
僅更改內容
使用 notepad++ 或其他工具編輯 (Debug 心理準備)
更改 Youtube channel id
& Youtube Data Api Key
& Discord 伺服器指定文字頻道ID
& Discord Bot token
17 'channelId' : 'YOUTBUE CHANNEL ID'
20 'key' : 'YOUTUBE DATA API KEY'
38 channel = client.get_channel(COPY DISCORD CHANNEL ID)
130 client.run('DISCORD BOT TOKEN')
更改Bot檢查直播的頻率
記住Youtube Data Api 配額為1天1萬單位,建議值在4~8分鐘一次
在我的測試中,獲得1次request花費了102個單位
按照配額來算代表1天只能請求98次
Bot在倒數時,若在這時候開播或關播,無法及時通知,造成延遲通知
12 pingEveryXMinutes = 6
點擊兩下 discord youtube live notify bot .py 執行