mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 04:05:39 +01:00
Add resolution info to --list-quality
This commit is contained in:
parent
4c8ed0de43
commit
7a85dc7d74
@ -23,6 +23,7 @@ class VideoRetriever:
|
|||||||
self.output_extention = None
|
self.output_extention = None
|
||||||
channels = kwargs.pop("channels", None)
|
channels = kwargs.pop("channels", None)
|
||||||
codec = kwargs.pop("codec", "h264")
|
codec = kwargs.pop("codec", "h264")
|
||||||
|
self.resolution = kwargs.pop("resolution", "")
|
||||||
self.format = f"{codec}-{channels}" if channels else codec
|
self.format = f"{codec}-{channels}" if channels else codec
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -130,6 +130,10 @@ def adaptionset(attributes, elements, url, baseurl=None):
|
|||||||
if "lang" in element.attrib:
|
if "lang" in element.attrib:
|
||||||
lang = element.attrib["lang"]
|
lang = element.attrib["lang"]
|
||||||
|
|
||||||
|
resolution = None
|
||||||
|
if "maxWidth" in element.attrib and "maxHeight" in element.attrib:
|
||||||
|
resolution = f'{element.attrib["maxWidth"]}x{element.attrib["maxHeight"]}'
|
||||||
|
|
||||||
for i in represtation:
|
for i in represtation:
|
||||||
files = []
|
files = []
|
||||||
segments = False
|
segments = False
|
||||||
@ -154,6 +158,8 @@ def adaptionset(attributes, elements, url, baseurl=None):
|
|||||||
codec = "hevc"
|
codec = "hevc"
|
||||||
else:
|
else:
|
||||||
codec = codecs
|
codec = codecs
|
||||||
|
if not resolution and "maxWidth" in i.attrib and "maxHeight" in i.attrib:
|
||||||
|
resolution = f'{element.attrib["maxWidth"]}x{element.attrib["maxHeight"]}'
|
||||||
if i.find("{urn:mpeg:dash:schema:mpd:2011}AudioChannelConfiguration") is not None:
|
if i.find("{urn:mpeg:dash:schema:mpd:2011}AudioChannelConfiguration") is not None:
|
||||||
chan = i.find("{urn:mpeg:dash:schema:mpd:2011}AudioChannelConfiguration").attrib["value"]
|
chan = i.find("{urn:mpeg:dash:schema:mpd:2011}AudioChannelConfiguration").attrib["value"]
|
||||||
if chan == "6":
|
if chan == "6":
|
||||||
@ -176,7 +182,15 @@ def adaptionset(attributes, elements, url, baseurl=None):
|
|||||||
files.append(filename)
|
files.append(filename)
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
streams[bitrate] = {"segments": segments, "files": files, "codecs": codec, "channels": channels, "lang": lang, "mimetype": mimetype}
|
streams[bitrate] = {
|
||||||
|
"segments": segments,
|
||||||
|
"files": files,
|
||||||
|
"codecs": codec,
|
||||||
|
"channels": channels,
|
||||||
|
"lang": lang,
|
||||||
|
"mimetype": mimetype,
|
||||||
|
"resolution": resolution,
|
||||||
|
}
|
||||||
|
|
||||||
return streams
|
return streams
|
||||||
|
|
||||||
@ -250,6 +264,7 @@ def _dashparse(config, text, url, cookies, **kwargs):
|
|||||||
segments=videofiles[i]["segments"],
|
segments=videofiles[i]["segments"],
|
||||||
codec=videofiles[i]["codecs"],
|
codec=videofiles[i]["codecs"],
|
||||||
channels=audiofiles[list(audiofiles.keys())[0]]["channels"],
|
channels=audiofiles[list(audiofiles.keys())[0]]["channels"],
|
||||||
|
resolution=videofiles[i]["resolution"],
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
for i in subtitles.keys():
|
for i in subtitles.keys():
|
||||||
|
@ -61,6 +61,7 @@ def hlsparse(config, res, url, **kwargs):
|
|||||||
audio_url = None
|
audio_url = None
|
||||||
vcodec = None
|
vcodec = None
|
||||||
chans = None
|
chans = None
|
||||||
|
resolution = ""
|
||||||
if i["TAG"] == "EXT-X-MEDIA":
|
if i["TAG"] == "EXT-X-MEDIA":
|
||||||
if "AUTOSELECT" in i and (i["AUTOSELECT"].upper() == "YES"):
|
if "AUTOSELECT" in i and (i["AUTOSELECT"].upper() == "YES"):
|
||||||
if i["TYPE"] and i["TYPE"] != "SUBTITLES":
|
if i["TYPE"] and i["TYPE"] != "SUBTITLES":
|
||||||
@ -88,6 +89,8 @@ def hlsparse(config, res, url, **kwargs):
|
|||||||
bit_rate = float(i["AVERAGE-BANDWIDTH"]) / 1000
|
bit_rate = float(i["AVERAGE-BANDWIDTH"]) / 1000
|
||||||
else:
|
else:
|
||||||
bit_rate = float(i["BANDWIDTH"]) / 1000
|
bit_rate = float(i["BANDWIDTH"]) / 1000
|
||||||
|
if "RESOLUTION" in i:
|
||||||
|
resolution = i["RESOLUTION"]
|
||||||
if "CODECS" in i:
|
if "CODECS" in i:
|
||||||
if i["CODECS"][:3] == "hvc":
|
if i["CODECS"][:3] == "hvc":
|
||||||
vcodec = "hevc"
|
vcodec = "hevc"
|
||||||
@ -114,6 +117,7 @@ def hlsparse(config, res, url, **kwargs):
|
|||||||
segments=bool(segments),
|
segments=bool(segments),
|
||||||
channels=chans,
|
channels=chans,
|
||||||
codec=codec,
|
codec=codec,
|
||||||
|
resolution=resolution,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,15 +15,15 @@ def sort_quality(data):
|
|||||||
data = sorted(data, key=lambda x: (x.bitrate, x.name), reverse=True)
|
data = sorted(data, key=lambda x: (x.bitrate, x.name), reverse=True)
|
||||||
datas = []
|
datas = []
|
||||||
for i in data:
|
for i in data:
|
||||||
datas.append([i.bitrate, i.name, i.format])
|
datas.append([i.bitrate, i.name, i.format, i.resolution])
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
|
|
||||||
def list_quality(videos):
|
def list_quality(videos):
|
||||||
data = sort_quality(videos)
|
data = sort_quality(videos)
|
||||||
logging.info("Quality\tMethod")
|
logging.info("Quality\tMethod\tCodec\tResolution")
|
||||||
for i in data:
|
for i in data:
|
||||||
logging.info("%s\t%s\t%s", i[0], i[1].upper(), i[2].upper())
|
logging.info("%s\t%s\t%s\t%s", i[0], i[1].upper(), i[2].upper(), i[3])
|
||||||
|
|
||||||
|
|
||||||
def protocol_prio(streams, priolist):
|
def protocol_prio(streams, priolist):
|
||||||
|
Loading…
Reference in New Issue
Block a user