Skip to content
Mauricio Antunes edited this page May 13, 2024 · 4 revisions

The most frequently usage for you to use this m3u8 module is perhaps you want to get the playlist URLs, here is the fast way, for example

def loadM3u8(m3u8url):
    def load_m3u8(url):
        urls = []
        m = m3u8.load(url)
        for seg in m.segments:
            urls.append(seg.absolute_uri)
        return urls
    try:
        videoUrls = load_m3u8(m3u8url)
    except Exception as e:
        # print('load_m3u8 {}'.format(e))
        return {'reason': 'load_m3u8 {}'.format(e)} 
    else:
        return {'videoUrls': videoUrls}
Clone this wiki locally