public async void sync() { string[] syncs = Directory.GetFiles(docs, "*.arch"); try { foreach (string sync in syncs) { string dir = Path.GetDirectoryName(File.ReadAllText(sync.Replace(".arch", ".conf")).Split('"')[1]); addOptimiseWatcher(dir); string link = "https://www.youtube.com/playlist?" + Path.GetFileNameWithoutExtension(sync); NYoutubeDL.YoutubeDL dl = new NYoutubeDL.YoutubeDL(); dl.YoutubeDlPath = AppContext.BaseDirectory + "ressources\\youtube-dl.exe"; dl.Options.GeneralOptions.ConfigLocation = sync.Replace(".arch", ".conf"); dl.VideoUrl = link; dl.Options.VideoSelectionOptions.DownloadArchive = sync; dl.Options.GeneralOptions.Update = true; dl.StandardOutputEvent += Dl_StandardOutputEvent; dl.StandardErrorEvent += Dl_StandardErrorEvent; await dl.DownloadAsync(); } } catch (Exception e) { MessageBox.Show(e.Message + e.StackTrace, e.Source); } logs.Clear(); }
/// <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; }
public async void download(string video) { NYoutubeDL.YoutubeDL dl = new NYoutubeDL.YoutubeDL(); dl.YoutubeDlPath = AppContext.BaseDirectory + "ressources\\youtube-dl.exe"; dl.Options.PostProcessingOptions.ExtractAudio = true; dl.Options.PostProcessingOptions.AudioFormat = NYoutubeDL.Helpers.Enums.AudioFormat.mp3; dl.Options.PostProcessingOptions.AddMetadata = true; dl.Options.GeneralOptions.Update = true; dl.StandardOutputEvent += Dl_StandardOutputEvent; dl.StandardErrorEvent += Dl_StandardErrorEvent; await dl.DownloadAsync(video); }
private void btnDownload_Click(object sender, EventArgs e) { if (!Directory.Exists(txtDirectory.Text)) { MessageBox.Show("Directory Invalid!", "reAudioPlayer Downloader", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } syncer.addOptimiseWatcher(txtDirectory.Text); dl = new NYoutubeDL.YoutubeDL(); dl.YoutubeDlPath = AppContext.BaseDirectory + "ressources\\youtube-dl.exe"; dl.Options.FilesystemOptions.Continue = true; dl.Options.GeneralOptions.IgnoreErrors = true; dl.Options.FilesystemOptions.NoOverwrites = true; dl.Options.PostProcessingOptions.AddMetadata = true; dl.Options.PostProcessingOptions.ExtractAudio = true; dl.Options.PostProcessingOptions.AudioFormat = NYoutubeDL.Helpers.Enums.AudioFormat.mp3; dl.Options.FilesystemOptions.Output = txtDirectory.Text + "\\%(title)s.%(ext)s"; dl.VideoUrl = txtLink.Text; dl.Options.GeneralOptions.Update = true; dl.Options.VideoSelectionOptions.NoPlaylist = chkSync.Enabled && (chkSync.Checked || (MessageBox.Show("Do you want to download this as a playlist?", "Apollo Downloader", MessageBoxButtons.YesNo) == DialogResult.No)); if (dl.Options.VideoSelectionOptions.NoPlaylist) { var arg = dl.VideoUrl.Split('?')[1].Split('&')[0]; dl.VideoUrl = dl.VideoUrl.Split('?')[0] + "?" + arg; } Debug.WriteLine(dl.PrepareDownload()); if (chkSync.Checked && chkSync.Enabled) { var args = txtLink.Text.Split('?')[1].Split('&'); string filename = ""; foreach (var arg in args) { if (arg.Contains("list=")) { filename = arg; } } filename = Path.Combine(docs, filename + ".conf"); File.WriteAllText(filename, $"-ciw --add-metadata --embed-thumbnail -x --audio-format mp3 -o \"{dl.Options.FilesystemOptions.Output}\""); if (!File.Exists(filename.Replace(".conf", ".arch"))) { File.Create(filename.Replace(".conf", ".arch")); } syncer.sync(); } else { dl.DownloadAsync(); dl.StandardOutputEvent += Dl_StandardOutputEvent; dl.StandardErrorEvent += Dl_StandardErrorEvent;; } }