C
C#12mo ago
Arsenic

Get Youtube thumbnail

I am developing a Discord bot, but I have a problem, how can I use YouTube video thumbnails?
7 Replies
Arsenic
ArsenicOP12mo ago
my bot finds and plays the song from YouTube, but I want to use the video thumbnail as well
Thinker
Thinker12mo ago
Be aware that playing songs off of YouTube through eg. a bot is against YouTube's terms of service. In any case, YouTube has an official API you can use to fetch video metadata like thumbnails, titles, descriptions, etc.
Thinker
Thinker12mo ago
Google for Developers
YouTube Data API  |  Google for Developers
Add YouTube features to your application, including the ability to upload videos, create and manage playlists, and more.
Tvde1
Tvde112mo ago
There are C# nuget packages for this
arion
arion12mo ago
For thumbnails you just take the video ID and slap it in either of these links https://img.youtube.com/vi/VIDEO_ID/maxresdefault.jpg https://img.youtube.com/vi/VIDEO_ID/hqdefault.jpg https://img.youtube.com/vi/VIDEO_ID/mqdefault.jpg Bear in mind, sometimes the highest quality is not available so a placeholder is put that looks like this:
No description
arion
arion12mo ago
Here's a regex to get the video id from a link
^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|shorts\/|embed\/|v\/)?)([\w\-]+)(\S+)?$
^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|shorts\/|embed\/|v\/)?)([\w\-]+)(\S+)?$
arion
arion12mo ago
Nick Chapsas
YouTube
The New Data Protection Features of .NET 8 (GDPR)
Use code CLEAN20 and get 20% off the brand new "Deep Dive in Clean Architecture" course on Dometrain: https://dometrain.com/course/deep-dive-clean-architecture-in-dotnet/?coupon_code=CLEAN20 Get the source code: https://mailchi.mp/dometrain/rk3-to7k6i8 Become a Patreon and get special perks: https://www.patreon.com/nickchapsas Hello everybody...
Want results from more Discord servers?
Add your server