Constructor

class YouTube(link, cookies)

    Initializes the YouTube object with the provided video link.

Parameters:

    link str The URL to the YouTube video.
    cookies list List of dicts.

Properties

							videoId
							str
							
						

    Returns the unique identifier of the video.

							title
							str
							
						

    Returns the title of the video.

							author
							str
							
						

    Returns the name of the channel that uploaded the video.

							description
							str
							
						

    Returns the description of the video.

							duration
							int
							
						

    Returns the duration of the video in seconds.

							views
							int
							
						

    Returns the view count of the video.

							likes
							int
							
						

    Returns the like count of the video.

							comments
							MyTube.CommentsManager
							
						

    Returns the comments manager. To get comments count call:
    len(yt.comments)

							type
							str
							
						

    Returns the type of content of the YouTube video. ("video" or "music")

							upload_date
							datetime
							
						

    Returns the upload date of the video.

							channel
							MyTube.Channel
							
						

    Returns the channel information that uploaded the video.

							thumbnail
							MyTube.Thumbnail
							
						

    Returns the thumbnail of the video.

							subtitles
							MyTube.SubtitlesManager
							
						

    Returns the subtitles manager for the video.

							streams
							MyTube.StreamsManager
							
						

    Returns the available video and audio streams for download.

Methods

							download(video, audio) ->MyTube.Downloader
							
						

    Initializes the Downloader based on the provided video or audio stream parameters.

Parameters:

Example

import MyTube

yt = MyTube.YouTube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

print(yt.title)        # Title of the video
print(yt.author)       # Author (channel name)
print(yt.views)        # Number of views
print(yt.duration)     # Video duration in seconds
>>> Rick Astley - Never Gonna Give You Up (Official Music Video)
>>> Rick Astley
>>> 1587866581
>>> 212

Cookies example

[{"domain": ".youtube.com", "expiry": 1700000000, "httpOnly": true, "name": "__Secure-1234", "path": "/", "sameSite": "Lax", "secure": true, "value": "ABCdef123456789"}, ...]

To get the cookies, you can use the browser extension to export cookies (Chrome or Firefox).

We are not developing this extensions, so install them at your own risk! Be careful what you install.

import json
import MyTube

with open("my_cookies.json", 'r') as f:
	cookies = json.loads(f.read())

link = "https://youtube.com/watch?v=HtVdAasjOgU"

yt = MyTube.YouTube(link, cookies=cookies)
print(yt.title)