Skip to content

Commit

Permalink
fix: parse fairplay protection correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Mar 26, 2024
1 parent 61decb7 commit 8fdef55
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ const fetchTrackSegments = (tracks) => {
tracks.map(async (track) => {
const playlist = await fetchPlaylist(track.url);
track.segments = segmentsDto(playlist.segments);
if (playlist.contentProtection) track.protection = {};
if (playlist.contentProtection['com.apple.fps.1_0'])
track.protection.fairplay = {
keyFormat: data.contentProtection['com.apple.fps.1_0'].attributes.KEYFORMAT,
uri: data.contentProtection['com.apple.fps.1_0'].attributes.URI,
method: data.contentProtection['com.apple.fps.1_0'].attributes.METHOD,
};
if (playlist.contentProtection) {
track.protection = {};
const fairplayLegacy = playlist.contentProtection['com.apple.fps.1_0'];
if (fairplayLegacy)
track.protection.fairplay = {
keyFormat: fairplayLegacy.attributes.KEYFORMAT,
uri: fairplayLegacy.attributes.URI,
method: fairplayLegacy.attributes.METHOD,
};
}
})
);
};
Expand All @@ -108,11 +111,11 @@ const parseManifest = async (manifestString, manifestUri) => {
const audios = getAudioPlaylists(m3u8, manifestUri);
const subtitles = getSubtitlePlaylists(m3u8, manifestUri);

await Promise.all(
await Promise.all([
fetchTrackSegments(videos),
fetchTrackSegments(audios),
fetchTrackSegments(subtitles)
);
fetchTrackSegments(subtitles),
]);

const manifest = {
tracks: {
Expand Down

0 comments on commit 8fdef55

Please sign in to comment.