|
8 | 8 | * Retrieves transcripts for all videos in a playlist, or all videos for a specific channel.
|
9 | 9 | * <p>
|
10 | 10 | * Playlists and channel videos are retrieved from the YouTube API, so you will need to have a valid api key to use this.
|
| 11 | + * <p> |
| 12 | + * All methods take a {@link TranscriptRequest} object as a parameter, which contains API key, cookies file path (optional), and stop on error flag (optional, defaults to true). |
| 13 | + * If cookies are not provided, the API will not be able to access age restricted videos, see <a href="https://github.com/Thoroldvix/youtube-transcript-api#cookies">Cookies</a>. |
| 14 | + * <p> |
| 15 | + * {@link TranscriptRequest} also contains a flag to stop on error, or continue on error. |
11 | 16 | * </p>
|
12 | 17 | * <p>
|
13 | 18 | * To get implementation for this interface see {@link TranscriptApiFactory}
|
|
16 | 21 | public interface PlaylistsTranscriptApi {
|
17 | 22 |
|
18 | 23 | /**
|
19 |
| - * Retrieves transcript lists for all videos in the specified playlist using provided API key and cookies file from a specified path. |
| 24 | + * Retrieves transcript lists for all videos in the specified playlist. |
20 | 25 | *
|
21 |
| - * @param playlistId The ID of the playlist |
22 |
| - * @param apiKey API key for the YouTube V3 API (see <a href="https://developers.google.com/youtube/v3/getting-started">Getting started</a>) |
23 |
| - * @param continueOnError Whether to continue if transcript retrieval fails for a video. If true, all transcripts that could not be retrieved will be skipped, |
24 |
| - * otherwise an exception will be thrown. |
25 |
| - * @param cookiesPath The file path to the text file containing the authentication cookies. Used in the case if some videos are age restricted see {<a href="https://github.com/Thoroldvix/youtube-transcript-api#cookies">Cookies</a>} |
| 26 | + * @param playlistId The ID of the playlist |
| 27 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
26 | 28 | * @return A map of video IDs to {@link TranscriptList} objects
|
27 | 29 | * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails
|
28 | 30 | */
|
29 |
| - Map<String, TranscriptList> listTranscriptsForPlaylist(String playlistId, String apiKey, String cookiesPath, boolean continueOnError) throws TranscriptRetrievalException; |
| 31 | + Map<String, TranscriptList> listTranscriptsForPlaylist(String playlistId, TranscriptRequest request) throws TranscriptRetrievalException; |
30 | 32 |
|
31 | 33 |
|
32 | 34 | /**
|
33 |
| - * Retrieves transcript lists for all videos in the specified playlist using provided API key. |
| 35 | + * Retrieves transcript lists for all videos for the specified channel. |
34 | 36 | *
|
35 |
| - * @param playlistId The ID of the playlist |
36 |
| - * @param apiKey API key for the YouTube V3 API (see <a href="https://developers.google.com/youtube/v3/getting-started">Getting started</a>) |
37 |
| - * @param continueOnError Whether to continue if transcript retrieval fails for a video. If true, all transcripts that could not be retrieved will be skipped, |
38 |
| - * otherwise an exception will be thrown. |
| 37 | + * @param channelName The name of the channel |
| 38 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
39 | 39 | * @return A map of video IDs to {@link TranscriptList} objects
|
40 | 40 | * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails
|
41 | 41 | */
|
42 |
| - Map<String, TranscriptList> listTranscriptsForPlaylist(String playlistId, String apiKey, boolean continueOnError) throws TranscriptRetrievalException; |
| 42 | + Map<String, TranscriptList> listTranscriptsForChannel(String channelName, TranscriptRequest request) throws TranscriptRetrievalException; |
43 | 43 |
|
44 | 44 |
|
45 | 45 | /**
|
46 |
| - * Retrieves transcript lists for all videos for the specified channel using provided API key and cookies file from a specified path. |
| 46 | + * Retrieves transcript content for all videos in the specified playlist. |
47 | 47 | *
|
48 |
| - * @param channelName The name of the channel |
49 |
| - * @param apiKey API key for the YouTube V3 API (see <a href="https://developers.google.com/youtube/v3/getting-started">Getting started</a>) |
50 |
| - * @param cookiesPath The file path to the text file containing the authentication cookies. Used in the case if some videos are age restricted see {<a href="https://github.com/Thoroldvix/youtube-transcript-api#cookies">Cookies</a>} |
51 |
| - * @param continueOnError Whether to continue if transcript retrieval fails for a video. If true, all transcripts that could not be retrieved will be skipped, |
52 |
| - * otherwise an exception will be thrown. |
53 |
| - * @return A map of video IDs to {@link TranscriptList} objects |
54 |
| - * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails |
55 |
| - * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails |
| 48 | + * @param playlistId The ID of the playlist |
| 49 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
| 50 | + * @param languageCodes A varargs list of language codes in descending priority. |
| 51 | + * <p> |
| 52 | + * For example: |
| 53 | + * </p> |
| 54 | + * If this is set to {@code ("de", "en")}, it will first attempt to fetch the German transcript ("de"), and then fetch the English |
| 55 | + * transcript ("en") if the former fails. If no language code is provided, it uses English as the default language. |
| 56 | + * @return A map of video IDs to {@link TranscriptContent} objects |
| 57 | + * @throws TranscriptRetrievalException If the retrieval of the transcript fails |
56 | 58 | */
|
57 |
| - Map<String, TranscriptList> listTranscriptsForChannel(String channelName, String apiKey, String cookiesPath, boolean continueOnError) throws TranscriptRetrievalException; |
| 59 | + Map<String, TranscriptContent> getTranscriptsForPlaylist(String playlistId, |
| 60 | + TranscriptRequest request, |
| 61 | + String... languageCodes) throws TranscriptRetrievalException; |
58 | 62 |
|
59 | 63 |
|
60 | 64 | /**
|
61 |
| - * Retrieves transcript lists for all videos for the specified channel using provided API key. |
| 65 | + * Retrieves transcript content for all videos for the specified channel. |
62 | 66 | *
|
63 |
| - * @param channelName The name of the channel |
64 |
| - * @param apiKey API key for the YouTube V3 API (see <a href="https://developers.google.com/youtube/v3/getting-started">Getting started</a>) |
65 |
| - * @param continueOnError Whether to continue if transcript retrieval fails for a video. If true, all transcripts that could not be retrieved will be skipped, |
66 |
| - * otherwise an exception will be thrown. |
67 |
| - * @return A map of video IDs to {@link TranscriptList} objects |
68 |
| - * @throws TranscriptRetrievalException If the retrieval of the transcript lists fails |
| 67 | + * @param channelName The name of the channel |
| 68 | + * @param request {@link TranscriptRequest} request object containing API key, cookies file path, and stop on error flag |
| 69 | + * @param languageCodes A varargs list of language codes in descending priority. |
| 70 | + * <p> |
| 71 | + * For example: |
| 72 | + * </p> |
| 73 | + * If this is set to {@code ("de", "en")}, it will first attempt to fetch the German transcript ("de"), and then fetch the English |
| 74 | + * transcript ("en") if the former fails. If no language code is provided, it uses English as the default language. |
| 75 | + * @return A map of video IDs to {@link TranscriptContent} objects |
| 76 | + * @throws TranscriptRetrievalException If the retrieval of the transcript fails |
69 | 77 | */
|
70 |
| - Map<String, TranscriptList> listTranscriptsForChannel(String channelName, String apiKey, boolean continueOnError) throws TranscriptRetrievalException; |
| 78 | + Map<String, TranscriptContent> getTranscriptsForChannel(String channelName, TranscriptRequest request, String... languageCodes) throws TranscriptRetrievalException; |
71 | 79 | }
|
0 commit comments