mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 10:23:24 +00:00
fix: filter out duplicate audiotracks
This commit is contained in:
@@ -113,17 +113,26 @@ export const ScraperProcess = ({ data }: ScraperProcessProps) => {
|
||||
};
|
||||
|
||||
if (tracks?.audio.length) {
|
||||
const audioTracks: AudioTrack[] = tracks.audio.map((track) => ({
|
||||
const audioTracks: AudioTrack[] = tracks.audio
|
||||
.map((track) => ({
|
||||
uri: constructFullUrl(
|
||||
(streamResult.stream as HlsBasedStream).playlist,
|
||||
track.uri,
|
||||
),
|
||||
name: (track.properties[0]?.attributes.name as string) ?? "Unknown",
|
||||
name:
|
||||
(track.properties[0]?.attributes.name as string) ?? "Unknown",
|
||||
language:
|
||||
(track.properties[0]?.attributes.language as string) ?? "Unknown",
|
||||
(track.properties[0]?.attributes.language as string) ??
|
||||
"Unknown",
|
||||
active:
|
||||
(track.properties[0]?.attributes.default as boolean) ?? false,
|
||||
}));
|
||||
}))
|
||||
.filter((track, index, self) => {
|
||||
const trackUriSet = new Set(self.map((t) => t.uri));
|
||||
return (
|
||||
!trackUriSet.has(track.uri) || trackUriSet.size === index + 1
|
||||
);
|
||||
});
|
||||
setAudioTracks(audioTracks);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user