fHDHR_XUMO/fHDHR/origin/origin_channels.py
deathbybandaid f0138a9b61 first
2020-12-06 08:41:24 -05:00

38 lines
971 B
Python

import m3u8
class OriginChannels():
def __init__(self, fhdhr, origin):
self.fhdhr = fhdhr
self.origin = origin
def get_channels(self):
channel_list = []
return channel_list
def get_channel_stream(self, chandict):
streamurl = ''
# if self.fhdhr.config.dict["origin"]["force_best"]:
# streamurl = self.m3u8_beststream(streamurl)
return streamurl
def m3u8_beststream(self, m3u8_url):
bestStream = None
videoUrlM3u = m3u8.load(m3u8_url)
if not videoUrlM3u.is_variant:
return m3u8_url
for videoStream in videoUrlM3u.playlists:
if not bestStream:
bestStream = videoStream
elif videoStream.stream_info.bandwidth > bestStream.stream_info.bandwidth:
bestStream = videoStream
if not bestStream:
return bestStream.absolute_uri
else:
return m3u8_url