### Create a Playlist Parser Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Instantiate the PlaylistParser to begin parsing m3u files. No specific setup is required before creating the parser. ```swift let parser = PlaylistParser() ``` -------------------------------- ### CocoaPods Installation Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Integrate M3UKit into your Xcode project by specifying it in your Podfile using the provided Git repository and tag. ```ruby pod 'M3UKit', :git => 'https://github.com/omaralbeik/M3UKit.git', :tag => '0.8.1' ``` -------------------------------- ### Swift Package Manager Installation Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Add M3UKit as a dependency in your Package.swift file for integration using Swift Package Manager. Then, build your project. ```swift dependencies: [ .package(url: "https://github.com/omaralbeik/M3UKit.git", from: "0.8.1") ] ``` ```sh $ swift build ``` -------------------------------- ### Carthage Installation Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Specify M3UKit in your Cartfile for integration using Carthage. Use the provided GitHub repository and version constraint. ```text github "omaralbeik/M3UKit" ~> 0.8.1 ``` -------------------------------- ### Parse Playlist Asynchronously (Async/Await) Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Parse an m3u playlist asynchronously using the async/await API. This provides a more modern and sequential-looking asynchronous code structure. This operation can throw errors. ```swift let playlist = try await parser.parse(url) ``` -------------------------------- ### Parse Playlist from Local File Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Parse an m3u playlist from a local file in the application's bundle. The file must be correctly added to the bundle and have the .m3u extension. This operation can throw errors. ```swift let url = Bundle.main.url(forResource: "playlist", withExtension: "m3u")! let playlist = try parser.parse(url) ``` -------------------------------- ### Parse Playlist from URL Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Parse an m3u playlist directly from a URL. Ensure the URL is valid and points to an m3u file. This operation can throw errors. ```swift let url = URL(string: "https://domain.com/link/to/m3u/file") let playlist = try parser.parse(url) ``` -------------------------------- ### Parse Playlist Asynchronously (Completion Handler) Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Parse an m3u playlist asynchronously using a completion handler. This is suitable for non-blocking operations. The result is delivered via a success or failure case. ```swift parser.parse(url) { result in switch result { case .success(let playlist): // consume playlist case .failure(let error): // handle error } } ``` -------------------------------- ### Parse Playlist from String Source: https://github.com/omaralbeik/m3ukit/blob/main/README.md Parse an m3u playlist directly from a raw string. This is useful for playlists provided as text. This operation can throw errors. ```swift let raw = """#EXTM3U #EXTINF:-1 tvg-id=\"DenHaagTV.nl\",Den Haag TV (1080p) http://wowza5.video-streams.nl:1935/denhaag/denhaag/playlist.m3u8 """ let playlist = try parser.parse(raw) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.