Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
Call completion on main queue in parser (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
omaralbeik authored Apr 24, 2022
1 parent e34974a commit 4521ede
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ The [Swift Package Manager](https://swift.org/package-manager/) is a tool for ma

```swift
dependencies: [
.package(url: "https://github.com/omaralbeik/M3UKit.git", from: "0.5.1")
.package(url: "https://github.com/omaralbeik/M3UKit.git", from: "0.5.2")
]
```

Expand All @@ -121,15 +121,15 @@ $ swift build
To integrate M3UKit into your Xcode project using [CocoaPods](https://cocoapods.org), specify it in your Podfile:

```rb
pod 'M3UKit', :git => 'https://github.com/omaralbeik/M3UKit.git', :tag => '0.5.1'
pod 'M3UKit', :git => 'https://github.com/omaralbeik/M3UKit.git', :tag => '0.5.2'
```

### Carthage

To integrate M3UKit into your Xcode project using [Carthage](https://github.com/Carthage/Carthage), specify it in your Cartfile:

```
github "omaralbeik/M3UKit" ~> 0.5.1
github "omaralbeik/M3UKit" ~> 0.5.2
```

### Manually
Expand Down
5 changes: 0 additions & 5 deletions Sources/M3UKit/Models/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,5 @@ extension Playlist {

/// Channel URL.
public var url: URL

/// Whether the channel is a live channel (its URL ends with .m3u8) or not.
public var isLive: Bool {
url.absoluteString.hasSuffix(".m3u8")
}
}
}
4 changes: 3 additions & 1 deletion Sources/M3UKit/Parsers/PlaylistParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ public final class PlaylistParser: Parser {
queue.async {
do {
let playlist = try self.parse(input)
completion(.success(playlist))
DispatchQueue.main.async {
completion(.success(playlist))
}
} catch {
DispatchQueue.main.async {
completion(.failure(error))
Expand Down
18 changes: 0 additions & 18 deletions Tests/M3UKitTests/ChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ final class ChannelTests: XCTestCase {
XCTAssertEqual(channel.url, url)
}

func testIsLive() {
let liveChannel = Playlist.Channel(
duration: -1,
attributes: .init(),
name: "Channel",
url: URL(string: "https://cnn-cnninternational-1-de.samsung.wurl.com/manifest/playlist.m3u8")!
)
XCTAssert(liveChannel.isLive)

let channel = Playlist.Channel(
duration: -1,
attributes: .init(),
name: "Channel",
url: URL(string: "https://not.a/real/url")!
)
XCTAssertFalse(channel.isLive)
}

func testExtractingDuration() throws {
let parser = ChannelMetadataParser()
XCTAssertThrowsError(try parser.extractDuration((1, "invalid")))
Expand Down

0 comments on commit 4521ede

Please sign in to comment.