ytscrape’s transcript system mirrors the familiar three-step flow: list available tracks for a video, find the one you want, then fetch and parse it. Four models are involved:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vsmutok/ytscrape/llms.txt
Use this file to discover all available pages before exploring further.
TranscriptSnippet (a single timed caption line), Transcript (a fully fetched and parsed transcript), TranscriptTrack (metadata for one available but not-yet-downloaded caption track), and TranscriptList (the collection of all tracks for a video).
TranscriptSnippet
A single timed caption line within a fetched transcript. All fields are required and are neverNone.
The caption text for this line, with HTML formatting tags stripped (unless
preserve_formatting=True was passed to TranscriptTrack.fetch()).Wall-clock start time in seconds (e.g.
42.56). Parsed from the start attribute of the timedtext XML element.How long the line stays on screen in seconds (e.g.
3.12). Note that adjacent snippets may overlap: start + duration of one snippet can exceed the start of the next.Transcript
A fully fetched and parsed transcript for a single video. Returned byTranscriptTrack.fetch().
Ordered tuple of all caption snippets, from first to last.
The YouTube video ID this transcript belongs to.
Full language name (e.g.
"English", "Français").ISO 639-1 language code (e.g.
"en", "fr").True when this is an auto-generated (ASR) caption track, False for manually created captions.Properties
Property. All snippet texts joined with a single space. Useful when you want the full transcript as a plain string for search, summarisation, or storage.
Sequence interface
Transcript is fully iterable, indexable, and supports len():
- Iterate —
for snippet in transcript:yields eachTranscriptSnippetin order. - Index —
transcript[0]returns the firstTranscriptSnippet;transcript[-1]the last;transcript[2:5]returns a tuple of snippets. - Length —
len(transcript)returns the total number of snippets.
Methods
Returns a list of plain
{"text": ..., "start": ..., "duration": ...} dictionaries, one per snippet. Useful for serialisation or passing data to code that does not import ytscrape types.TranscriptTrack
Metadata for one available caption track. Instances are collected inside aTranscriptList and are not downloaded until you call fetch().
The YouTube video ID this track belongs to.
Full language name (e.g.
"English (auto-generated)").ISO 639-1 language code (e.g.
"en").True for auto-generated (ASR) tracks, False for manually created tracks.Properties
Property.
True when YouTube can translate this track into other languages server-side. Use translate() to obtain a translated TranscriptTrack.Property. A tuple of
{"language": …, "language_code": …} dicts listing every language this track can be translated into. Empty tuple when is_translatable is False.Methods
Downloads the timedtext XML for this track, parses it into
TranscriptSnippet instances, and returns a Transcript object.preserve_formatting— whenTrue, semantic HTML tags (<b>,<i>,<em>,<strong>, etc.) are preserved in snippet text instead of being stripped. All other tags are still removed.
ParseError if the transcript XML cannot be parsed or if YouTube requires a PO token for this track.Returns a new
TranscriptTrack that, when fetched, will request a server-side translation into the given language. The returned track has is_generated=True.Raises ParseError if this track is not translatable, or NoTranscriptFound if language_code is not in translation_languages.String representation
str(track) returns a compact human-readable summary, for example:
TranscriptList
The collection of all available caption tracks for a video. Returned byYouTube.transcripts() (which internally calls list_transcripts).
Attributes
The YouTube video ID whose tracks this list represents. Set when the list is constructed and never changes.
Methods
Finds the best available track for the given language priority list. Manually created tracks are preferred over generated (ASR) tracks. The first matching language code wins.Raises
NoTranscriptFound if none of the requested languages are available.Like
find_transcript(), but considers only auto-generated (ASR) tracks. Raises NoTranscriptFound if no generated track matches.Like
find_transcript(), but considers only manually created tracks. Raises NoTranscriptFound if no manual track matches.Iteration and length
TranscriptList is iterable and supports len(). Iterating over it yields every TranscriptTrack — manually created tracks first, then generated tracks. len(transcript_list) returns the total number of tracks across both groups.
String representation
str(transcript_list) prints a human-readable summary of all available tracks grouped by type: