Notifications
Clear all

Welcome to bestrestream iptv forum• İp Tv Forum • IPTV community • IPTV Forum Site

If email confirmation not received check spam box in your email.

  • Everyone is invited! My iptv forum is for everyone, new and advanced user alike!
  • Searching is key! Before you post a question, use the iptv forum search feature to determine whether your topic has already been covered.
  • Do not start flame wars! If someone has engaged in behavior that is detrimental to the discussion -- spamming, harassment, etc -- report the post and we'll take a look.
  • Join us now to access all our features. Once you register and login, you will be able to create topics, reply to existing topics, give reputation to your other members, get your own private messenger, and much more. It's also fast and completely free, so what are you waiting for?

how to parse logo image from m3u playlist

1 Posts
1 Users
0 Reactions
110 Views
tycoon
(@tycoon)
Posts: 39
Estimable Member
Topic starter
 

I have a parsing m3u playlist url but I can't parse image url too?

all source code from 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
}

Any suggestions to parsing the channel logo is provided by tvg-logo.

example:

#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 
 

1 Answer

//You can do this, and linkIm3 gives you the url for the image    
let val2 = line.components(separatedBy: " ")
for sep in val2{
    if sep.hasPrefix("tvg-logo="){
        let sep2 = sep.components(separatedBy: ",")
        let sep1 = sep2[0]
        let indexStartOfText = sep1.index(sep1.startIndex, offsetBy: 10)
        linkIm2 = String(sep1[indexStartOfText...])
        let indexEndOfText = linkIm2.index(linkIm2.endIndex, offsetBy: -1)
        linkIm3 = String(linkIm2[..<indexEndOfText])
     }
 }
 
Posted : 10/07/2024 2:36 pm
Share:
Scroll to Top