Skip to content

Commit

Permalink
Merge pull request #481 from NickvisionApps/fix-resolutions
Browse files Browse the repository at this point in the history
Fix invalid video resolution options
  • Loading branch information
nlogozzo authored Jul 26, 2023
2 parents a3af8bc + 0871d2e commit 25bc87f
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions NickvisionTubeConverter.Shared/Models/MediaUrlInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,36 +127,30 @@ private void ParseFormats(PyDict mediaInfo)
foreach (var f in mediaInfo["formats"].As<PyList>())
{
var format = f.As<PyDict>();
if (format.HasKey("vbr"))
if (format.HasKey("vcodec"))
{
if (format.HasKey("language") && format["vcodec"].As<string>() == "none")
if (format["vcodec"].As<string>() == "none")
{
if (!format["language"].IsNone() && !AudioLanguages.Contains(format["language"].As<string>()))
if (format.HasKey("language"))
{
AudioLanguages.Add(format["language"].As<string>());
}
}
try
{
var resolution = new VideoResolution(format["width"].As<int>(), format["height"].As<int>());
if (!VideoResolutions.Contains(resolution))
{
VideoResolutions.Add(resolution);
if (!format["language"].IsNone() && !AudioLanguages.Contains(format["language"].As<string>()))
{
AudioLanguages.Add(format["language"].As<string>());
}
}
}
catch { }
}
else if (format.HasKey("resolution"))
{
try
else if (format.HasKey("resolution"))
{
var resolution = VideoResolution.Parse(format["resolution"].As<string>());
if (resolution != null && !VideoResolutions.Contains(resolution))
try
{
VideoResolutions.Add(resolution);
var resolution = VideoResolution.Parse(format["resolution"].As<string>());
if (resolution != null && !VideoResolutions.Contains(resolution))
{
VideoResolutions.Add(resolution);
}
}
catch { }
}
catch { }
}
}
VideoResolutions.Sort((a, b) => b.CompareTo(a));
Expand Down

0 comments on commit 25bc87f

Please sign in to comment.