Interface TranscriptList

All Superinterfaces:
Iterable<Transcript>

public interface TranscriptList extends Iterable<Transcript>
Represents a list of all available transcripts for a YouTube video.

This interface provides methods to iterate over all available transcripts for a given YouTube video, and to find either generated or manual transcripts for a specific language. Individual transcripts are represented by Transcript objects. Instances of TranscriptList can be obtained through the YoutubeTranscriptApi class.

  • Method Details

    • findTranscript

      Transcript findTranscript(String... languageCodes) throws TranscriptRetrievalException
      Searches for a transcript using the provided language codes. Manually created transcripts are prioritized, and if none are found, generated transcripts are used. If you only want generated or manually created transcripts, use findGeneratedTranscript(String...) or findManualTranscript(String...) instead.
      Parameters:
      languageCodes - A varargs list of language codes in descending priority.

      For example:

      If this is set to ("de", "en"), it will first attempt to fetch the German transcript ("de"), and then fetch the English transcript ("en") if the former fails. If no language code is provided, it uses English as the default language.
      Returns:
      The found Transcript.
      Throws:
      TranscriptRetrievalException - If no transcript could be found for the given language codes.
    • findGeneratedTranscript

      Transcript findGeneratedTranscript(String... languageCodes) throws TranscriptRetrievalException
      Searches for an automatically generated transcript using the provided language codes.
      Parameters:
      languageCodes - A varargs list of language codes in descending priority.

      For example:

      If this is set to ("de", "en"), it will first attempt to fetch the German transcript ("de"), and then fetch the English transcript ("en") if the former fails. If no language code is provided, it uses English as the default language.
      Returns:
      The found Transcript.
      Throws:
      TranscriptRetrievalException - If no transcript could be found for the given language codes.
    • findManualTranscript

      Transcript findManualTranscript(String... languageCodes) throws TranscriptRetrievalException
      Searches for a manually created transcript using the provided language codes.
      Parameters:
      languageCodes - A varargs list of language codes in descending priority.

      For example:

      If this is set to ("de", "en"), it will first attempt to fetch the German transcript ("de"), and then fetch the English transcript ("en") if the former fails. If no language code is provided, it uses English as the default language.
      Returns:
      The found Transcript.
      Throws:
      TranscriptRetrievalException - If no transcript could be found for the given language codes.
    • getVideoId

      String getVideoId()
      Retrieves the ID of the video to which transcript was retrieved.
      Returns:
      The video ID.
    • forEach

      default void forEach(Consumer<? super Transcript> action)
      Specified by:
      forEach in interface Iterable<Transcript>