Exceptions

exception ayt_api.exceptions.YoutubeExceptions[source]

Bases: BaseException

Base exception for errors regarding the YouTube API.

exception ayt_api.exceptions.ResourceNotFound[source]

Bases: YoutubeExceptions

Base exceptions for errors relating to a missing YouTube resource.

exception ayt_api.exceptions.AuthException[source]

Bases: YoutubeExceptions

Base exceptions for errors related to authorisation.

Added in version 0.4.0.

exception ayt_api.exceptions.OAuth2Exception[source]

Bases: AuthException

Base exceptions for errors related to OAuth2.

Added in version 0.4.0.

exception ayt_api.exceptions.PlaylistNotFound(playlist_id: str | list[str])[source]

Bases: ResourceNotFound

Raises if the specified playlist id does not exist on YouTube.

playlist_id

The playlist id that was attempted to be fetched.

Type:

str

exception ayt_api.exceptions.VideoNotFound(video_id: str | list[str])[source]

Bases: ResourceNotFound

Raises if the specified video id does not exist on YouTube.

video_id

The video id that was attempted to be fetched.

Type:

str

exception ayt_api.exceptions.ChannelNotFound(channel_id: str | list[str] = None)[source]

Bases: ResourceNotFound

Raises if the specified channel id or username does not exist on YouTube.

channel_id

channel id that was attempted to be fetched if any.

Type:

Optional[str]

exception ayt_api.exceptions.CommentNotFound(comment_id: str | list[str])[source]

Bases: ResourceNotFound

Raises if the specified comment id does not exist on YouTube.

comment_id

comment id that was attempted to be fetched.

Type:

str

exception ayt_api.exceptions.VideoCategoryNotFound(category_id: str | list[str])[source]

Bases: ResourceNotFound

Raises if the specified video category id does not exist on YouTube.

category_id

video category id that was attempted to be fetched.

Type:

str

exception ayt_api.exceptions.WatermarkNotFound(message: str = None)[source]

Bases: ResourceNotFound

Raises if there is no watermark set for a channel

Added in version 0.4.0.

exception ayt_api.exceptions.InvalidMetadata(metadata: dict, message='The the data in the dictionary provided is invalid')[source]

Bases: YoutubeExceptions

Raises when invalid metadata is given.

metadata

The raw data that is invalid.

Type:

dict

exception ayt_api.exceptions.MissingDataFromMetadata(missing_data: str, metadata: dict, exception: Exception)[source]

Bases: InvalidMetadata

Raises when the metadata in the response is malformed.

raw_exception

The original exception raised to trigger this exception.

Type:

Exception

missing_data

The error message to send along with the exception.

Type:

str

exception ayt_api.exceptions.InvalidInput(invalid_input)[source]

Bases: YoutubeExceptions

Raises if an argument in a function is invalid or empty.

input

The invalid input that was provided.

Type:

Any

exception ayt_api.exceptions.InvalidKey[source]

Bases: AuthException

Exception that’s raised when an invalid API key is passed.

exception ayt_api.exceptions.InvalidToken[source]

Bases: OAuth2Exception

Exception that’s raised when an OAuth token is invalid, expired or one is needed.

Added in version 0.4.0.

exception ayt_api.exceptions.NoAuth[source]

Bases: AuthException

Exception that is raised when neither an api key nor an oauth token is provided to AsyncYoutubeAPI.

Added in version 0.4.0.

exception ayt_api.exceptions.NoSession[source]

Bases: OAuth2Exception

Raises when performing an operation that needs an OAuth2Session instance when there isn’t one.

Added in version 0.4.0.

exception ayt_api.exceptions.APITimeout(timeout_set: ClientTimeout)[source]

Bases: YoutubeExceptions

Exception that’s raised when the api does not respond within the timeout set.

timeout_set

The timeout that was set.

Type:

int

exception ayt_api.exceptions.HTTPException(response: ClientResponse, message: str = None, error_data: dict = None)[source]

Bases: YoutubeExceptions

Exception that’s raised when an HTTP request operation fails.

response

The aiohttp response associated with the error.

Type:

ClientResponse

message

The error message associated with the error that the YouTube api gave.

Type:

str

status

The HTTP status code associated with the error.

Type:

int

error_data

The raw error data associated with the error.

Type:

dict