parent
5b79ef3557
commit
c1cfb2b223
|
@ -750,8 +750,10 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
final String baseUrl = captionsArray.getObject(i).getString("baseUrl");
|
final String baseUrl = captionsArray.getObject(i).getString("baseUrl");
|
||||||
final boolean isAutoGenerated = captionsArray.getObject(i).getString("vssId").startsWith("a.");
|
final boolean isAutoGenerated = captionsArray.getObject(i).getString("vssId").startsWith("a.");
|
||||||
|
|
||||||
result.add(new Subtitles(SubtitlesFormat.TTML, languageCode, baseUrl, isAutoGenerated));
|
result.add(new Subtitles(SubtitlesFormat.TTML, languageCode,
|
||||||
result.add(new Subtitles(SubtitlesFormat.VTT, languageCode, baseUrl, isAutoGenerated));
|
getSubtitleFormatUrl(baseUrl, SubtitlesFormat.TTML), isAutoGenerated));
|
||||||
|
result.add(new Subtitles(SubtitlesFormat.VTT, languageCode,
|
||||||
|
getSubtitleFormatUrl(baseUrl, SubtitlesFormat.VTT), isAutoGenerated));
|
||||||
// todo: add transcripts, they are currently omitted since they are incompatible with ExoPlayer
|
// todo: add transcripts, they are currently omitted since they are incompatible with ExoPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,26 +785,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static List<Subtitles> getVideoSubtitlesUrl(final String baseUrl,
|
private static String getSubtitleFormatUrl(final String baseUrl, final SubtitlesFormat format) {
|
||||||
final List<String> manualCaptionLanguageCodes,
|
return baseUrl.replaceAll("&fmt=[^&]*", "") + "&fmt=" + format.getExtension();
|
||||||
final List<String> automaticCaptionLanguageCodes,
|
|
||||||
final SubtitlesFormat format) {
|
|
||||||
final String cleanUrl = baseUrl
|
|
||||||
.replaceAll("&fmt=[^&]*", "") // Remove preexisting format if exists
|
|
||||||
.replaceAll("&tlang=[^&]*", "") // Remove translation language
|
|
||||||
.replaceAll("&kind=[^&]*", ""); // Remove automatic generation toggle
|
|
||||||
final String builderUrl = cleanUrl + "&fmt=" + format.getExtension() + "&tlang=";
|
|
||||||
|
|
||||||
List<Subtitles> subtitles = new ArrayList<>(manualCaptionLanguageCodes.size() +
|
|
||||||
automaticCaptionLanguageCodes.size());
|
|
||||||
for (final String languageCode : manualCaptionLanguageCodes) {
|
|
||||||
subtitles.add(new Subtitles(format, languageCode, builderUrl + languageCode, false));
|
|
||||||
}
|
|
||||||
for (final String languageCode : automaticCaptionLanguageCodes) {
|
|
||||||
final String fullUrl = builderUrl + languageCode + "&kind=asr";
|
|
||||||
subtitles.add(new Subtitles(format, languageCode, fullUrl, true));
|
|
||||||
}
|
|
||||||
return subtitles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, ItagItem> getItags(String encodedUrlMapKey, ItagItem.ItagType itagTypeWanted) throws ParsingException {
|
private Map<String, ItagItem> getItags(String encodedUrlMapKey, ItagItem.ItagType itagTypeWanted) throws ParsingException {
|
||||||
|
|
Loading…
Reference in New Issue