/// <summary> /// Create a new Youtube-DL source that downloads audio with a given audio format. /// </summary> /// <param name="url"> /// The url. Here is a list of the /// <a href="https://rg3.github.io/youtube-dl/supportedsites.html">supported sites</a>. /// </param> /// <param name="audioFormat"> /// The audio format the file will be stored. Only specific audio formats are supported (i.e. not /// <see cref="Enums.AudioFormat.best" />). /// </param> /// <param name="lazyLoading">If <c>true</c>, the file will be fetched as late as possible.</param> public YoutubeDlSource(string url, Enums.AudioFormat audioFormat, bool lazyLoading = false) : this(url, Enums.VideoFormat.best, audioFormat, lazyLoading) { if (audioFormat == Enums.AudioFormat.best) { throw new InvalidOperationException($"{audioFormat} not support—please specify it specifically."); } YoutubeDl.Options.PostProcessingOptions.ExtractAudio = true; }
/// <summary> /// Create a new Youtube-DL source that downloads videos with a given video and audio format. /// </summary> /// <param name="url"> /// The url. Here is a list of the /// <a href="https://rg3.github.io/youtube-dl/supportedsites.html">supported sites</a>. /// </param> /// <param name="videoFormat">The video format the video will be downloaded.</param> /// <param name="audioFormat">The audio format that is used internally.</param> /// <param name="lazyLoading">If <c>true</c>, the file will be fetched as late as possible.</param> public YoutubeDlSource(string url, Enums.VideoFormat videoFormat = Enums.VideoFormat.best, Enums.AudioFormat audioFormat = Enums.AudioFormat.best, bool lazyLoading = false) : base(url, lazyLoading) { YoutubeDl = new NYoutubeDL.YoutubeDL { VideoUrl = url }; YoutubeDl.Options.VideoFormatOptions.Format = videoFormat; YoutubeDl.Options.PostProcessingOptions.AudioFormat = audioFormat; YoutubeDl.Options.DownloadOptions.ExternalDownloader = Enums.ExternalDownloader.aria2c; }