Class TranscriptList

java.lang.Object
io.github.thoroldvix.api.TranscriptList
All Implemented Interfaces:
Iterable<Transcript>

public class TranscriptList extends Object implements 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

      public 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.
    • findManualTranscript

      public 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.
    • findGeneratedTranscript

      public 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.
    • getVideoId

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

      public Iterator<Transcript> iterator()
      Specified by:
      iterator in interface Iterable<Transcript>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object