我有一个解析 m3u 播放列表 url,但我也无法解析图像 url?
来自 GitHub 的所有源代码:https ://github.com/ArtemStepuk/zombobox
extension IPTVM3U8PareserService: M3U8ParserService {
func extractChannelsFromRawString(_ string: String) -> [Channel] {
var channels = [Channel]()
string.enumerateLines { line, shouldStop in
if line.hasPrefix("#EXTINF:") {
let infoLine = line.replacingOccurrences(of: "#EXTINF:", with: "")
let infoItems = infoLine.components(separatedBy: ",")
if let title = infoItems.last {
let channel = Channel(title: title, url: nil, logo: nil)
channels.append(channel)
}
} else {
if var channel = channels.popLast() {
channel.url = URL(string: line)
channels.append(channel)
}
}
}
return channels
}
解析频道徽标的任何建议均由tvg-logo
.
例子:
#EXTINF:-1 tvg-logo="http://i.cdn.turner.com/adultswim/big/video/mainstream/liveStream.jpg" group-title="USA",[AS] Live Stream
http://adultswimhls-i.akamaihd.net/hls/live/238460/adultswim/main/1/master_Layer5.m3u8