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(); }
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;; } }