Skip to content

~.youtube

YouTube

YouTubeThumbnail

YouTubeThumbnail(data: dict[str, str | int])

YouTube thumbnail data.

Create a new thumbnail container.

PARAMETER DESCRIPTION
data

The raw thumbnail data.

TYPE: dict[str, str | int]

height property

height: int

The height of this thumbnail in pixels.

url property

url: str

The media URL of this thumbnail.

width property

width: int

The width of this thumbnail in pixels.

YouTubePartialVideo

YouTubePartialVideo(data: dict[str, Any])

Partial YouTube video data.

Create a new partial YouTube video container.

PARAMETER DESCRIPTION
data

The raw video data.

TYPE: dict[str, Any]

channel property

channel: str | None

The name of the channel that uploaded the video, if provided.

channel_id property

channel_id: str | None

The ID of the channel that uploaded the video, if provided.

description property

description: str | None

The description of the video, if provided.

duration property

duration: float | None

The duration of the video in seconds, if provided.

id property

id: str | None

The ID of the video, if provided.

thumbnail property

thumbnail: str | None

The URL of the primary thumbnail of the video, if provided.

thumbnails property

thumbnails: list[YouTubeThumbnail]

A collection of all video thumbnails, if provided.

timestamp property

timestamp: int | None

The time in which this video was uploaded, if provided.

title property

title: str

The title of the video.

url property

url: str

The URL of the video page.

view_count property

view_count: int | None

The amount of views this video has, if provided.

YouTubeSearchResult

YouTubeSearchResult(query: str, data: dict[str, Any])

Result of a YouTube search.

Create a new YouTube search result.

PARAMETER DESCRIPTION
query

The query used to search YouTube.

TYPE: str

data

The raw data passed from yt-dlp's search query.

TYPE: dict[str, Any]

query property

query: str

The search query resulting in this result.

raw property

raw: dict[str, Any]

The raw data from the query request.

videos property

The parsed video data from the query request.

YouTube

Utility class containing UX features for YouTube.

Warning

This is an experimental feature. This may change or be removed with or without notice at any time.

queue_from_playlist async staticmethod

queue_from_playlist(
    player: AudioPlayer,
    url: str,
    *,
    limit: int = None,
    autoplay: bool = True,
    shuffle: bool = False
) -> list[YouTubeAudioSource]

Queue audio from a YouTube playlist into an audio player queue.

PARAMETER DESCRIPTION
player

The audio player to queue the audio in.

TYPE: AudioPlayer

url

The YouTube playlist URL to add.

TYPE: str

limit

If provided, the maximum amount of audio to queue.

TYPE: int DEFAULT: None

autoplay

If provided, controls if the player should automatically play the first queued audio if the player isn't playing anything.

TYPE: bool DEFAULT: True

shuffle

If provided, if the queued audio should be shuffled instead of the order of the playlist.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
list[YouTubeAudioSource]

A reference to all audio added to the queue.

RAISES DESCRIPTION
TypeError
  • If player is not AudioPlayer.
  • If url is not str.
  • If limit is provided and is not int.
  • If autoplay is provided and is not bool.
  • If shuffle is provided and is not bool.
ValueError
  • If url is not a valid YouTube playlist URL.
  • If limit is provided and is not at least 1.
Warning

This is an experimental feature. This may change or be removed with or without notice at any time.

search async staticmethod

search(
    query: str, limit: int = 10
) -> YouTubeSearchResult | None

Asynchronously search YouTube via a query.

PARAMETER DESCRIPTION
query

The keywords/query to search YouTube with.

TYPE: str

limit

The maximum amount of results to return.

TYPE: int DEFAULT: 10

RETURNS DESCRIPTION
YouTubeSearchResult

The resulting search from the query, if successful.

RAISES DESCRIPTION
TypeError
  • If query is not a str.
  • If limit is provided and not int.
ValueError
  • If query length is less than 1.
  • If limit is less than 1.
Warning

This is an experimental feature. This may change or be removed with or without notice at any time.

search_sync staticmethod

search_sync(
    query: str, limit: int = 10
) -> YouTubeSearchResult | None

Synchronously search YouTube via a query.

PARAMETER DESCRIPTION
query

The keywords/query to search YouTube with.

TYPE: str

limit

The maximum amount of results to return.

TYPE: int DEFAULT: 10

RETURNS DESCRIPTION
YouTubeSearchResult

The resulting search from the query, if successful.

RAISES DESCRIPTION
TypeError
  • If query is not a str.
  • If limit is provided and not int.
ValueError
  • If query length is less than 1.
  • If limit is less than 1.
Warning

This is an experimental feature. This may change or be removed with or without notice at any time.