From 0bd569286bf8965549fec110ee9fbf9987402bee Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 15 Dec 2020 10:54:15 -0500 Subject: [PATCH] test --- origin/origin_channels.py | 25 ++++++++++++++++++++++++- origin/origin_conf.json | 8 +++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/origin/origin_channels.py b/origin/origin_channels.py index 1f9c980..bb8eda4 100644 --- a/origin/origin_channels.py +++ b/origin/origin_channels.py @@ -1,3 +1,4 @@ +import m3u8 class OriginChannels(): @@ -44,9 +45,31 @@ class OriginChannels(): return channel_list def get_channel_stream(self, chandict): - streamurl = "" + chan_item_url = "%s/status/%s" % (self.base_api_url, str(chandict["origin_id"])) + chan_item_urlopn = self.fhdhr.web.session.get(chan_item_url) + stirr_chan_item = chan_item_urlopn.json() + streamurl = stirr_chan_item['rss']["channel"]["item"]["link"] + 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 + """ { diff --git a/origin/origin_conf.json b/origin/origin_conf.json index 4d68deb..1786c0b 100644 --- a/origin/origin_conf.json +++ b/origin/origin_conf.json @@ -40,5 +40,11 @@ "config_web": false } }, - "stirr":{} + "stirr":{ + "force_best":{ + "value": false, + "config_file": true, + "config_web": true + } + } }