Package io.github.thoroldvix.api
Class TranscriptList
java.lang.Object
io.github.thoroldvix.api.TranscriptList
- All Implemented Interfaces:
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 TypeMethodDescriptionbooleanfindGeneratedTranscript(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.Retrieves the ID of the video to which transcript was retrieved.inthashCode()iterator()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, 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.
-
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.
-
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
Retrieves the ID of the video to which transcript was retrieved.- Returns:
- The video ID.
-
iterator
- Specified by:
iteratorin interfaceIterable<Transcript>
-
equals
-
hashCode
public int hashCode() -
toString
-