Package io.github.thoroldvix.api
Interface PlaylistsTranscriptApi
public interface PlaylistsTranscriptApi
Retrieves transcripts for all videos in a playlist, or all videos for a specific channel.
Playlists and channel videos are retrieved from the YouTube API, so you will need to have a valid api key to use this.
All methods take a TranscriptRequest
object as a parameter, which contains API key, cookies file path (optional), and stop on error flag (optional, defaults to true).
If cookies are not provided, the API will not be able to access age restricted videos, see Cookies.
TranscriptRequest
also contains a flag to stop on error, or continue on error.
To get implementation for this interface see TranscriptApiFactory
-
Method Summary
Modifier and TypeMethodDescriptiongetTranscriptsForChannel
(String channelName, TranscriptRequest request, String... languageCodes) Retrieves transcript content for all videos for the specified channel.getTranscriptsForPlaylist
(String playlistId, TranscriptRequest request, String... languageCodes) Retrieves transcript content for all videos in the specified playlist.listTranscriptsForChannel
(String channelName, TranscriptRequest request) Retrieves transcript lists for all videos for the specified channel.listTranscriptsForPlaylist
(String playlistId, TranscriptRequest request) Retrieves transcript lists for all videos in the specified playlist.
-
Method Details
-
listTranscriptsForPlaylist
Map<String,TranscriptList> listTranscriptsForPlaylist(String playlistId, TranscriptRequest request) throws TranscriptRetrievalException Retrieves transcript lists for all videos in the specified playlist.- Parameters:
playlistId
- The ID of the playlistrequest
-TranscriptRequest
request object containing API key, cookies file path, and stop on error flag- Returns:
- A map of video IDs to
TranscriptList
objects - Throws:
TranscriptRetrievalException
- If the retrieval of the transcript lists fails
-
listTranscriptsForChannel
Map<String,TranscriptList> listTranscriptsForChannel(String channelName, TranscriptRequest request) throws TranscriptRetrievalException Retrieves transcript lists for all videos for the specified channel.- Parameters:
channelName
- The name of the channelrequest
-TranscriptRequest
request object containing API key, cookies file path, and stop on error flag- Returns:
- A map of video IDs to
TranscriptList
objects - Throws:
TranscriptRetrievalException
- If the retrieval of the transcript lists fails
-
getTranscriptsForPlaylist
Map<String,TranscriptContent> getTranscriptsForPlaylist(String playlistId, TranscriptRequest request, String... languageCodes) throws TranscriptRetrievalException Retrieves transcript content for all videos in the specified playlist.- Parameters:
playlistId
- The ID of the playlistrequest
-TranscriptRequest
request object containing API key, cookies file path, and stop on error flaglanguageCodes
- 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:
- A map of video IDs to
TranscriptContent
objects - Throws:
TranscriptRetrievalException
- If the retrieval of the transcript fails
-
getTranscriptsForChannel
Map<String,TranscriptContent> getTranscriptsForChannel(String channelName, TranscriptRequest request, String... languageCodes) throws TranscriptRetrievalException Retrieves transcript content for all videos for the specified channel.- Parameters:
channelName
- The name of the channelrequest
-TranscriptRequest
request object containing API key, cookies file path, and stop on error flaglanguageCodes
- 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:
- A map of video IDs to
TranscriptContent
objects - Throws:
TranscriptRetrievalException
- If the retrieval of the transcript fails
-