private void DownloadAllVideos(List <string> Ids) { var downloadQueue = new List <DownloadParameters>(); try { foreach (var vid in Videos) { lock (_commandLockObject) { if (!string.IsNullOrWhiteSpace(vid.Id)) { TwitchVideo video = Videos.Where(v => v.Id == vid.Id).FirstOrDefault(); if (video != null) { VodAuthInfo vodAuthInfo = _twitchService.RetrieveVodAuthInfo(video.Id); if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly) { _dialogService.ShowMessageBox("This video is sub-only! Twitch removed the ability for 3rd party software to download such videos, sorry :(", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone(); string folder = currentPrefs.DownloadSubfoldersForFav && _preferencesService.IsChannelInFavourites(video.Channel) ? Path.Combine(currentPrefs.DownloadFolder, video.Channel) : currentPrefs.DownloadFolder; string filename = _filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, video); filename = _filenameService.EnsureExtension(filename, currentPrefs.DownloadDisableConversion); DownloadParameters downloadParams = new DownloadParameters(video, vodAuthInfo, video.Qualities.First(), folder, filename, currentPrefs.DownloadDisableConversion); downloadQueue.Add(downloadParams); //_navigationService.ShowDownload(downloadParams); } } } } DownloadAll(downloadQueue); } catch (Exception ex) { _dialogService.ShowAndLogException(ex); } }
private void DownloadVideo(string id) { try { lock (this.commandLockObject) { if (!string.IsNullOrWhiteSpace(id)) { TwitchVideo video = this.Videos.Where(v => v.Id == id).FirstOrDefault(); if (video != null) { VodAuthInfo vodAuthInfo = this.twitchService.RetrieveVodAuthInfo(video.IdTrimmed); if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly) { if (!this.twitchService.IsAuthorized) { this.dialogService.ShowMessageBox("This video is sub-only! Please authorize your Twitch account by clicking the Twitch button in the menu.", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { this.dialogService.ShowMessageBox("This video is sub-only but you are not subscribed to '" + video.Channel + "'!", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } return; } Preferences currentPrefs = this.preferencesService.CurrentPreferences.Clone(); TwitchVideoQuality resolution = video.Resolutions.Where(r => r.QualityFormatted == currentPrefs.DownloadVideoQuality).FirstOrDefault(); if (resolution == null) { resolution = video.Resolutions.First(); } string filename = this.filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, video); DownloadParameters downloadParams = new DownloadParameters(video, resolution, vodAuthInfo, currentPrefs.DownloadFolder, filename); this.navigationService.ShowDownload(downloadParams); } } } } catch (Exception ex) { this.dialogService.ShowAndLogException(ex); } }
private void DownloadVideo(string id) { try { lock (_commandLockObject) { if (!string.IsNullOrWhiteSpace(id)) { TwitchVideo video = Videos.Where(v => v.Id == id).FirstOrDefault(); if (video != null) { VodAuthInfo vodAuthInfo = _twitchService.RetrieveVodAuthInfo(video.Id); if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly) { if (!_twitchService.IsAuthorized) { _dialogService.ShowMessageBox("This video is sub-only! Please authorize your Twitch account by clicking the Twitch button in the menu.", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { _dialogService.ShowMessageBox("This video is sub-only but you are not subscribed to '" + video.Channel + "'!", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } return; } Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone(); string folder = currentPrefs.DownloadSubfoldersForFav && _preferencesService.IsChannelInFavourites(video.Channel) ? Path.Combine(currentPrefs.DownloadFolder, video.Channel) : currentPrefs.DownloadFolder; string filename = _filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, video); filename = _filenameService.EnsureExtension(filename, currentPrefs.DownloadDisableConversion); DownloadParameters downloadParams = new DownloadParameters(video, vodAuthInfo, video.Qualities.First(), folder, filename, currentPrefs.DownloadDisableConversion); _navigationService.ShowDownload(downloadParams); } } } } catch (Exception ex) { _dialogService.ShowAndLogException(ex); } }
private void DownloadVideo(string id) { try { lock (_commandLockObject) { if (!string.IsNullOrWhiteSpace(id)) { TwitchVideo video = Videos.Where(v => v.Id == id).FirstOrDefault(); if (video != null) { VodAuthInfo vodAuthInfo = _twitchService.RetrieveVodAuthInfo(video.Id); if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly) { _dialogService.ShowMessageBox("이 비디오는 구독자 전용입니다! '" + video.Channel + "'에 구독해주세요!", "구독냥이!", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone(); string folder = currentPrefs.DownloadSubfoldersForFav && _preferencesService.IsChannelInFavourites(video.Channel) ? Path.Combine(currentPrefs.DownloadFolder, video.Channel) : currentPrefs.DownloadFolder; string filename = _filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, video); filename = _filenameService.EnsureExtension(filename, currentPrefs.DownloadDisableConversion); DownloadParameters downloadParams = new DownloadParameters(video, vodAuthInfo, video.Qualities.First(), folder, filename, currentPrefs.DownloadDisableConversion); _navigationService.ShowDownload(downloadParams); } } } } catch (Exception ex) { _dialogService.ShowAndLogException(ex); } }
private void DownloadAll() { var addedCount = 0; var skippedCount = 0; var overwrittenCount = 0; try { var existingCount = 0; bool overrideAllExisting = false; bool skipAllExisting = false; foreach (var video in _twitchService.Videos) { lock (_commandLockObject) { if (video != null) { VodAuthInfo vodAuthInfo = _twitchService.RetrieveVodAuthInfo(video.Id); if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly) { _dialogService.ShowMessageBox($"This video ({video.Title}) is sub-only! Twitch removed the ability for 3rd party software to download such videos, sorry :(", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); continue; } Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone(); string folder = currentPrefs.DownloadSubfoldersForFav && _preferencesService.IsChannelInFavourites(video.Channel) ? Path.Combine(currentPrefs.DownloadFolder, video.Channel) : currentPrefs.DownloadFolder; string filename = _filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, video); filename = _filenameService.EnsureExtension(filename, currentPrefs.DownloadDisableConversion); DownloadParameters downloadParams = new DownloadParameters(video, vodAuthInfo, video.Qualities.First(), folder, filename, currentPrefs.DownloadDisableConversion); if (File.Exists(downloadParams.FullPath)) { existingCount++; if (existingCount == 2) { var messageMultiple = $"It seems there are multiple files that already exist.{Environment.NewLine}{Environment.NewLine}Press Cancel if you want to get a question for each existing file.{Environment.NewLine}{Environment.NewLine}Press Yes if you want to override all existing files.{Environment.NewLine}{Environment.NewLine}Press No if you want to skip all existing files"; var resultMultiple = _dialogService.ShowMessageBox(messageMultiple, "Download", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); switch (resultMultiple) { case MessageBoxResult.None: case MessageBoxResult.OK: break; case MessageBoxResult.Yes: overrideAllExisting = true; break; case MessageBoxResult.Cancel: break; case MessageBoxResult.No: skipAllExisting = true; break; default: throw new ArgumentOutOfRangeException(); } } if (skipAllExisting) { skippedCount++; continue; } if (overrideAllExisting) { overwrittenCount++; addedCount++; _twitchService.Enqueue(downloadParams); continue; } var message = $"The file: {Environment.NewLine}{downloadParams.FullPath}{Environment.NewLine} already exists. Do you want to overwrite it?{Environment.NewLine}{Environment.NewLine}If you press Cancel the rest of the downloads will not be added."; var result = _dialogService.ShowMessageBox(message, "Download", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); switch (result) { case MessageBoxResult.None: case MessageBoxResult.OK: case MessageBoxResult.Yes: overwrittenCount++; break; case MessageBoxResult.Cancel: this.ShowMultiDownloadNotification(addedCount, skippedCount, overwrittenCount); return; case MessageBoxResult.No: skippedCount++; continue; default: throw new ArgumentOutOfRangeException(); } } addedCount++; _twitchService.Enqueue(downloadParams); } } } } catch (Exception ex) { _dialogService.ShowAndLogException(ex); } this.ShowMultiDownloadNotification(addedCount, skippedCount, overwrittenCount); }
private void DownloadVideo(string id) { try { lock (_commandLockObject) { if (!string.IsNullOrWhiteSpace(id)) { TwitchVideo video = Videos.Where(v => v.Id == id).FirstOrDefault(); if (video != null) { VodAuthInfo vodAuthInfo = _twitchService.RetrieveVodAuthInfo(video.Id); if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly) { if (!_twitchService.IsAuthorized) { _dialogService.ShowMessageBox("This video is sub-only! Please authorize your Twitch account by clicking the Twitch button in the menu.", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { _dialogService.ShowMessageBox("This video is sub-only but you are not subscribed to '" + video.Channel + "'!", "SUB HYPE!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } return; } Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone(); string folder = currentPrefs.DownloadSubfoldersForFav && _preferencesService.IsChannelInFavourites(video.Channel) ? Path.Combine(currentPrefs.DownloadFolder, video.Channel) : currentPrefs.DownloadFolder; string filename = currentPrefs.DownloadFileName; filename = _filenameService.EnsureExtension(filename, currentPrefs.DownloadDisableConversion); if (currentPrefs.DownloadDisableConversion || video.Length.TotalSeconds < currentPrefs.DownloadSplitTime.TotalSeconds + Preferences.MinSplitLength) { currentPrefs.DownloadSplitUse = false; } if (currentPrefs.DownloadSplitUse) {//Keep UNIQNUMBER wildcard in name to split file (only in conversation mode) string tempUniqWildcard = FilenameWildcards.UNIQNUMBER.Insert(FilenameWildcards.UNIQNUMBER.Length - 1, "_TEMP"); filename = filename.Replace(FilenameWildcards.UNIQNUMBER, tempUniqWildcard); filename = _filenameService.SubstituteWildcards(filename, folder, _twitchService.IsFileNameUsed, video); filename = filename.Replace(tempUniqWildcard, FilenameWildcards.UNIQNUMBER); } else { filename = _filenameService.SubstituteWildcards(filename, folder, _twitchService.IsFileNameUsed, video); } TwitchVideoQuality shouldQualityOrNull = TryFindQuality(video.Qualities, currentPrefs.DownloadQuality); DownloadParameters downloadParams = new DownloadParameters(video, vodAuthInfo, shouldQualityOrNull, folder, filename, currentPrefs.DownloadDisableConversion, currentPrefs.DownloadSplitUse, currentPrefs.DownloadSplitTime, currentPrefs.SplitOverlapSeconds); _navigationService.ShowDownload(downloadParams); } } } } catch (Exception ex) { _dialogService.ShowAndLogException(ex); } }