|
2 | 2 |
|
3 | 3 | import io.github.thoroldvix.internal.TranscriptApiFactory; |
4 | 4 |
|
| 5 | +import java.util.Map; |
| 6 | + |
5 | 7 | /** |
6 | 8 | * This is the main interface for the YouTube Transcript API. |
7 | 9 | * <p> |
8 | | - * It provides functionality for retrieving all available transcripts or retrieving actual transcript content from YouTube. |
| 10 | + * It provides functionality for retrieving all available transcripts or retrieving actual transcript content for a single video, playlist, or channel. |
9 | 11 | * </p> |
10 | 12 | * <p> |
11 | 13 | * To instantiate this API, you should use {@link TranscriptApiFactory}. |
@@ -94,4 +96,61 @@ public interface YoutubeTranscriptApi { |
94 | 96 | * @throws IllegalArgumentException If the video ID is invalid |
95 | 97 | */ |
96 | 98 | TranscriptContent getTranscript(String videoId, String... languageCodes) throws TranscriptRetrievalException; |
| 99 | + |
| 100 | + /** |
| 101 | + * Retrieves transcript lists for all videos in the specified playlist. |
| 102 | + * |
| 103 | + * @param playlistId The ID of the playlist |
| 104 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
| 105 | + * @return A map of video IDs to {@link TranscriptList} objects |
| 106 | + * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails |
| 107 | + */ |
| 108 | + Map<String, TranscriptList> listTranscriptsForPlaylist(String playlistId, TranscriptRequest request) throws TranscriptRetrievalException; |
| 109 | + |
| 110 | + |
| 111 | + /** |
| 112 | + * Retrieves transcript lists for all videos for the specified channel. |
| 113 | + * |
| 114 | + * @param channelName The name of the channel |
| 115 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
| 116 | + * @return A map of video IDs to {@link TranscriptList} objects |
| 117 | + * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails |
| 118 | + */ |
| 119 | + Map<String, TranscriptList> listTranscriptsForChannel(String channelName, TranscriptRequest request) throws TranscriptRetrievalException; |
| 120 | + |
| 121 | + |
| 122 | + /** |
| 123 | + * Retrieves transcript content for all videos in the specified playlist. |
| 124 | + * |
| 125 | + * @param playlistId The ID of the playlist |
| 126 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
| 127 | + * @param languageCodes A varargs list of language codes in descending priority. |
| 128 | + * <p> |
| 129 | + * For example: |
| 130 | + * </p> |
| 131 | + * If this is set to {@code ("de", "en")}, it will first attempt to fetch the German transcript ("de"), and then fetch the English |
| 132 | + * transcript ("en") if the former fails. If no language code is provided, it uses English as the default language. |
| 133 | + * @return A map of video IDs to {@link TranscriptContent} objects |
| 134 | + * @throws TranscriptRetrievalException If the retrieval of the transcript fails |
| 135 | + */ |
| 136 | + Map<String, TranscriptContent> getTranscriptsForPlaylist(String playlistId, |
| 137 | + TranscriptRequest request, |
| 138 | + String... languageCodes) throws TranscriptRetrievalException; |
| 139 | + |
| 140 | + |
| 141 | + /** |
| 142 | + * Retrieves transcript content for all videos for the specified channel. |
| 143 | + * |
| 144 | + * @param channelName The name of the channel |
| 145 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
| 146 | + * @param languageCodes A varargs list of language codes in descending priority. |
| 147 | + * <p> |
| 148 | + * For example: |
| 149 | + * </p> |
| 150 | + * If this is set to {@code ("de", "en")}, it will first attempt to fetch the German transcript ("de"), and then fetch the English |
| 151 | + * transcript ("en") if the former fails. If no language code is provided, it uses English as the default language. |
| 152 | + * @return A map of video IDs to {@link TranscriptContent} objects |
| 153 | + * @throws TranscriptRetrievalException If the retrieval of the transcript fails |
| 154 | + */ |
| 155 | + Map<String, TranscriptContent> getTranscriptsForChannel(String channelName, TranscriptRequest request, String... languageCodes) throws TranscriptRetrievalException; |
97 | 156 | } |
0 commit comments