
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
An unofficial lightweight Python wrapper for extracting video metadata and transcripts from YouTube videos.
pip install simple-yt-api
from simple_yt_api import YouTubeAPI
# Initialize
yt = YouTubeAPI()
url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# Get video metadata
metadata = yt.data(url=url)
print(metadata["title"])
# Get video transcript
transcript = yt.get_transcript(
url=url,
language_code="tr",
as_dict=True
) # Get Turkish transcript. Defaults to "en".
print(transcript)
# Get both metadata and transcript at once
data, transcript = yt.get_video_data_and_transcript(
url=url,
language_code="es",
as_dict=False # Return transcript as plain text
)
YouTubeAPI()
Initializes the API client.
data(url: str) -> dict
Returns video metadata dictionary containing:
video_id
: YouTube video IDtitle
: Video titleimg_url
: Thumbnail URLshort_description
: Video descriptionget_transcript(url: str, language_code: str = "en", as_dict: bool = True) -> list[dict] | str
Get video transcript in the specified languages.
url (str)
: The URL of the YouTube video.language_code (str, optional)
: The language code for the desired transcript. Defaults to "en".as_dict (bool, optional)
: If True
, returns the transcript as a list of dictionaries; otherwise, returns the transcript as a string. Defaults to True
.get_video_data_and_transcript(url: str, language_code: str = "en", as_dict: bool = True) -> tuple
Returns both video metadata and transcript. If there is an error, that spot in the tuple will have None
instead of a value.
url (str)
: The URL of the YouTube video.language_code (str, optional)
: The language code for the desired transcript. Defaults to "en".as_dict (bool, optional)
: If True
, returns the transcript as a list of dictionaries; otherwise, returns the transcript as a string. Defaults to True
.The library includes custom exceptions:
NoVideoFound
: When a video is not accessible or doesn't exist.NoMetadataFound
: When no metadata is found for the video.TranscriptsDisabled
: When transcripts are not available for the video.NoTranscriptFound
: When no transcript is available for the video.Sending too many requests in a short period might lead to your IP address being temporarily blocked by YouTube. Use responsibly.
This project is licensed under the MIT License.
FAQs
A simple and easy-to-use unofficial YouTube API Wrapper.
We found that simple-yt-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.