Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Sep 1, 2024
1 parent 6cc77d0 commit cdfafad
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 46 deletions.
57 changes: 27 additions & 30 deletions YoutubeDownloader.Core/Downloading/VideoDownloadPreference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,33 @@ VideoQualityPreference PreferredVideoQuality

var preferredOption = PreferredVideoQuality switch
{
VideoQualityPreference.Highest
=> orderedOptions.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo1080p
=> orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 1080)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo720p
=> orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 720)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo480p
=> orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 480)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo360p
=> orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 360)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.Lowest
=> orderedOptions.LastOrDefault(o => o.Container == PreferredContainer),

_
=> throw new InvalidOperationException(
$"Unknown video quality preference '{PreferredVideoQuality}'."
)
VideoQualityPreference.Highest => orderedOptions.LastOrDefault(o =>
o.Container == PreferredContainer
),

VideoQualityPreference.UpTo1080p => orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 1080)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo720p => orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 720)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo480p => orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 480)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.UpTo360p => orderedOptions
.Where(o => o.VideoQuality?.MaxHeight <= 360)
.LastOrDefault(o => o.Container == PreferredContainer),

VideoQualityPreference.Lowest => orderedOptions.LastOrDefault(o =>
o.Container == PreferredContainer
),

_ => throw new InvalidOperationException(
$"Unknown video quality preference '{PreferredVideoQuality}'."
),
};

return preferredOption
Expand Down
4 changes: 2 additions & 2 deletions YoutubeDownloader.Core/Downloading/VideoQualityPreference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum VideoQualityPreference
UpTo480p,
UpTo720p,
UpTo1080p,
Highest
Highest,
// ReSharper restore InconsistentNaming
}

Expand All @@ -25,6 +25,6 @@ public static string GetDisplayName(this VideoQualityPreference preference) =>
VideoQualityPreference.UpTo720p => "≤ 720p",
VideoQualityPreference.UpTo1080p => "≤ 1080p",
VideoQualityPreference.Highest => "Highest quality",
_ => throw new ArgumentOutOfRangeException(nameof(preference))
_ => throw new ArgumentOutOfRangeException(nameof(preference)),
};
}
2 changes: 1 addition & 1 deletion YoutubeDownloader.Core/Resolving/QueryResultKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public enum QueryResultKind
Playlist,
Channel,
Search,
Aggregate
Aggregate,
}
6 changes: 3 additions & 3 deletions YoutubeDownloader.Core/Utils/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public static class Http
new ProductInfoHeaderValue(
"YoutubeDownloader",
Assembly.GetExecutingAssembly().GetName().Version?.ToString(3)
)
}
}
),
},
},
};
}
2 changes: 1 addition & 1 deletion YoutubeDownloader.Core/Utils/PathEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static class PathEx
{
private static readonly HashSet<char> InvalidFileNameChars =
[
.. Path.GetInvalidFileNameChars()
.. Path.GetInvalidFileNameChars(),
];

public static string EscapeFileName(string path)
Expand Down
4 changes: 2 additions & 2 deletions YoutubeDownloader/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public App()
{
ThemeVariant.Light => Avalonia.Styling.ThemeVariant.Light,
ThemeVariant.Dark => Avalonia.Styling.ThemeVariant.Dark,
_ => Avalonia.Styling.ThemeVariant.Default
_ => Avalonia.Styling.ThemeVariant.Default,
};

InitializeTheme();
Expand Down Expand Up @@ -97,7 +97,7 @@ private void InitializeTheme()
{
"Light" => PlatformThemeVariant.Light,
"Dark" => PlatformThemeVariant.Dark,
_ => PlatformSettings?.GetColorValues().ThemeVariant ?? PlatformThemeVariant.Light
_ => PlatformSettings?.GetColorValues().ThemeVariant ?? PlatformThemeVariant.Light,
};

this.LocateMaterialTheme<MaterialThemeBase>().CurrentTheme =
Expand Down
4 changes: 2 additions & 2 deletions YoutubeDownloader/Framework/DialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ await DialogHost.Show(
{
FileTypeChoices = fileTypes,
SuggestedFileName = defaultFilePath,
DefaultExtension = Path.GetExtension(defaultFilePath).TrimStart('.')
DefaultExtension = Path.GetExtension(defaultFilePath).TrimStart('.'),
}
);

Expand All @@ -82,7 +82,7 @@ await DialogHost.Show(
new FolderPickerOpenOptions
{
AllowMultiple = false,
SuggestedStartLocation = startLocation
SuggestedStartLocation = startLocation,
}
);

Expand Down
2 changes: 1 addition & 1 deletion YoutubeDownloader/Framework/ThemeVariant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public enum ThemeVariant
{
System,
Light,
Dark
Dark,
}
2 changes: 1 addition & 1 deletion YoutubeDownloader/Framework/ViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class ViewManager
DownloadSingleSetupViewModel => new DownloadSingleSetupView(),
MessageBoxViewModel => new MessageBoxView(),
SettingsViewModel => new SettingsView(),
_ => null
_ => null,
};

public Control? TryBindView(ViewModelBase viewModel)
Expand Down
2 changes: 1 addition & 1 deletion YoutubeDownloader/ViewModels/Components/DownloadStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public enum DownloadStatus
Started,
Completed,
Failed,
Canceled
Canceled,
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ private async Task ConfirmAsync()
[
new FilePickerFileType($"{container.Name} file")
{
Patterns = [$"*.{container.Name}"]
}
Patterns = [$"*.{container.Name}"],
},
],
FileNameTemplate.Apply(settingsService.FileNameTemplate, Video, container)
);
Expand Down

0 comments on commit cdfafad

Please sign in to comment.