Package: youtubepy
youtubepyyoutubepy is a package to search for youtube videos through python code.Installationpip install youtubepyORpip3 install youtubepyUsageVideo classfromyoutubepyimportVideovideo=Video("me at the zoo")result=video.search()print(result)>https://www.youtube.com/watch?v=A8AlbaDmaecSafeSearch FilterfromyoutubepyimportVideovideo=Video("fuck",safesearch=True)result=video.search()print(result)>"youtubepy.BlockedWordError: A blocked word detected in the result video! Don't use safesearch to ignore this error!"Functions available in Video classsearch() - Returns video url
source_url() - Returns the source url of the video
audio_source() - Returns the audio source url of the video
download(/path/to/directory/filename.mp4) - Downloads the video
audio_download(/path/to/directory/filename.mp3) - Downloads the audio of a youtube video
title() - Returns video title
description() - Returns description of the video
channel_url() - Returns the url of the channel that published the video
channel_name() - Returns the name of the channel that published the video
published_date() - Returns the date the video was published to YouTube
thumbnail_url() - Returns thumbnail url of the video
thumbnail_save(/path/to/directory/filename.jpg) - Saves the thumbnail of the video, if path is not given, saves to the path in which the script is saved
duration() - Returns duration of the video
view_count() - Returns view count of the video
like_count() - Returns like count of the video
dislike_count() - Returns dislike count of the video
average_rating() - Returns average rating of the videoExtractData classfromyoutubepyimportExtractDatavideo=ExtractData("https://youtu.be/A8AlbaDmaec")title=video.title()print(title)>Meatthezoo-4kUpscaled,60FPSFunctions available in ExtractData classsource_url() - Returns the source url of the video
audio_source() - Returns the audio source url of the video
download(/path/to/directory/filename.mp4) - Downloads the video
audio_download(/path/to/directory/filename.mp3) - Downloads the audio of a youtube video
title() - Returns video title
description() - Returns description of the video
channel_url() - Returns the url of the channel that published the video
channel_name() - Returns the name of the channel that published the video
published_date() - Returns the date the video was published to YouTube
thumbnail_url() - Returns thumbnail url of the video
thumbnail_save(/path/to/directory/to/save/filename.jpg) - Saves the thumbnail of the video, if path is not given, saves to the path in which the script is saved
duration() - Returns duration of the video
view_count() - Returns view count of the video
like_count() - Returns like count of the video
dislike_count() - Returns dislike count of the video
average_rating() - Returns average rating of the videoThis package also has asynchronous working classes that are used in discord.py for creating non-blocking commands!AsyncVideo class#discord.py example!importdiscordimportasyncioimportyoutubepyfromdiscord.extimportcommandsbot=commands.Bot(command_prefix="!")@bot.command()asyncdefyoutube(ctx,query):video=youtubepy.AsyncVideo("spooky scary skeletons")url=awaitvideo.search()awaitctx.send(url)Functions of AsyncVideo class are same as Video classAsyncExtractData class#Not a discord.py example!importyoutubepyimportasyncioasyncdefget_title():video=youtubepy.AsyncExtractData("https://youtu.be/XTgFtxHhCQ0")title=awaitvideo.title()print(title)asyncio.run(get_title())Functions of AsyncExtractData class are same as ExtractData classIt is highly recommended to use the asynchronous classes while using youtubepy in discord.py as using non-asynchronous classes in discord.py can make your code extremely blocking! In simple language, using non-asynchronous classes in discord.py is same as using time.sleep() in your bot code!