test
This commit is contained in:
parent
afbd590eff
commit
0bd569286b
@ -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
|
||||
|
||||
|
||||
"""
|
||||
{
|
||||
|
||||
@ -40,5 +40,11 @@
|
||||
"config_web": false
|
||||
}
|
||||
},
|
||||
"stirr":{}
|
||||
"stirr":{
|
||||
"force_best":{
|
||||
"value": false,
|
||||
"config_file": true,
|
||||
"config_web": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user