Ejemplo n.º 1
0
        private void UpdateFilenameFromTemplate()
        {
            Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone();
            string      folder       = currentPrefs.DownloadFolder;
            string      fileName     = currentPrefs.DownloadFileName;

            TimeSpan?cropStartTime = _downloadParams.CropStart ? _downloadParams.CropStartTime : TimeSpan.Zero;
            TimeSpan?cropEndTime   = _downloadParams.CropEnd ? _downloadParams.CropEndTime : _downloadParams.Video.Length;

            fileName = _filenameService.EnsureExtension(fileName, currentPrefs.DownloadDisableConversion);
            //if (AutoSplitUseExtended && currentPrefs.DownloadDisableConversion)
            //    AutoSplitUseExtended = false;

            if (AutoSplitUseExtended && fileName.Contains(FilenameWildcards.UNIQNUMBER))
            {
                string tempUniqNumb = FilenameWildcards.UNIQNUMBER.Insert(FilenameWildcards.UNIQNUMBER.Length - 1, "_temp");
                fileName = fileName.Replace(FilenameWildcards.UNIQNUMBER, tempUniqNumb);
                fileName = _filenameService.SubstituteWildcards(fileName, folder, _twitchService.IsFileNameUsed, _downloadParams.Video, _downloadParams.Quality, cropStartTime, cropEndTime);
                fileName = fileName.Replace(tempUniqNumb, FilenameWildcards.UNIQNUMBER);
            }
            else
            {
                fileName = _filenameService.SubstituteWildcards(fileName, folder, _twitchService.IsFileNameUsed, _downloadParams.Video, _downloadParams.Quality, cropStartTime, cropEndTime);
            }

            _downloadParams.Filename = fileName;
        }
Ejemplo n.º 2
0
        private void DownloadVideo(string id)
        {
            try
            {
                lock (_commandLockObject)
                {
                    if (!string.IsNullOrWhiteSpace(id))
                    {
                        TwitchVideo video = Videos.Where(v => v.Id == id).FirstOrDefault();

                        if (video != null)
                        {
                            TwitchVideoAuthInfo vodAuthInfo = _apiService.GetVodAuthInfo(video.Id);

                            if (!vodAuthInfo.Privileged && vodAuthInfo.SubOnly)
                            {
                                if (_isAuthenticatedSubOnly)
                                {
                                    _dialogService.ShowMessageBox("This video is sub-only but you are not subscribed to the channel!", "Download", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                }
                                else
                                {
                                    _dialogService.ShowMessageBox("This video is sub-only! You need to enable sub-only video download support first!", "Download", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                }

                                return;
                            }

                            Dictionary <TwitchVideoQuality, string> playlistInfo = _apiService.GetPlaylistInfo(id, vodAuthInfo);
                            List <TwitchVideoQuality> qualities = playlistInfo.Keys.OrderBy(q => q).ToList();

                            Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone();

                            TwitchVideoQuality selectedQuality = GetSelectedQuality(qualities, currentPrefs.DownloadDefaultQuality);

                            string folder = currentPrefs.DownloadSubfoldersForFav && _preferencesService.IsChannelInFavourites(video.Channel)
                                ? Path.Combine(currentPrefs.DownloadFolder, video.Channel)
                                : currentPrefs.DownloadFolder;

                            string filename = _filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, video, selectedQuality);
                            filename = _filenameService.EnsureExtension(filename, currentPrefs.DownloadDisableConversion);

                            DownloadParameters downloadParams = new DownloadParameters(video, qualities, selectedQuality, folder, filename, currentPrefs.DownloadDisableConversion);

                            if (video.StartTime.HasValue)
                            {
                                downloadParams.CropStartTime = video.StartTime.Value;
                            }

                            _navigationService.ShowDownload(downloadParams);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _dialogService.ShowAndLogException(ex);
            }
        }
Ejemplo n.º 3
0
        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("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);

                            _navigationService.ShowDownload(downloadParams);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _dialogService.ShowAndLogException(ex);
            }
        }
Ejemplo n.º 4
0
        private void UpdateFilenameFromTemplate()
        {
            Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone();

            TimeSpan?cropStartTime = _downloadParams.CropStart ? _downloadParams.CropStartTime : TimeSpan.Zero;
            TimeSpan?cropEndTime   = _downloadParams.CropEnd ? _downloadParams.CropEndTime : _downloadParams.Video.Length;

            string fileName = _filenameService.SubstituteWildcards(currentPrefs.DownloadFileName, _downloadParams.Video, _downloadParams.SelectedQuality, cropStartTime, cropEndTime);

            fileName = _filenameService.EnsureExtension(fileName, currentPrefs.DownloadDisableConversion);

            _downloadParams.Filename = fileName;
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
            }
        }