[MediaCCC] Extract audio language property for single language audio tracks

This commit is contained in:
AudricV 2023-01-31 19:25:58 +01:00
parent 7f0269c4c7
commit 30a0f8c510
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
1 changed files with 16 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.JsonUtils;
import org.schabi.newpipe.extractor.utils.LocaleCompat;
import java.io.IOException;
import java.util.ArrayList;
@ -114,15 +115,24 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
mediaFormat = null;
}
// Not checking containsSimilarStream here, since MediaCCC does not provide enough
// information to decide whether two streams are similar. Hence that method would
// always return false, e.g. even for different language variations.
audioStreams.add(new AudioStream.Builder()
final AudioStream.Builder builder = new AudioStream.Builder()
.setId(recording.getString("filename", ID_UNKNOWN))
.setContent(recording.getString("recording_url"), true)
.setMediaFormat(mediaFormat)
.setAverageBitrate(UNKNOWN_BITRATE)
.build());
.setAverageBitrate(UNKNOWN_BITRATE);
final String language = recording.getString("language");
// If the language contains a - symbol, this means that the stream has an audio
// track with multiple languages, so there is no specific language for this stream
// Don't set the audio language in this case
if (language != null && !language.contains("-")) {
builder.setAudioLocale(LocaleCompat.forLanguageTag(language));
}
// Not checking containsSimilarStream here, since MediaCCC does not provide enough
// information to decide whether two streams are similar. Hence that method would
// always return false, e.g. even for different language variations.
audioStreams.add(builder.build());
}
}
return audioStreams;