Youtube¶
This Cog enables the bot’s YouTube livestream-checking capabilities. It
uses streamlink to get the stream’s URL and yt_dlp to get the
stream’s title and thumbnail.
Hint
To enable this cog, set the ENABLE_YT variable.
Requirements¶
Packages¶
The
streamlinkpackage:
python3 -m install -U streamlink
py -m pip install -U streamlink
New in version 1.1.0.
The
yt_dlppackage:
python3 -m install -U yt-dlp
py -m pip install -U yt-dlp
Note
For backwards compatibility with the pre-v1.1.0 Music cog, the
youtube-dl package can be used. However its use in this bot is
deprecated and installing yt-dlp is recommended.
env variables¶
YT_FILErepresents the path to a JSON file which contains the IDs of the Discord users to notify, and the info of the streamers to check.This cog implicitly uses the
TW_FREQUENCYvariable from the Twitch cog. It indicates how often the bot checks the streams, in minutes. If need be, just createYT_FREQUENCYin.envand make the appropriate changes inbot.py.
Format used by YT_FILE¶
The format to use for YT_FILE is as follows:
{
"discord_user_ID_1": {
"youtube_channel_1": {
"nickname": "streamers_nickname_1",
"url": "channel_url_1"
},
"youtube_channel_2": {
"nickname": "streamers_nickname_2",
"url": "channel_url_2"
}
},
"discord_user_ID_2": {
"youtube_channel_1": {
"nickname": "streamers_nickname_1",
"url": "channel_url_1"
},
"youtube_channel_3": {
"nickname": "streamers_nickname_3",
"url": "channel_url_3"
}
}
}
Note
The youtube_channel and nickname keys are arbitrary.
youtube_channel is used to make it easier to identify the
channel in the logs, while nickname is used to have an
identifiable name in the message (since we can’t get that info
through the API). They can have the same value.
Fill it with the corresponding information and set YT_FILE in
.env. The Discord user’s ID can be found by right-clicking the
user’s name.