mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 05:36:59 -05:00
Add m3u8 selector
This commit is contained in:
parent
0095da4c3b
commit
df96783c97
@ -3,6 +3,7 @@ import sys
|
||||
import ast
|
||||
import requests
|
||||
import xml.etree.ElementTree
|
||||
import m3u8
|
||||
|
||||
UNARY_OPS = (ast.UAdd, ast.USub)
|
||||
BINARY_OPS = (ast.Add, ast.Sub, ast.Mult, ast.Div, ast.Mod)
|
||||
@ -14,6 +15,26 @@ def clean_exit():
|
||||
os._exit(0)
|
||||
|
||||
|
||||
def m3u8_beststream(m3u8_url):
|
||||
bestStream = None
|
||||
videoUrlM3u = m3u8.load(m3u8_url)
|
||||
if len(videoUrlM3u.playlists) > 0:
|
||||
for videoStream in videoUrlM3u.playlists:
|
||||
if bestStream is None:
|
||||
bestStream = videoStream
|
||||
elif ((videoStream.stream_info.resolution[0] > bestStream.stream_info.resolution[0]) and
|
||||
(videoStream.stream_info.resolution[1] > bestStream.stream_info.resolution[1])):
|
||||
bestStream = videoStream
|
||||
elif ((videoStream.stream_info.resolution[0] == bestStream.stream_info.resolution[0]) and
|
||||
(videoStream.stream_info.resolution[1] == bestStream.stream_info.resolution[1]) and
|
||||
(videoStream.stream_info.bandwidth > bestStream.stream_info.bandwidth)):
|
||||
bestStream = videoStream
|
||||
if bestStream is not None:
|
||||
return bestStream.absolute_uri
|
||||
else:
|
||||
return m3u8_url
|
||||
|
||||
|
||||
def sub_el(parent, name, text=None, **kwargs):
|
||||
el = xml.etree.ElementTree.SubElement(parent, name, **kwargs)
|
||||
if text:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user