Improve Streams with Headers and Quality Options

This commit is contained in:
deathbybandaid 2021-01-20 16:01:13 -05:00
parent a9f183b22a
commit fc9700f0ae

View File

@ -1,4 +1,3 @@
import m3u8
class OriginChannels():
@ -32,8 +31,6 @@ class OriginChannels():
origin_chandict = self.get_channel_dict(channels_json, "identifier", chandict["origin_id"])
streamdict = self.get_channel_dict(origin_chandict["streams"], "StreamType", 'website')
streamurl = streamdict['Url']
if self.fhdhr.config.dict["origin"]["force_best"]:
streamurl = self.m3u8_beststream(streamurl)
stream_info = {"url": streamurl}
@ -41,20 +38,3 @@ class OriginChannels():
def get_channel_dict(self, chanlist, keyfind, valfind):
return next(item for item in chanlist if item[keyfind] == valfind)
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