youtubepy
youtubepy is a package to search for youtube videos through python code.
Installation
pip install youtubepy
OR
pip3 install youtubepy
Usage
Video class
from youtubepy import Video
video = Video("me at the zoo")
result = video.search()
print(result)
> https://www.youtube.com/watch?v=A8AlbaDmaec
SafeSearch Filter
from youtubepy import Video
video = 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 class
search() - 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 video
ExtractData class
from youtubepy import ExtractData
video = ExtractData("https://youtu.be/A8AlbaDmaec")
title = video.title()
print(title)
> Me at the zoo - 4k Upscaled, 60 FPS
Functions available in ExtractData class
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/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 video
This package also has asynchronous working classes that are used in discord.py for creating non-blocking commands!
AsyncVideo class
#discord.py example!
import discord
import asyncio
import youtubepy
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command()
async def youtube(ctx, query):
video = youtubepy.AsyncVideo("spooky scary skeletons")
url = await video.search()
await ctx.send(url)
Functions of AsyncVideo class are same as Video class
AsyncExtractData class
#Not a discord.py example!
import youtubepy
import asyncio
async def get_title():
video = youtubepy.AsyncExtractData("https://youtu.be/XTgFtxHhCQ0")
title = await video.title()
print(title)
asyncio.run(get_title())
Functions of AsyncExtractData class are same as ExtractData class
It 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!
Metadata
Release files for youtubepy 6.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| youtubepy-6.0.2.tar.gz | 10.6 kB | Without provenance | Details for youtubepy-6.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| youtubepy-6.0.2-py3-none-any.whl | Python 3 | none | any | Details for youtubepy-6.0.2-py3-none-any.whl |
Total release size: 20.5 kB
Release files / youtubepy-6.0.2.tar.gz
| Download URL | youtubepy-6.0.2.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20cfa29001247cf381970bc3ab1cf5ad9fbafa0ebddc24cd4cb0e3f1356c7593
|
|
BLAKE2b-256 checksum How to use checksums |
1bae6ac202d593845d9d027156bdbd72937bdef9ac8ea4d9e2e206c8d7f5383b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Release files / youtubepy-6.0.2-py3-none-any.whl
| Download URL | youtubepy-6.0.2-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d4bb1201227ac45f470ba1c65fde776f7397d55cf28d967211f144b93f08b5f
|
|
BLAKE2b-256 checksum How to use checksums |
dbb7e2cbc117ce135ba426bc3c5b6ee0cebe8d0b950460661238e5f1762e7679
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Security for youtubepy 6.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.