@@ -14,6 +14,7 @@ public final class SubtitlesStream extends Stream {
1414 private final MediaFormat format ;
1515 private final Locale locale ;
1616 private final boolean autoGenerated ;
17+ private final boolean autoTranslated ;
1718 private final String code ;
1819
1920 /**
@@ -32,6 +33,7 @@ public static final class Builder {
3233 private String languageCode ;
3334 // Use of the Boolean class instead of the primitive type needed for setter call check
3435 private Boolean autoGenerated ;
36+ private Boolean autoTranslated ;
3537
3638 /**
3739 * Create a new {@link Builder} instance with default values.
@@ -152,6 +154,18 @@ public Builder setAutoGenerated(final boolean autoGenerated) {
152154 return this ;
153155 }
154156
157+ /**
158+ * Set whether the subtitles have been automatically translated
159+ * (i.e. by a machine like Google Translator) by the streaming service.
160+ * @param autoTranslated whether the subtitles have been automatically translated by the
161+ * streaming service
162+ * @return this {@link Builder} instance
163+ */
164+ public Builder setAutoTranslated (final boolean autoTranslated ) {
165+ this .autoTranslated = autoTranslated ;
166+ return this ;
167+ }
168+
155169 /**
156170 * Build a {@link SubtitlesStream} using the builder's current values.
157171 *
@@ -196,13 +210,19 @@ public SubtitlesStream build() throws ParsingException {
196210 + "with setIsAutoGenerated." );
197211 }
198212
213+ if (autoTranslated == null ) {
214+ throw new IllegalStateException ("The subtitles stream has been not set as an "
215+ + "automatically translated subtitles stream or not. "
216+ + "Please specify this information with setIsAutoTranslated." );
217+ }
218+
199219 if (id == null ) {
200220 id = languageCode + (mediaFormat != null ? "." + mediaFormat .suffix
201221 : "" );
202222 }
203223
204224 return new SubtitlesStream (id , content , isUrl , mediaFormat , deliveryMethod ,
205- languageCode , autoGenerated , manifestUrl );
225+ languageCode , autoGenerated , autoTranslated , manifestUrl );
206226 }
207227 }
208228
@@ -219,6 +239,7 @@ public SubtitlesStream build() throws ParsingException {
219239 * @param deliveryMethod the {@link DeliveryMethod} of the stream
220240 * @param languageCode the language code of the stream
221241 * @param autoGenerated whether the subtitles are auto-generated by the streaming service
242+ * @param autoTranslated whether the subtitles are auto-translated by the streaming service
222243 * @param manifestUrl the URL of the manifest this stream comes from (if applicable,
223244 * otherwise null)
224245 */
@@ -230,6 +251,7 @@ private SubtitlesStream(@Nonnull final String id,
230251 @ Nonnull final DeliveryMethod deliveryMethod ,
231252 @ Nonnull final String languageCode ,
232253 final boolean autoGenerated ,
254+ final boolean autoTranslated ,
233255 @ Nullable final String manifestUrl ) throws ParsingException {
234256 super (id , content , isUrl , mediaFormat , deliveryMethod , manifestUrl );
235257 this .locale = LocaleCompat .forLanguageTag (languageCode ).orElseThrow (
@@ -238,6 +260,7 @@ private SubtitlesStream(@Nonnull final String id,
238260 this .code = languageCode ;
239261 this .format = mediaFormat ;
240262 this .autoGenerated = autoGenerated ;
263+ this .autoTranslated = autoTranslated ;
241264 }
242265
243266 /**
@@ -250,7 +273,7 @@ public String getExtension() {
250273 }
251274
252275 /**
253- * Return whether if the subtitles are auto-generated.
276+ * Return whether the subtitles are auto-generated.
254277 * <p>
255278 * Some streaming services can generate subtitles for their contents, like YouTube.
256279 * </p>
@@ -261,6 +284,21 @@ public boolean isAutoGenerated() {
261284 return autoGenerated ;
262285 }
263286
287+ /**
288+ * Whether the subtitles are translated automatically by a machine.
289+ *
290+ * <p>
291+ * Some streaming services provide automatically translated subtitles.
292+ * YouTube, for example, uses Google translator to generate translated subtitles.
293+ * Automatically translated subtitles might not coincide completely with the original text.
294+ * </p>
295+ *
296+ * @return {code true} if the subtitles are auto-translated, {@link false} otherwise
297+ */
298+ public boolean isAutoTranslated () {
299+ return autoTranslated ;
300+ }
301+
264302 /**
265303 * {@inheritDoc}
266304 */
0 commit comments