Skip to content

Commit

Permalink
Never return chapters for audio content (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos authored Apr 23, 2024
1 parent 80f5526 commit ce46a19
Show file tree
Hide file tree
Showing 5 changed files with 772 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/CoreBusiness/Model/MediaComposition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public struct MediaComposition: Decodable {

/// The available chapters.
public var chapters: [Chapter] {
_chapters.filter { $0.fullLengthUrn == chapterUrn && $0.mediaType == mainChapter.mediaType }
guard mainChapter.mediaType == .video else { return [] }
return _chapters.filter { $0.fullLengthUrn == chapterUrn && $0.mediaType == mainChapter.mediaType }
}

/// The related show.
Expand Down
5 changes: 5 additions & 0 deletions Tests/CoreBusinessTests/MediaCompositionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ final class MediaCompositionTests: XCTestCase {
let mediaComposition = Mock.mediaComposition(.mixed)
expect(mediaComposition.chapters.count).to(equal(10))
}

func testAudioChapterRemoval() {
let mediaComposition = Mock.mediaComposition(.audioChapters)
expect(mediaComposition.chapters).to(beEmpty())
}
}
1 change: 1 addition & 0 deletions Tests/CoreBusinessTests/Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum Mock {
case onDemand
case redundant
case mixed
case audioChapters
}

static func mediaComposition(_ kind: MediaCompositionKind = .onDemand) -> MediaComposition {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"data" : [
{
"filename" : "urn_rts_audio_13598743.json",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit ce46a19

Please sign in to comment.