YouTube Data Types¶
- class ayt_api.types.UseExisting[source]¶
Bases:
object
A dummy class that is used to indicate when updating an object to use the previous existing values
Added in version 0.4.0.
- class ayt_api.types.YoutubeThumbnail(url: str | None, _call_data: Any, width: int | None = None, height: int | None = None)[source]¶
Bases:
object
Data for an individual YouTube thumbnail.
- async download() bytes [source]¶
Downloads the thumbnail and stores it as a
bytes
object- Returns:
The image as a
bytes
object- Return type:
- Raises:
HTTPException – Fetching the request failed.
aiohttp.ClientError – There was a problem sending the request to the api.
RuntimeError – The contents was not a jpeg image
asyncio.TimeoutError – The i.ytimg.com server did not respond within the timeout period set.
- async save(fp: str | PathLike | None = None)[source]¶
Downloads the thumbnail and saves it to a specified location
- Parameters:
fp (os.PathLike | str) – The path and/or filename to save the file to. Defaults to current working directory with the filename format:
{video_id}-{quality}.png
- Raises:
HTTPException – Fetching the request failed.
aiohttp.ClientError – There was a problem sending the request to the api.
RuntimeError – The contents was not a jpeg image
asyncio.TimeoutError – The i.ytimg.com server did not respond within the timeout period set.
- class ayt_api.types.YoutubeBanner(url: str | None, _call_data: Any)[source]¶
Bases:
object
Data for an individual YouTube banner.
- async download(width: int | None = None) tuple[bytes, str] [source]¶
Downloads the banner and stores it as a
bytes
object- Parameters:
width (Optional[int]) – The width or number of horizontal pixels the downloaded image should have.
- Returns:
- A list containing the image as a
bytes
object and the file extension of the image
- A list containing the image as a
- Return type:
- Raises:
HTTPException – Fetching the request failed.
aiohttp.ClientError – There was a problem sending the request to the server.
RuntimeError – The contents was not a jpeg image
asyncio.TimeoutError – The yt3.ggpht.com or yt3.googleusercontent.com server did not respond within the
timeout period set. –
- async save(fp: str | PathLike | None = None, width: int = None)[source]¶
Downloads the banner specified and saves it to a specified location
- Parameters:
fp (os.PathLike | str) – The path and/or filename to save the file to. Defaults to current working directory with the filename format:
{banner_id}.{extension}
width (Optional[int]) – The width or number of horizontal pixels the downloaded image should have.
- Raises:
HTTPException – Fetching the request failed.
aiohttp.ClientError – There was a problem sending the request to the server.
RuntimeError – The contents was not a jpeg image
asyncio.TimeoutError – The yt3.ggpht.com or yt3.googleusercontent.com server did not respond within the timeout period set.
- class ayt_api.types.YoutubeThumbnailMetadata(thumbnail_metadata: dict, call_data, etag: str | None = None)[source]¶
Bases:
object
Data for the available thumbnails of a video.
- highest_available() str | None [source]¶
Helper function to get the highest resolution out of the thumbnails available
- Returns:
The name of the highest available thumbnail format
- Return type:
Optional[str]
- property highest: YoutubeThumbnail | None¶
Helper property that provided the highest resolution out of the thumbnails available
- Returns:
The thumbnail with the highest resolution available
- Return type:
Optional[YoutubeThumbnail]
- property default: YoutubeThumbnail | None¶
The default video thumbnail. The value is not guaranteed and could be
None
.This is the most guaranteed to actually return a thumbnail.
- Returns:
A YouTube thumbnail object. Could be
None
.- Return type:
Optional[YoutubeThumbnail]
- property medium: YoutubeThumbnail | None¶
The medium video thumbnail. The value is not guaranteed and could be
None
.- Returns:
A YouTube thumbnail object. Could be
None
.- Return type:
Optional[YoutubeThumbnail]
- property high: YoutubeThumbnail | None¶
The high video thumbnail. The value is not guaranteed and could be
None
.- Returns:
A YouTube thumbnail object. Could be
None
.- Return type:
Optional[YoutubeThumbnail]
- property standard: YoutubeThumbnail | None¶
The standard video thumbnail. The value is not guaranteed and could be
None
.- Returns:
A YouTube thumbnail object. Could be
None
.- Return type:
Optional[YoutubeThumbnail]
- property maxres: YoutubeThumbnail | None¶
The maximum resolution video thumbnail. The value is not guaranteed and could be
None
.- Returns:
A YouTube thumbnail object. Could be
None
.- Return type:
Optional[YoutubeThumbnail]
- class ayt_api.types.LocalName(title: str, description: str = None, language: str = None)[source]¶
Bases:
object
Represents the video title and description in a local language if available.
- class ayt_api.types.RegionRestrictions(allowed: list[str] = None, blocked: list[str] = None)[source]¶
Bases:
object
Represents information about the countries where a video is (or is not) viewable.
- class ayt_api.types.ContentRating(data: dict)[source]¶
Bases:
object
Specifies the ratings that the video received under various rating schemes.
There are many attributes for each rating system, only 1 or 2 (if there is a reason) will be available, the rest will be
None
or all if there is no restrictions set. The attributes documented below are non-exhaustive.
- class ayt_api.types.RecordingLocation(latitude: float, longitude: float, altitude: float)[source]¶
Bases:
object
The geolocation information associated with the video. if specified by the video uploader.
- class ayt_api.types.RecordingDetails(data: dict)[source]¶
Bases:
object
Contains details of the location and date of the video recording if specified by the video uploader.
- data¶
The raw information about the location, date and address where the video was recorded.
- Type:
- location¶
The geolocation information associated with the video.
- Type:
Optional[RecordingLocation]
- date¶
The date and time when the video was recorded.
- Type:
Optional[datetime.datetime]
- class ayt_api.types.VideoStream(data: dict)[source]¶
Bases:
object
Metadata about a video stream for a YouTube video.
- class ayt_api.types.AudioStream(data: dict)[source]¶
Bases:
object
Metadata about an audio stream for a YouTube video.
- class ayt_api.types.ProcessingProgress(data: dict)[source]¶
Bases:
object
Contains information about the progress YouTube has made in processing the video.
- parts_total¶
An estimate of the total number of parts that need to be processed for the video.
- Type:
- time_left¶
An estimate of the amount of time, in milliseconds, that YouTube needs to finish processing the video.
- Type:
Optional[datetime.timedelta]
- class ayt_api.types.TagSuggestion(data: dict)[source]¶
Bases:
object
- A list of keyword tags that could be added to the video’s metadata to increase the likelihood that users will
locate your video when searching or browsing on YouTube.
- class ayt_api.types.VideoChapter(start: timedelta, duration: timedelta, name: str)[source]¶
Bases:
object
The start time, duration and name of a YouTube video chapter.
- duration¶
(int): The length of the chapter in seconds.
- Type:
- class ayt_api.types.BaseVideo(metadata: dict, call_url: str, etag: str, id: str, url: str, title: str, description: str, visibility: PrivacyStatus)[source]¶
Bases:
object
The base class that all video related objects are inherited from.
- metadata¶
The raw metadata from the API response used to construct this class. Intended use is for debugging purposes.
- Type:
- id¶
The ID of the video. Example: “dQw4w9WgXcQ” from the url: “https://www.youtube.com/watch?v=dQw4w9WgXcQ”. Look familiar?
- Type:
- thumbnails¶
The available thumbnails the video has.
- Type:
- visibility¶
The video’s privacy status. Can be
PrivacyStatus.private
,PrivacyStatus.public
orPrivacyStatus.unlisted
.- Type:
- thumbnails¶
alias of
YoutubeThumbnailMetadata
- class ayt_api.types.DummyObject(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
This is used for debugging only.
- class ayt_api.types.YoutubeVideo(metadata: dict, call_url: str, call_data)[source]¶
Bases:
BaseVideo
A data class containing video data such as the title, id, description, channel, etc.
- metadata¶
The raw metadata from the API response used to construct this class. Intended use is for debugging purposes.
- Type:
- id¶
The ID of the video. Example: “dQw4w9WgXcQ” from the url: “https://www.youtube.com/watch?v=dQw4w9WgXcQ”. Look familiar?
- Type:
- raw_localisations¶
The raw localisation data used to construct part of this class.
- Type:
Optional[dict]
- paid_product_placement_details¶
The paid product placement details data used to construct part of this class.
- Type:
- published_at¶
The date and time the video was published.
- Type:
- thumbnails¶
The available thumbnails the video has.
- Type:
- tags¶
The tags the uploaded has provided to make the video appear in search results relating to it.
- category_id¶
The id of the category that was set for the video.
Changed in version 0.4.0:
category_id
is now astr
rather than anint
- Type:
- live_broadcast_content¶
Indicates if the video is a livestream and if it is live.
- Type:
- default_language¶
The default language the video is set in. The value is a BCP-47 language code.
- Type:
Optional[str]
- localised¶
The localised language of the title and description of the video.
- Type:
Optional[LocalName]
- default_audio_language¶
The default audio language the video is set in. The value is a BCP-47 language code.
- Type:
Optional[str]
- duration¶
The length of the video.
- Type:
Union[isodate.Duration, datetime.timedelta, _NotImplementedType]
- definition¶
Indicates whether the video is available in high definition (HD) or only in standard definition.
- Type:
- licensed_content¶
Indicates whether the video represents licensed content, which means that the content was uploaded to a channel linked to a YouTube content partner and then claimed by that partner.
- Type:
- region_restrictions¶
contains information about the countries where a video is (or is not) viewable. Can be
None
.- Type:
Optional[RegionRestrictions]
- content_rating¶
Specifies the ratings that the video received under various rating schemes.
- Type:
- projection¶
Specifies the projection format of the video (example: 360 or rectangular).
- Type:
Optional[VideoProjection]
- upload_status¶
The status of the uploaded video.
- Type:
Optional[UploadStatus]
- failure_reason¶
Explains why a video failed to upload. This attribute is only present if the upload_status attribute is set to
UploadStatus.failed
.- Type:
Optional[UploadFailureReason]
- rejection_reason¶
Explains why YouTube rejected an uploaded video. This attribute is only present if the upload_status attribute is set to
UploadStatus.rejected
.- Type:
Optional[UploadRejectionReason]
- visibility¶
The video’s privacy status. Can be
PrivacyStatus.private
,PrivacyStatus.public
orPrivacyStatus.unlisted
.- Type:
- publish_set_at¶
The date and time when the video is scheduled to publish if any.
- Type:
Optional[datetime.datetime]
- license¶
The video’s license. valid values for this attribute is
License.creative_common
andLicense.youtube
.- Type:
Optional[License]
- public_stats_viewable¶
Indicates whether the extended video statistics on the video’s watch page are publicly viewable.
- Type:
- made_for_kids¶
Indicates whether the video is designated as child-directed, and it contains the current “made for kids” status of the video.
- Type:
Optional[bool]
- contains_synthetic_media¶
If the video contain realistic Altered or Synthetic (A/S) content.
Note
This attribute will not be set unless setting the value via updating this class.
- Type:
Optional[bool]
- comment_count¶
The number of comments on the video. This attribute is
None
if disabled- Type:
Optional[int]
- embed_height¶
The height of the embedded player returned to the embed_html attribute. Is
None
unless the height and aspect ratio is known.- Type:
Optional[str]
- embed_width¶
The width of the embedded player returned to the embed_html attribute. Is
None
unless the width and aspect ratio is known.- Type:
Optional[str]
- topic_categories¶
A list of Wikipedia URLs that provide a high-level description of the video’s content.
- recording_details¶
Encapsulates information about the location, date and address where the video was recorded.
- Type:
- stream_actual_start_time¶
The time that the broadcast actually started.
- Type:
Optional[datetime.datetime]
- stream_scheduled_start_time¶
The time that the broadcast is scheduled to begin.
- Type:
Optional[datetime.datetime]
- stream_actual_end_time¶
The time that the broadcast actually ended.
- Type:
Optional[datetime.datetime]
- stream_scheduled_end_time¶
The time that the broadcast is scheduled to end.
- Type:
Optional[datetime.datetime]
- stream_concurrent_viewers¶
The number of viewers currently watching the broadcast.
- Type:
Optional[int]
- stream_active_live_chat_id¶
The ID of the currently active live chat attached to this video.
- Type:
Optional[str]
- has_paid_product_placement¶
Set to
True
if the content uses paid product placement. Defaults toFalse
.- Type:
- async fetch_channel() YoutubeChannel | None [source]¶
Fetches the channel associated with the video.
This ia an api call which then returns a
YoutubeChannel
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The channel object containing data of the channel.
- Return type:
Optional[YoutubeChannel]
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_comments(max_comments: int | None = 50) list[YoutubeCommentThread] [source]¶
Fetches a list of comments on the video.
This ia an api call which then returns a
list[YoutubeCommentThread]
object.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 comments fetched.
- Returns:
A list of comments on the video.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_captions() list[VideoCaption] [source]¶
Fetches a list of captions on the video.
This ia an api call which then returns a
list[VideoCaption]
object.Quota Impact
A call to this method has a quota cost of 50 units per call or per 50 captions fetched.
- Returns:
A list of captions on the video.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_category() YoutubeVideoCategory [source]¶
Fetches the category that has been or could be associated with the video.
Quota Impact
A call to this method has a quota cost of 1 unit per call.
Added in version 0.4.0.
- Returns:
The video category
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoCategoryNotFound – The video category does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video category id.
APITimeout – The YouTube api did not respond within the timeout period set.
- property chapters: list[VideoChapter] | None¶
A list of chapters the video has if any otherwise just an empty list.
- Returns:
A list of chapters the video has if any otherwise
None
.- Return type:
chapters (list[VideoChapter])
- current_chapter(position: timedelta) VideoChapter | None [source]¶
Gets the current chapter based on the position provided.
- Parameters:
position (datetime.timedelta) – The position of the video to get the current chapter from.
- Returns:
- The current video chapter at that position of the video. Returns
None
if either the video doesn’t have any chapters or the position is greater than the duration of the video or is negative.
- The current video chapter at that position of the video. Returns
- Return type:
Optional[VideoChapter]
- class ayt_api.types.PlaylistItem(metadata: dict, call_url: str, call_data)[source]¶
Bases:
BaseVideo
A data class for videos in a playlist.
- resource_id¶
Contains information that can be used to uniquely identify the resource that is included in the playlist as the playlist item.
- Type:
- video_id¶
The ID of the video in the playlist. Example: “dQw4w9WgXcQ” from the url: “https://www.youtube.com/watch?v=dQw4w9WgXcQ”. Look familiar?
- Type:
- added_at¶
The date and time the video was added to the playlist.
- Type:
- thumbnails¶
The available thumbnails the video has.
- Type:
- published_at¶
The date and time the video was published.
- Type:
- available¶
Whether the video in the playlist is playable hasn’t been deleted or made private. This is determined by checking if the video has an upload date.
- Type:
- visibility¶
The playlist item’s privacy status. Can be
PrivacyStatus.private
,PrivacyStatus.public
orPrivacyStatus.unlisted
.- Type:
- async expand() YoutubeVideo [source]¶
Fetches extended information on the video in the playlist.
This ia an api call which then returns a
YoutubeVideo
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The video object containing data of the video.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_playlist() YoutubePlaylist [source]¶
Fetches the playlist associated with the video.
This ia an api call which then returns a
YoutubePlaylist
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The playlist object containing data of the playlist.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_channel() YoutubeChannel | None [source]¶
Fetches the channel associated with the video.
This ia an api call which then returns a
YoutubeChannel
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The channel object containing data of the channel.
- Return type:
Optional[YoutubeChannel]
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_comments(max_comments: int | None = 50) list[YoutubeCommentThread] [source]¶
Fetches a list of comments on the video.
This ia an api call which then returns a
list[YoutubeCommentThread]
object.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 comments fetched.
- Returns:
A list of comments on the video.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_captions() list[VideoCaption] [source]¶
Fetches a list of comments on the video.
This ia an api call which then returns a
list[VideoCaption]
object.Quota Impact
A call to this method has a quota cost of 50 units per call or per 50 captions fetched.
- Returns:
A list of comments on the video.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async update(*, position: int | EXISTING | None = EXISTING, note: str | EXISTING | None = EXISTING) PlaylistItem [source]¶
Update the metadata for an item in a playlist.
Added in version 0.4.0.
Values default to a special constant called
EXISTING
which is from the classayt_api.types.UseExisting
. Specify any other value in order to edit the property you want.Quota Impact
A call to this method has a quota cost of 50 units per call.
Important
Specifying
None
for a parameter will wipe it or set it to YouTube’s default value.Note
This method requires OAuth2 authentication with at least the default scope.
- Parameters:
- Returns:
The updated metadata for the item in the playlist related to the video.
- Return type:
- Raises:
HTTPException – Editing the item in the playlist failed or an invalid playlist position or note was set.
ResourceNotFound – The playlist item does not exist or is not accessible.
aiohttp.ClientError – There was a problem sending the request to the api.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.PlaylistImageMetadata(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
Represents metadata about a custom image for a playlist.
Added in version 0.4.0.
- async fetch_playlist() YoutubePlaylist [source]¶
Fetches the playlist associated with the image.
This ia an api call which then returns a
YoutubePlaylist
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The playlist object containing data of the playlist.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.YoutubePlaylist(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
Data class for YouTube playlists.
- id¶
The ID of the playlist. Example: “PLwZcI0zn-Jhemx2m_gpYqQfnc3l4xA4fp” from the url: “https://www.youtube.com/playlist?list=PLwZcI0zn-Jhemx2m_gpYqQfnc3l4xA4fp”.
- Type:
- raw_localisations¶
The raw localisation data used to construct part of this class.
- Type:
Optional[dict]
- published_at¶
The date and time the playlist was published.
- Type:
- thumbnails¶
The available thumbnails the playlist has.
- Type:
- localised¶
The localised language of the title and description of the video.
- Type:
Optional[LocalName]
- visibility¶
The video’s privacy status. Can be
PrivacyStatus.private
,PrivacyStatus.public
orPrivacyStatus.unlisted
.- Type:
Optional[PrivacyStatus]
- podcast_status¶
The playlist’s podcast status.
Added in version 0.4.0.
- Type:
Optional[PodcastStatus]
- localizations¶
an alias of
localisations
.
- async fetch_items() list[PlaylistItem] [source]¶
Fetches a list of the videos in the playlist.
This is an api call which returns a list of
PlaylistItem
objects.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 items fetched.
- Returns:
A list containing playlist video objects.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_videos(exclude: list[str] = None, ignore_not_found=False) list[YoutubeVideo] | list [source]¶
Fetches a list of the videos in the playlist.
This is an api call which returns a list of
YoutubeVideo
objects.Quota Impact
A call to this method has a quota cost of 2 units per call or per 50 videos fetched.
- Parameters:
- Returns:
A list containing videos from the playlist.
- Return type:
Union[list[YoutubeVideo], list]
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_channel() YoutubeChannel | None [source]¶
Fetches the channel associated with the playlist.
This ia an api call which then returns a
YoutubeChannel
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The channel object containing data of the channel.
- Return type:
Optional[YoutubeChannel]
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_image_metadata() PlaylistImageMetadata | None [source]¶
Fetches metadata on the custom cover images if the current playlist has one.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 1 unit per call.
Important
The API endpoint for playlist images is still in early stages and its own documentation currently has bits missing and contains a few errors and inconsistencies. Not everything may work as expected or may change and break this method.
Note
This method will not fetch the actual image asset due to YouTube limitations.
- Returns:
The metadata of the custom playlist image. Returns
None
if the playlist has no custom image set.- Return type:
Optional[PlaylistImageMetadata]
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async add_video(video: BaseVideo | str, *, position: int = None, note: str = None) PlaylistItem [source]¶
Add a video to the playlist.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 50 units per call.
Note
This method requires OAuth2 authentication with at least the default scope.
- Parameters:
video (Union[BaseVideo, str]) – The video or video ID to add to the playlist.
position (Optional[int]) – The position in the playlist to add the video. Defaults to the end.
note (Optional[str]) –
A user-generated note for this item. The note has a maximum character limit of 280 and the API is meant to throw a 400 error if this limit is exceeded.
Important
This property might be deprecated by the API as it seems to ignore any set value even if it is over the said character limit in its documentation.
- Returns:
The metadata for the item in the playlist related to the video.
- Return type:
- Raises:
HTTPException – Adding the video to the playlist failed or an invalid playlist position was set.
PlaylistNotFound – The playlist does not exist or is not accessable.
VideoNotFound – The video does not exist or is not accessable.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async update(*, title: str | EXISTING = EXISTING, description: str | EXISTING | None = EXISTING, default_language: str | EXISTING | None = EXISTING, visibility: PrivacyStatus | EXISTING | None = EXISTING, podcast_status: PodcastStatus | EXISTING | None = EXISTING, localisations: list[LocalName] | EXISTING | None = EXISTING) YoutubePlaylist [source]¶
Updates metadata for the playlist.
Added in version 0.4.0.
Values default to a special constant called
EXISTING
which is from the classayt_api.types.UseExisting
. Specify any other value in order to edit the property you want.Quota Impact
A call to this method has a quota cost of 50 units per call.
Important
Specifying
None
for a parameter will wipe it or set it to YouTube’s default value.Note
This method requires OAuth2 authentication with at least the default scope.
- Parameters:
title (Union[str, EXISTING]) –
The title of the playlist to set.
Note
This value cannot be set to
None
or an empty string as YouTube forbids this.default_language (Union[str, EXISTING, None]) – The default language the playlist should be set in. The value should be a BCP-47 language code.
description (Union[str, EXISTING, None]) – The description of the playlist to set.
visibility (Union[PrivacyStatus, EXISTING, None]) – Set the playlist’s privacy status.
podcast_status (Union[PodcastStatus, EXISTING, None]) – Set the playlist’s podcast status.
localisations (Union[list[LocalName], EXISTING, None]) – Specify translations of the playlist’s metadata.
- Returns:
The updated playlist object.
- Return type:
- Raises:
HTTPException – Updating the playlist failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the API.
APITimeout – The YouTube API did not respond within the timeout period set.
- class ayt_api.types.AuthorisedYoutubeVideo(metadata, call_url, call_data)[source]¶
Bases:
YoutubeVideo
A data class containing owner only information video data such as the file and processing information.
This class is used if authorisation is provided that you are the owner of the video. It contains attributes only accessible by the video owner as well as attributes inherited from
YoutubeVideo
.- has_custom_thumbnail¶
Indicates whether the video uploader has provided a custom thumbnail image for the video.
- Type:
- self_declared_made_for_kids¶
This Attribute allows the channel owner to designate the video as being child-directed.
- Type:
- dislike_count¶
The number of users who have indicated that they disliked the video.
- Type:
Optional[int]
- file_type¶
The uploaded file’s type as detected by YouTube’s video processing engine.
- Type:
Optional[UploadFileType]
- video_streams¶
A list of video streams contained in the uploaded video file.
- Type:
Optional[list[VideoStream]]
- audio_streams¶
A list of audio streams contained in the uploaded video file.
- Type:
Optional[list[AudioStream]]
- file_duration¶
The length of the uploaded video millisecond accurate.
- Type:
Optional[datetime.timedelta]
- file_bitrate¶
The uploaded video file’s combined (video and audio) bitrate in bits per second.
- Type:
Optional[int]
- file_creation_time¶
The date and time when the uploaded video file was created.
- Type:
Optional[datetime.datetime]
- processing_status¶
The video’s processing status.
- Type:
Optional[ProcessingStatus]
- processing_progress¶
contains information about the progress YouTube has made in processing the video
- Type:
Optional[ProcessingProgress]
- processing_failure_reason¶
The reason that YouTube failed to process the video.
- Type:
Optional[ProcessingFailureReason]
- file_details_availability¶
This value indicates whether file details are available for the uploaded video.
- Type:
Optional[str]
- processing_issues_availability¶
indicates whether the video processing engine has generated suggestions that might improve YouTube’s ability to process the video, warnings that explain video processing problems, or errors that cause video processing problems.
- Type:
Optional[str]
- tag_suggestions_availability¶
This value indicates whether keyword (tag) suggestions are available for the video.
- Type:
Optional[str]
- editor_suggestions_availability¶
This value indicates whether video editing suggestions, which might improve video quality or the playback experience, are available for the video.
- Type:
Optional[str]
- thumbnails_availability¶
This value indicates whether thumbnail images have been generated for the video.
- Type:
Optional[str]
- processing_errors¶
A list of errors that will prevent YouTube from successfully processing the uploaded video.
- Type:
Optional[list[ProcessingError]]
- processing_warnings¶
A list of reasons why YouTube may have difficulty transcoding the uploaded video or that might result in an erroneous transcoding.
- Type:
Optional[list[ProcessingWarning]]
- processing_hints¶
A list of suggestions that may improve YouTube’s ability to process the video.
- Type:
Optional[list[ProcessingHint]]
- tag_suggestions¶
A list of keyword tags that could be added to the video’s metadata to increase the likelihood that users will locate your video when searching or browsing on YouTube.
- Type:
Optional[list[TagSuggestion]]
- editor_suggestions¶
A list of video editing operations that might improve the video quality or playback experience of the uploaded video.
- Type:
Optional[list[EditorSuggestion]]
- async update(*, title: str | EXISTING = EXISTING, category_id: str | EXISTING = EXISTING, default_language: str | EXISTING | None = EXISTING, description: str | EXISTING | None = EXISTING, tags: list[str] | EXISTING | None = EXISTING, embeddable: bool | EXISTING | None = EXISTING, video_license: License | EXISTING | None = EXISTING, visibility: PrivacyStatus | EXISTING | None = EXISTING, public_stats_viewable: bool | EXISTING | None = EXISTING, publish_at: datetime | EXISTING | None = EXISTING, made_for_kids: bool | EXISTING | None = EXISTING, contains_synthetic_media: bool | EXISTING | None = EXISTING, recording_date: datetime | EXISTING | None = EXISTING, localisations: list[LocalName] | EXISTING | None = EXISTING)[source]¶
Updates metadata for the video.
Added in version 0.4.0.
Values default to a special constant called
EXISTING
which is from the classayt_api.types.UseExisting
. Specify any other value in order to edit the property you want.Quota Impact
A call to this method has a quota cost of 50 units per call.
Important
Specifying
None
for a parameter will wipe it or set it to YouTube’s default value.- Parameters:
title (Union[str, EXISTING]) –
The title of the video to set.
Note
This value cannot be set to
None
or an empty string as YouTube forbids this.category_id (Union[str, EXISTING]) –
The category id to set for the video.
Note
This value cannot be set to
None
or an empty string as YouTube forbids this.default_language (Union[str, EXISTING, None]) – The default language the video should be set in. The value should be a BCP-47 language code.
description (Union[str, EXISTING, None]) – The description of the video to set.
tags (Union[list[str], EXISTING, None]) – The tags the to set to make the video appear in search results relating to it.
embeddable (Union[bool, EXISTING, None]) – Set whether the video can be embedded on another website.
video_license (Union[License, EXISTING, None]) – The YouTube license to set for the video.
visibility (Union[PrivacyStatus, EXISTING, None]) – Set the video’s privacy status.
public_stats_viewable (Union[bool, EXISTING, None]) – Set whether the extended video statistics on the video’s watch page are publicly viewable.
publish_at (Union[datetime.datetime, EXISTING, None]) –
Set the date and time when the video is scheduled to publish.
Note
If you set a value for this property, you must also set the
visibility
property toayt_api.enums.PrivacyStatus.private
.made_for_kids (Union[bool, EXISTING, None]) – Designate the video as being child-directed.
contains_synthetic_media (Union[bool, EXISTING, None]) – Tell YouTube if the video contain realistic Altered or Synthetic (A/S) content.
recording_date (Union[datetime.datetime, EXISTING, None]) – Set the date and time when the video was recorded.
localisations (Union[list[LocalName], EXISTING, None]) – Specify translations of the video’s metadata.
- Returns:
The updated instance of this class.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the API.
InvalidInput – The input is not a video ID.
APITimeout – The YouTube API did not respond within the timeout period set.
- async set_thumbnail(image: bytes)[source]¶
Upload and set the video’s thumbnail.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 50 units per call.
- Parameters:
image (bytes) – The thumbnail image to upload.
- Raises:
HTTPException – Uploading the thumbnail failed.
ResourceNotFound – The API didn’t return any thumbnail metadata.
aiohttp.ClientError – There was a problem sending the request to the API.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.YoutubeChannel(metadata: dict, call_url: str, call_data, partial=False)[source]¶
Bases:
object
A class representing metadata from a YouTube channel.
- content_owner_details¶
encapsulates channel data that is visible only to the YouTube Partner that has linked the channel to their Content Manager.
- Type:
- snippet¶
contains basic details about the channel, such as its title, description, and thumbnail images.
- Type:
- topic_details¶
encapsulates information about topics associated with the channel.
- Type:
Optional[dict]
- description¶
The channel’s description. The property’s value has a maximum length of 1000 characters.
- Type:
Optional[str]
- username¶
Alias for
custom_url
.- Type:
Optional[str]
- handle¶
Alias for
custom_url
.- Type:
Optional[str]
- published_at¶
The date and time that the channel was created.
- Type:
- created_at¶
Alias for
published_at
.- Type:
- thumbnails¶
The thumbnail images associated with the channel.
- Type:
- icon¶
Alias of
thumbnails
.- Type:
- pfp¶
Alias of
thumbnails
.- Type:
- avatar¶
Alias of
thumbnails
.- Type:
- default_language¶
The language of the text in the
YoutubeChannel
class’stitle
anddescription
properties.- Type:
Optional[str]
- localised¶
The localized title and description for the channel or title and description in the
default_language
.- Type:
Optional[LocalName]
The playlists associated with the channel, such as the channel’s uploaded videos or liked videos.
- Type:
- uploads_url¶
The URL of the playlist that contains the channel’s uploaded videos.
- Type:
Optional[str]
- subscriber_count¶
The number of subscribers that the channel has. This is rounded to 3 significant figures.
- Type:
Whether the channel’s subscriber count is publicly visible.
- Type:
- topic_categories¶
A list of Wikipedia URLs that describe the channel’s content.
- visibility¶
The channel’s privacy status. Can be
PrivacyStatus.private
,PrivacyStatus.public
orPrivacyStatus.unlisted
.- Type:
- is_linked¶
Whether the channel data identifies a user that is already linked to either a YouTube username or a Google+ account.
- Type:
- long_upload_status¶
whether the channel is eligible to upload videos that are more than 15 minutes long.
- Type:
- made_for_kids¶
Whether the channel is designated as child-directed, and it contains the current “made for kids” status of the channel.
- Type:
Optional[bool]
- tracking_analytics_account_id¶
The ID for a Google Analytics account used to track and measure traffic to the channel.
- Type:
Optional[str]
- moderate_comments¶
Determines whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible.
- Type:
Optional[bool]
- unsubscribed_trailer_id¶
The ID of the video that should play in the featured video module in the channel page’s browse view for unsubscribed viewers.
- Type:
Optional[str]
- unsubscribed_trailer_url¶
The URL of the video that should play in the featured video module in the channel page’s browse view for unsubscribed viewers.
- Type:
Optional[str]
- banner_external¶
The banner image that YouTube uses to generate the various banner image sizes for a channel.
- Type:
Optional[YoutubeBanner]
- time_linked¶
The date and time of when the channel was linked to the content owner.
- Type:
Optional[datetime.datetime]
- localizations¶
Alias for
localisations
.
- async fetch_uploads() list[PlaylistItem] | None [source]¶
Fetches the playlist containing all public uploads associated with the channel.
This ia an api call which then returns a
PlaylistItem
object.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 items fetched.
- Returns:
A list containing playlist video objects of the channel’s public uploads.
- Return type:
Optional[list[PlaylistItem]]
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_likes(max_items: int = None) list[PlaylistItem] | None [source]¶
Fetches the playlist containing all videos the channel has liked if public.
This ia an api call which then returns a
PlaylistItem
object if public, otherwiseNone
.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 items fetched.
- Parameters:
max_items (Optional[int]) –
The maximum number of playlist items to fetch. Defaults to
None
which fetches every item in a playlist.Added in version 0.4.0.
Warning
If a specified playlist has a lot of videos, not specifying a value to
max_items
could hammer the api too much causing you to get rate limited so do this with caution.- Returns:
A list containing playlist video objects of the channel’s public likes.
- Return type:
Optional[list[PlaylistItem]]
- Raises:
HTTPException – Fetching the metadata failed.
PlaylistNotFound – The playlist does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a playlist id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_unsubscribed_trailer() YoutubeVideo | None [source]¶
Fetches the channel trailer video if any.
This ia an api call which then returns a
YoutubeVideo
object if the channel has a trailer, otherwiseNone
.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The video object containing data of the channel trailer.
- Return type:
Optional[YoutubeVideo]
- Raises:
HTTPException – Fetching the metadata failed.
VideoNotFound – The video does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a video id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_comments(max_comments: int | None = 50) list[YoutubeCommentThread] [source]¶
Fetches a list of related to the channel.
This ia an api call which then returns a
list[YoutubeCommentThread]
object.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 comments fetched.
- Parameters:
max_comments (Optional[int]) –
The maximum number of comments to fetch. Defaults to 50.
Warning
If a specified video has a lot of comments, not specifying a value to
max_comments
could hammer the api too much causing you to get rate limited so do this with caution.- Returns:
A list of comments related to the channel.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async update(*, country: str | EXISTING | None = EXISTING, description: str | EXISTING | None = EXISTING, default_language: str | EXISTING | None = EXISTING, keywords: list[str] | EXISTING | None = EXISTING, tracking_analytics_account_id: str | EXISTING | None = EXISTING, unsubscribed_trailer: str | BaseVideo | EXISTING | None = EXISTING, localisations: list[LocalName] | EXISTING | None = EXISTING, made_for_kids: bool | EXISTING = EXISTING) YoutubeChannel [source]¶
Updates metadata for the channel.
Added in version 0.4.0.
Values default to a special constant called
EXISTING
which is from the classayt_api.types.UseExisting
. Specify any other value in order to edit the property you want.Quota Impact
A call to this method has a quota cost of between 0-150 units. As updating
localisations
andmade_for_kids
cost an extra 50 units each and not updating anything costs nothing as no API call is actually made.Note
If no arguments are specified or are all set to
EXISTING
, no API call is made and hence no quota units will be used. The function will just return theYoutubeChannel
as it is.Important
Specifying
None
for a parameter will wipe it or set it to YouTube’s default value.Note
This method requires OAuth2 authentication with at least the default scope.
- Parameters:
country (Union[str, EXISTING, None]) – The country to set which the channel is associated.
description (Union[str, EXISTING, None]) – The description of the channel to set.
default_language (Union[str, EXISTING, None]) – The default language the video should be set in. The value should be a BCP-47 language code.
keywords (Union[list[str], EXISTING, None]) – Keywords to set associated with your channel.
tracking_analytics_account_id (Union[str, EXISTING, None]) – The ID to set for a Google Analytics account used to track and measure traffic to the channel.
unsubscribed_trailer (Union[str, BaseVideo, EXISTING, None]) – The ID or
BaseVideo
to set of the video that should play in the featured video module in the channel page’s browse view for unsubscribed viewers.localisations (Union[list[LocalName], EXISTING, None]) –
Specify translations of the video’s metadata.
Note
This value cannot be set to
None
or an empty list as YouTube forbids this.made_for_kids (Union[bool, EXISTING]) –
Designate the channel as being child-directed.
Note
This value cannot be set to
None
as YouTube forbids this.
- Returns:
The updated channel object.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the API.
InvalidInput – The input is not a channel ID.
APITimeout – The YouTube API did not respond within the timeout period set.
- async set_banner(image: bytes)[source]¶
Upload and set the banner for the channel.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 100 units per call.
Note
This method requires OAuth2 authentication with at least the default scope.
- Parameters:
image (bytes) –
The banner image to upload.
Note
The image must have a 16:9 aspect ratio and be at least 2048x1152 pixels. YouTube recommends uploading a 2560px by 1440px image.
- Raises:
HTTPException – Uploading the banner failed.
ResourceNotFound – The API didn’t return any banner or channel metadata.
aiohttp.ClientError – There was a problem sending the request to the API.
APITimeout – The YouTube API did not respond within the timeout period set.
- async set_watermark(image: bytes, timing_type: WatermarkTimingType = None, timing_offset: timedelta = None, duration: timedelta = None)[source]¶
Upload and set the watermark for a channel.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 50 units per call.
Note
This method requires OAuth2 authentication with at least the default scope.
- Parameters:
image (bytes) – The watermark image to upload.
timing_type (Optional[WatermarkTimingType]) –
The timing method that determines when the watermark image is displayed during the video playback.
Note
Setting this argument to
None
will make the watermark appear for the entire video.timing_offset (Optional[datetime.timedelta]) – The time offset that determines when the promoted item appears during video playbacks.
timing_type
Determines if this offset if from the start or end of a video.duration (Optional[datatime.timedelta]) – The length of time that the watermark image should display.
- Raises:
HTTPException – Uploading the watermark failed.
aiohttp.ClientError – There was a problem sending the request to the API.
APITimeout – The YouTube API did not respond within the timeout period set.
- async unset_watermark()[source]¶
Unset the watermark for a channel.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 50 units per call.
Warning
If the channel currently has no watermark set, this function will raise
WatermarkNotFound
as the API throws a 404 error.Note
This method requires OAuth2 authentication with at least the default scope.
- Raises:
HTTPException – Unsetting the watermark failed.
aiohttp.ClientError – There was a problem sending the request to the API.
APITimeout – The YouTube API did not respond within the timeout period set.
WatermarkNotFound – There is no watermark to unset.
- async fetch_playlists() list[YoutubePlaylist] [source]¶
Fetches playlists created by the channel.
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 playlists fetched.
Note
Only playlists marked as public will be returned if the request is made without OAuth2 authorisation using the associated channel.
- Returns:
The playlists created by the channel.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.YoutubeComment(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
Represents information on an individual YouTube command.
Information about the video the comment belongs to will not be available unless this object was access under
YoutubeCommentThread.replies
- video_id¶
The ID of the video that the comments refer to. Will be
None
unless part of aYoutubeCommentThread
.- Type:
Optional[str]
- video_url¶
The URL of the video that the comments refer to. Will be
None
unless part of aYoutubeCommentThread
.- Type:
Optional[str]
- highlight_url¶
The highlight URL of the comment. Will be
None
unless part of aYoutubeCommentThread
.- Type:
Optional[str]
- url¶
Alias of
highlight_url
- Type:
Optional[str]
- published_at¶
The date and time when the comment was originally published.
- Type:
- updated_at¶
The date and time when the comment was last updated.
- Type:
- async fetch_replies(max_comments: int | None = 50) list[YoutubeComment] [source]¶
Fetches a list of replies on the comment.
This ia an api call which then returns a
list[YoutubeComment]
object.Quota Impact
A call to this method has a quota cost of 1 unit per call or per 50 comments fetched.
- Parameters:
max_comments (Optional[int]) –
The maximum number of comments to fetch. Defaults to 50.
Warning
If a specified comment has a lot of replies, not specifying a value to
max_comments
could hammer the api too much causing you to get rate limited so do this with caution.- Returns:
A list of replies on the comment.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
CommentNotFound – The comment does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a comment id.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.YoutubeCommentThread(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
Represents the structure of a comment (thread).
- url¶
Alias of
highlight_url
- Type:
Optional[str]
- top_level_comment¶
The thread’s top-level comment.
- Type:
- total_reply_count¶
The total number of replies that have been submitted in response to the top-level comment.
- Type:
Optional[int]
- is_public¶
Whether the thread, including all of its comments and comment replies, is visible to all YouTube users.
- Type:
- replies¶
The replies on the comment if any.
- Type:
Optional[list[YoutubeComment]]
- class ayt_api.types.YoutubeSearchResult(data: dict, call_url: str, call_data)[source]¶
Bases:
object
Represents individual results from an API search.
- kind_id¶
The raw kind of the result separated by a #. Could be video, channel or playlist.
- Type:
- kind¶
- Type:
type[Union[YoutubeVideo, YoutubeChannel, YoutubePlaylist]]
- thumbnails¶
The available thumbnails the object has.
- Type:
- channel_title¶
The title of the channel that published the resource that the search result identifies.
- Type:
Optional[str]
- live_broadcast_content¶
Indicates if the object is a livestream and if it is live.
- Type:
- async expand() YoutubeVideo | YoutubeChannel | YoutubePlaylist [source]¶
Expand the search result into its appropriate type.
Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The proper object of the search result.
- Return type:
Union[YoutubeVideo, YoutubeChannel, YoutubePlaylist]
- Raises:
HTTPException – Fetching the metadata failed.
ResourceNotFound – The object does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a YouTube ID.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.VideoCaption(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
Represents data of an individual caption track on a video.
- last_updated¶
The date and time when the caption track was last updated.
- Type:
- track_kind¶
The caption track’s type.
- Type:
- name¶
The name of the caption track. The name is intended to be visible to the user as an option during playback.
- Type:
- audio_track_type¶
The type of audio track associated with the caption track.
- Type:
- is_large¶
Whether the caption track uses large text for the vision-impaired. Defaults to
False
.- Type:
- is_easy_reader¶
Whether the caption track is formatted for “easy reader,” meaning it is at a third-grade level for language learners. Defaults to
False
.- Type:
- is_auto_synced¶
Whether YouTube synchronized the caption track to the audio track in the video.
- Type:
- status¶
The caption track’s status.
- Type:
- failure_reason¶
The reason that YouTube failed to process the caption track.
- Type:
- async download(track_format: CaptionFormat | None = None, language: str | None = None) bytes [source]¶
Downloads the caption track and stores it as a
bytes
objectAdded in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 200 units per call.
Note
You must be the owner of the video of the captions and use OAuth authentication to call this method with one of the following scopes:
- Parameters:
track_format (Optional[CaptionFormat]) – The format YouTube should return the captions in.
language (Optional[str]) – The alpha-2 language code to translate the caption track into.
- Returns:
The caption track as a
bytes
object.- Return type:
- Raises:
HTTPException – Fetching the request failed.
aiohttp.ClientError – There was a problem sending the request to the api.
asyncio.TimeoutError – The API server did not respond within the timeout period set.
- async save(*, track_format: CaptionFormat | None = None, language: str | None = None, fp: PathLike | str | None = None)[source]¶
Downloads the caption track and saves it to a specified location
Added in version 0.4.0.
Quota Impact
A call to this method has a quota cost of 200 units per call.
Note
You must be the owner of the video of the captions and use OAuth authentication to call this method with one of the following scopes:
- Parameters:
track_format (Optional[CaptionFormat]) – The format YouTube should return the captions in.
language (Optional[str]) – The alpha-2 language code to translate the caption track into.
fp (Union[os.PathLike, str, None]) – The path and/or filename to save the file to. Defaults to current working directory with the filename format:
{track_id}.{file_extension (if any)}
- Raises:
HTTPException – Fetching the request failed.
aiohttp.ClientError – There was a problem sending the request to the api.
asyncio.TimeoutError – The API did not respond within the timeout period set.
- class ayt_api.types.YoutubeSubscription(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
A class representing a user’s subscription to a channel on YouTube
Added in version 0.4.0.
- id¶
Alias of
subscription_id
.- Type:
- published_at¶
The date and time the subscriber subscribed to the channel this subscription points to.
- Type:
- subscribed_at¶
Alias of
published_at
.- Type:
- thumbnails¶
The thumbnail images associated with the channel the subscription points to.
- Type:
- icon¶
Alias of
thumbnails
.- Type:
- pfp¶
Alias of
thumbnails
.- Type:
- avatar¶
Alias of
thumbnails
.- Type:
- new_item_count¶
The number of new items in the subscription since its content was last read.
- Type:
- activity_type¶
The type of activity this subscription is for.
- Type:
- subscriber_thumbnails¶
The thumbnail images associated with the channel associated with the subscriber.
- Type:
- subscriber_icon¶
Alias of
subscriber_thumbnails
.- Type:
- subscriber_pfp¶
Alias of
subscriber_thumbnails
.- Type:
- subscriber_avatar¶
Alias of
subscriber_thumbnails
.- Type:
- async fetch_channel() YoutubeChannel [source]¶
Fetches the channel the subscription points to.
This ia an api call which then returns a
YoutubeChannel
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The channel object containing data of the channel.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- async fetch_subscriber() YoutubeChannel [source]¶
Fetches the channel associated with the subscriber.
This ia an api call which then returns a
YoutubeChannel
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The channel object containing data of the channel.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.YoutubeVideoCategory(metadata: dict, call_url: str, call_data)[source]¶
Bases:
object
Represents a YouTube video category
Added in version 0.4.0.
- async fetch_channel() YoutubeChannel [source]¶
Fetches the channel that created the video category.
This ia an api call which then returns a
YoutubeChannel
object.Quota Impact
A call to this method has a quota cost of 1 unit per call.
- Returns:
The channel object containing data of the channel.
- Return type:
- Raises:
HTTPException – Fetching the metadata failed.
ChannelNotFound – The channel does not exist.
aiohttp.ClientError – There was a problem sending the request to the api.
InvalidInput – The input is not a channel id.
APITimeout – The YouTube api did not respond within the timeout period set.
- class ayt_api.types.OAuth2Session(access_token: str, expires_in: int, refresh_token: str, scope: str, token_type: str, client_id: str, client_secret: str, http_date: datetime)[source]¶
Bases:
object
Represents an oauth2 session
Added in version 0.4.0.
- expiry_length¶
The total time the token is valid before it expires
- Type:
- expires_at¶
The time the token will expire at
- Type:
- client_id¶
A client id as part of OAuth client credentials created at https://console.cloud.google.com/apis/credentials.
- Type:
- client_secret¶
The client secret as part of OAuth client credentials created at https://console.cloud.google.com/apis/credentials.
- Type: