Skip to content

Commit

Permalink
FEM-2746 Fix download of audio-only assets (#53)
Browse files Browse the repository at this point in the history
The chunks for the audio tracks are saved to the "video" directory but the playlist is in "audio" (and the master links to "audio" as well).
  • Loading branch information
noamtamim authored and x-NR-x committed Nov 28, 2019
1 parent b361124 commit 4068ec6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Sources/HLSLocalizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class HLSLocalizer {
try save(text: localMaster.joined(separator: "\n") + "\n", as: MASTER_PLAYLIST_NAME)

// Localize the selected video stream
try saveMediaPlaylist(videoStream)
try saveMediaPlaylist(videoStream, forceVideo: true)

// Localize the selected audio and text streams
for stream in selectedAudioStreams {
Expand Down Expand Up @@ -175,11 +175,11 @@ class HLSLocalizer {
return line.hasPrefix("#EXT-X-SESSION-KEY:") && line.contains(KEYFORMAT_FAIRPLAY)
}

private func saveMediaPlaylist<T>(_ stream: Stream<T>) throws {
private func saveMediaPlaylist<T>(_ stream: Stream<T>, forceVideo: Bool = false) throws {
let mediaPlaylist = stream.mediaPlaylist
let originalUrl = stream.mediaUrl
let mapUrl = stream.mapUrl
let type = stream.trackType
let type = forceVideo ? DownloadItemTaskType.video : stream.trackType

guard let originalText = mediaPlaylist.originalText else { throw HLSLocalizerError.invalidState }
#if DEBUG
Expand Down
2 changes: 1 addition & 1 deletion Sources/HLSLocalizerUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class VideoStream: Stream<M3U8ExtXStreamInf>, CustomStringConvertible {
return M3U8_EXT_X_STREAM_INF +
attribs.map { $0 + "=" + $1 }.joined(separator: ",") +
"\n" +
self.mediaUrl.mediaPlaylistRelativeLocalPath(as: self.trackType)
self.mediaUrl.mediaPlaylistRelativeLocalPath(as: .video)
}
}

Expand Down

0 comments on commit 4068ec6

Please sign in to comment.