Skip to content

vincent-chang-rightfighter/discord-youtube-live-notify-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[Python]Discord Youtube直播通知機器人 AKA. Discord-youtube-live-notify-bot

版本

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)紀錄備用

Youtube Api 教學


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在倒數時,若在這時候開播或關播,無法及時通知,造成延遲通知

Imgur

12 pingEveryXMinutes = 6  


執行

點擊兩下 discord youtube live notify bot .py 執行

About

Discord-youtube-live-notify-bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages