Package io.github.thoroldvix.api
Interface TranscriptList
- All Superinterfaces:
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 Summary
Modifier and TypeMethodDescriptionfindGeneratedTranscript
(String... languageCodes) Searches for an automatically generated transcript using the provided language codes.findManualTranscript
(String... languageCodes) Searches for a manually created transcript using the provided language codes.findTranscript
(String... languageCodes) Searches for a transcript using the provided language codes.default void
forEach
(Consumer<? super Transcript> action) Retrieves the ID of the video to which transcript was retrieved.Methods inherited from interface java.lang.Iterable
iterator, spliterator
-
Method Details
-
findTranscript
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, usefindGeneratedTranscript(String...)
orfindManualTranscript(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
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
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
- Specified by:
forEach
in interfaceIterable<Transcript>
-