-
Notifications
You must be signed in to change notification settings - Fork 475
Usage
Mauricio Antunes edited this page Aug 10, 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
import m3u8
def get_segments(m3u8_url):
def load_m3u8(url):
urls = []
m = m3u8.load(url)
for seg in m.segments:
urls.append(seg.absolute_uri)
return urls
try:
video_urls = load_m3u8(m3u8_url)
except Exception as e:
# print('load_m3u8 {}'.format(e))
return {'reason': 'load_m3u8 {}'.format(e)}
else:
return {'video_urls': video_urls}