// Copyright 2017 Brian Allred // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. namespace NYoutubeDL.Options { #region Using using Helpers; #endregion /// /// Object containing Video Format parameters /// public class VideoFormat : OptionSection { [Option] internal readonly BoolOption allFormats = new BoolOption("--all-formats"); [Option] internal readonly EnumOption format = new EnumOption("-f"); [Option] internal readonly StringOption formatAdvanced = new StringOption("-f"); [Option] internal readonly BoolOption listFormats = new BoolOption("-F"); [Option] internal readonly EnumOption mergeOutputFormat = new EnumOption("--merge-output-format"); [Option] internal readonly BoolOption preferFreeFormats = new BoolOption("--prefer-free-formats"); [Option] internal readonly BoolOption youtubeSkipDashManifest = new BoolOption("--youtube-skip-dash-manifest"); /// /// --all-formats /// public bool AllFormats { get => this.allFormats.Value ?? false; set => this.SetField(ref this.allFormats.Value, value); } /// /// This is a simple version of -f. For more advanced format usage, use the FormatAdvanced /// property. /// NOTE: FormatAdvanced takes precedence over Format. /// public Enums.VideoFormat Format { get => this.format.Value == null ? Enums.VideoFormat.undefined : (Enums.VideoFormat) this.format.Value; set => this.SetField(ref this.format.Value, (int) value); } /// /// This accepts a string matching -f according to the youtube-dl documentation below. /// NOTE: FormatAdvanced takes precedence over Format. /// /// public string FormatAdvanced { get => this.formatAdvanced.Value; set => this.SetField(ref this.formatAdvanced.Value, value); } /// /// -F /// public bool ListFormats { get => this.listFormats.Value ?? false; set => this.SetField(ref this.listFormats.Value, value); } /// /// --merge-output-format /// public Enums.VideoFormat MergeOutputFormat { get => this.mergeOutputFormat.Value == null ? Enums.VideoFormat.undefined : (Enums.VideoFormat) this.mergeOutputFormat.Value; set => this.SetField(ref this.mergeOutputFormat.Value, (int) value); } /// /// --prefer-free-formats /// public bool PreferFreeFormats { get => this.preferFreeFormats.Value ?? false; set => this.SetField(ref this.preferFreeFormats.Value, value); } /// /// --youtube-skip-dash-manifest /// public bool YoutubeSkipDashManifest { get => this.youtubeSkipDashManifest.Value ?? false; set => this.SetField(ref this.youtubeSkipDashManifest.Value, value); } public override string ToCliParameters() { // Set format to undefined if formatAdvanced has a valid value, // then return the parameters. if (!string.IsNullOrWhiteSpace(this.formatAdvanced.Value)) { this.format.Value = (int) Enums.VideoFormat.undefined; } return base.ToCliParameters(); } } }