Improve the check main or high module

This commit is contained in:
Jared-02 2021-11-07 21:31:27 +08:00
parent a6debd0c8d
commit 8291497843

View File

@ -332,7 +332,7 @@ class get_manifest:
else f"{size_in_bytes/1073741824:0.2f} GiB" else f"{size_in_bytes/1073741824:0.2f} GiB"
) )
vid_url = downloadable["urls"][0]["url"] vid_url = downloadable["urls"][0]["url"]
L3 = 'L3' if 'SEGMENT_MAP_2KEY' in str(downloadable['tags']) else '' # L3 = 'L3' if 'SEGMENT_MAP_2KEY' in str(downloadable['tags']) else ''
VideoList.append( VideoList.append(
{ {
@ -346,7 +346,7 @@ class get_manifest:
"Url": vid_url, "Url": vid_url,
"Bitrate": str(downloadable["bitrate"]), "Bitrate": str(downloadable["bitrate"]),
"Profile": downloadable["content_profile"], "Profile": downloadable["content_profile"],
"L3": L3 # "L3": L3
} }
) )
@ -408,41 +408,46 @@ class get_manifest:
if getHigh: if getHigh:
HighVideoList = self.HighVideoMSL() HighVideoList = self.HighVideoMSL()
# 变量赋值
if not HighVideoList == []: if not HighVideoList == []:
# 判断 main 或 high要求 main_max = dict(VideoList[-1])
# main 和 high 的 vmaf 不同时选择 vmaf 更高者 high_max = dict(HighVideoList[-1])
# main 和 high 的 vmaf 相同时选择 bitrate 更高者 else:
if dict(VideoList[-1])["vmaf"]: self.logger.info("Error: Getting Manifest")
if int(dict(VideoList[-1])["vmaf"]) >= int(dict(HighVideoList[-1])["vmaf"]) and int(dict(VideoList[-1])["Bitrate"]) >= int(dict(HighVideoList[-1])["Bitrate"]): exit(-1)
check_high_or_main = "MAIN" # 判断 main 或 high要求
else: check_high_or_main = "HIGH" # main 和 high 的 vmaf 不同时选择 vmaf 更高者
# vmaf = None 时,通过码率判断 # main 和 high 的 vmaf 相同时选择 bitrate 更高者
elif dict(VideoList[-1])["Bitrate"]: if main_max["vmaf"]:
if int(dict(VideoList[-1])["Bitrate"]) >= int(dict(HighVideoList[-1])["Bitrate"]): if int(main_max["vmaf"]) >= int(high_max["vmaf"]) and int(main_max["Bitrate"]) >= int(high_max["Bitrate"]):
check_high_or_main = "MAIN" check_high_or_main = "MAIN"
else: check_high_or_main = "HIGH" else:
else: self.logger.info("There was something wrong with getting manifest!") check_high_or_main = "HIGH"
# vmaf = None 时,通过码率判断
elif main_max["Bitrate"]:
if int(main_max["Bitrate"]) >= int(high_max["Bitrate"]):
check_high_or_main = "MAIN"
else:
check_high_or_main = "HIGH"
else:
self.logger.info("Error: Getting Manifest")
exit(-1)
checkerinfo = "\nNetflix Profile Checker v1.1\n2021-10-25 Jared_mod\n\nMain Profile Rate: {}kbps | VMAF: {} | {}\nHigh Profile Rate: {}kbps | VMAF: {} | {}\n\nResult: {} is Better!\n" checkerinfo = "\nNetflix Profile Checker v1.1\n2021-11-07 Jared_mod\n\nMain Profile Rate: {}kbps | VMAF: {} | {}\nHigh Profile Rate: {}kbps | VMAF: {} | {}\nResult: {} is Better!\n".format(
checkerinfo = checkerinfo.format( str(main_max["Bitrate"]),
str(dict(VideoList[-1])["Bitrate"]), str(main_max["vmaf"]),
str(dict(VideoList[-1])["vmaf"]), str(main_max["Profile"]),
str(dict(VideoList[-1])["Profile"]), str(high_max["Bitrate"]),
str(dict(HighVideoList[-1])["Bitrate"]), str(high_max["vmaf"]),
str(dict(HighVideoList[-1])["vmaf"]), str(high_max["Profile"]),
str(dict(HighVideoList[-1])["Profile"]), check_high_or_main,
check_high_or_main,
) )
self.logger.debug("HighVideoList: {}".format(HighVideoList)) self.logger.debug("HighVideoList: {}".format(HighVideoList))
if check_high_or_main == "MAIN": if check_high_or_main == "HIGH":
# 合并 main 和 high 解析列表 VideoList = HighVideoList
VideoList += HighVideoList
elif check_high_or_main == "HIGH":
VideoList = HighVideoList
VideoList = sorted(VideoList, key=lambda k: int(k["Bitrate"])) VideoList = sorted(VideoList, key=lambda k: int(k["Bitrate"]))
return VideoList, checkerinfo return VideoList, checkerinfo
def ParseAudioSubs(self, resp): def ParseAudioSubs(self, resp):