Skip to content

Commit

Permalink
[MediaCCC] Extract audio language property for single language audio …
Browse files Browse the repository at this point in the history
…tracks
  • Loading branch information
AudricV committed Feb 22, 2023
1 parent cb6a397 commit 6a994a3
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -114,15 +115,24 @@ public List<AudioStream> getAudioStreams() throws ExtractionException {
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;
Expand Down

0 comments on commit 6a994a3

Please sign in to comment.