private void btnGetVideoUrlFile_Click(object sender, RoutedEventArgs e) { // Local variables string playListId = ""; IList <string> urlList = new List <string>(); string playlistTitle = ""; // check if a playlist is selected if (comboboxPlaylistIDs.SelectedValue == null) { _log.Error("No playlist available to download or no playlist selected (impossible)"); api.TelegramBotSendError("No playlist available to download or no playlist selected (impossible)"); return; } //Get Playlist title playlistTitle = comboboxPlaylistIDs.SelectedValue.ToString().Split(',')[0]; playlistTitle = playlistTitle.Replace("[", ""); // Set variables playListId = comboboxPlaylistIDs.SelectedValue.ToString().Split(',')[1]; playListId = playListId.Replace("]", ""); // Get all video IDs from the YouTube playlist dynamic allVideoIds; try { allVideoIds = GetIDs.GetVideosInPlayListAsync(playListId).Result; } catch (Exception ex) { _log.Fatal("Error retrieving all video IDs = " + ex.Message); return; } // Check if IDs where found if (allVideoIds.Count == 0) { _log.Error("Video IDs where retrieved but empty -> probably empty playlist"); api.TelegramBotSendError("Video IDs where retrieved but empty -> probably empty playlist"); return; } // Loop over every videofile foreach (var videoObject in allVideoIds) { urlList.Add("http://www.youtube.com/watch?v=" + (string)videoObject.Id); } TextWriter tw = new StreamWriter("UrlList.txt"); foreach (String s in urlList) { tw.WriteLine(s); } tw.Close(); Process.Start("UrlList.txt"); }
private void UpdateSelectedPlaylist(object sender, RoutedEventArgs e) { try { total.Start(); // Get selected playlist ID this.Dispatcher.Invoke(() => { selectedPlaylistID = comboboxPlaylistIDs.SelectedValue.ToString(); }); // Default checks if (!DefaultChecks()) { MessageBox.Show("Default checks failed. See logging for more details."); return; } // Fill variables (playlistTitle, playlistId, pathVideoFiles, pathMp3Files, pathVideoFolder, tmpDirectory, pathMp3Folder) // and create missing directories if they don't exist yet SetVariablesAndDirectories(); api.TelegramBotSendInfo("Processing: " + playlistTitle); // Get all video IDs from the YouTube playlist allVideoIds = GetIDs.GetVideosInPlayListAsync(playListId).Result; // Check if IDs where found if (allVideoIds.Count == 0) { _log.Error("Video IDs where retrieved but empty -> probably empty playlist"); api.TelegramBotSendError("Video IDs where retrieved but empty -> probably empty playlist"); MessageBox.Show("Empty playlist?"); return; } _log.Debug("Retrieval is starting..."); api.ProcessVideosToMp3(allVideoIds, pathMp3Files, playlistTitle); // Reset variables just to be sure InitVariables(); } catch (Exception ex) { MessageBox.Show("Fatal error, send file 'proper.log' to me!"); api.TelegramBotSendError("Fatal error, send file 'proper.log' to me!"); _log.Error("Fatal error: " + ex.Message); } }