From 0871d2ed4db620a8533409e8e8271374215f457e Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Tue, 25 Jul 2023 15:03:04 -0700 Subject: [PATCH] Shared - Fix invalid video resolution options --- .../Models/MediaUrlInfo.cs | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/NickvisionTubeConverter.Shared/Models/MediaUrlInfo.cs b/NickvisionTubeConverter.Shared/Models/MediaUrlInfo.cs index 427b3b4fb..7ed44aebf 100644 --- a/NickvisionTubeConverter.Shared/Models/MediaUrlInfo.cs +++ b/NickvisionTubeConverter.Shared/Models/MediaUrlInfo.cs @@ -127,36 +127,30 @@ private void ParseFormats(PyDict mediaInfo) foreach (var f in mediaInfo["formats"].As()) { var format = f.As(); - if (format.HasKey("vbr")) + if (format.HasKey("vcodec")) { - if (format.HasKey("language") && format["vcodec"].As() == "none") + if (format["vcodec"].As() == "none") { - if (!format["language"].IsNone() && !AudioLanguages.Contains(format["language"].As())) + if (format.HasKey("language")) { - AudioLanguages.Add(format["language"].As()); - } - } - try - { - var resolution = new VideoResolution(format["width"].As(), format["height"].As()); - if (!VideoResolutions.Contains(resolution)) - { - VideoResolutions.Add(resolution); + if (!format["language"].IsNone() && !AudioLanguages.Contains(format["language"].As())) + { + AudioLanguages.Add(format["language"].As()); + } } } - catch { } - } - else if (format.HasKey("resolution")) - { - try + else if (format.HasKey("resolution")) { - var resolution = VideoResolution.Parse(format["resolution"].As()); - if (resolution != null && !VideoResolutions.Contains(resolution)) + try { - VideoResolutions.Add(resolution); + var resolution = VideoResolution.Parse(format["resolution"].As()); + if (resolution != null && !VideoResolutions.Contains(resolution)) + { + VideoResolutions.Add(resolution); + } } + catch { } } - catch { } } } VideoResolutions.Sort((a, b) => b.CompareTo(a));