async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Seasons.Clear();
                var seasons = await GetSeasons();

                foreach (var season in seasons)
                {
                    Seasons.Add(season);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #2
0
 public override void Clear()
 {
     Commands.Clear();
     Profiles.Clear();
     Seasons.Clear();
     Misc.Clear();
 }
Beispiel #3
0
        public void ClearFiles()
        {
            foreach (var Season in Seasons)
            {
                foreach (var Episode in Season.Episodes)
                {
                    foreach (var Sub in Episode.Subs)
                    {
                        Sub.Control.Dispose();
                    }
                    Episode.Control.Dispose();
                }
                Season.Control.Dispose();
            }

            foreach (var Movie in Movies)
            {
                foreach (var Sub in Movie.Subs)
                {
                    Sub.Control.Dispose();
                }
                Movie.Control.Dispose();
            }

            Seasons.Clear();
            Movies.Clear();
            JunkFiles.Clear();
        }
Beispiel #4
0
        public async Task LoadAsync(bool refresh = false)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (IsMultiSeason)
            {
                FeaturedVideo = await _animeService.GetLatestEpisodeAsync();

                var seasons = await _seasonService.ListAsync(new DataServices.ListRequest {
                    Skip = refresh ? 0 : Seasons.Count
                });

                Seasons.Clear();
                Seasons.AddRange(seasons);

                foreach (var season in Seasons)
                {
                    var episodes = await _animeService.ListEpisodeBySeasonAsync(new ListEpisodeBySeasonRequest { SeasonId = season.Id, Take = 5 });

                    season.Episodes.AddRange(episodes);
                }
            }
            else
            {
                List <Anime> animes = null;
                if (DataSource.ToLower() == "tvspecials")
                {
                    FeaturedVideo = await _animeService.GetLatestTvSpecialAsync();

                    animes = await _animeService.ListTvSpecialsAsync(new DataServices.ListRequest {
                        Skip = refresh ? 0 : Animes.Count
                    });
                }
                else if (DataSource.ToLower() == "movies")
                {
                    FeaturedVideo = await _animeService.GetLatestMovieAsync();

                    animes = await _animeService.ListMoviesAsync(new DataServices.ListRequest {
                        Skip = refresh ? 0 : Animes.Count
                    });
                }

                if (animes != null)
                {
                    Animes.Clear();
                    Animes.AddRange(animes);
                }
            }

            IsBusy = false;
        }
        public async Task LoadAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            _appDataStorage.SaveAnime(Anime);

            List <Anime> animes = null;

            switch (AnimeType.ToLower())
            {
            case "stories":
                animes = await _animeService.ListStoriesAsync(new DataServices.ListRequest {
                    Skip = Animes.Count
                });

                break;

            case "tvspecials":
                animes = await _animeService.ListTvSpecialsAsync(new DataServices.ListRequest {
                    Skip = Animes.Count
                });

                break;

            case "movies":
                animes = await _animeService.ListMoviesAsync(new DataServices.ListRequest {
                    Skip = Animes.Count
                });

                break;
            }

            Animes.Clear();
            Animes.AddRange(animes);

            var seasons = await _seasonService.ListAsync(new DataServices.ListRequest {
                Skip = Seasons.Count
            });

            Seasons.Clear();
            Seasons.AddRange(seasons);

            IsBusy = false;
        }
Beispiel #6
0
        private void Reset()
        {
            EpisodeName_Renaming_TextBox.Text    = string.Empty;
            EpisodeName_Renumbering_TextBox.Text = string.Empty;

            OriginalTextBox_Renaming.Text    = string.Empty;
            OriginalTextBox_Renumbering.Text = string.Empty;

            ReplacementTextBox.Text  = string.Empty;
            SeasonNumberTextBox.Text = string.Empty;

            Seasons.Clear();
            Episodes.Clear();
            StatusMessages.Clear();
        }
Beispiel #7
0
        private void RefreshByShowId(long showId, int selectedSeason = 1)
        {
            IsLoading = true;

            _tvshowtimeApiService.GetShow(showId, string.Empty, true)
            .Subscribe(async(showResponse) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    LastLoadingDate = DateTime.Now;

                    Seasons.Clear();

                    Show = showResponse.Show;
                    RaisePropertyChanged(nameof(Show));

                    foreach (var episode in Show.Episodes)
                    {
                        var seasonGroup = Seasons.FirstOrDefault(s => s.SeasonNumber == episode.Season);
                        if (seasonGroup == null)
                        {
                            seasonGroup = new ShowSeasonGroup {
                                SeasonNumber = episode.Season
                            };
                            Seasons.Add(seasonGroup);
                        }

                        seasonGroup.Episodes.Add(episode);
                    }

                    RaisePropertyChanged(nameof(MinSeasonNumber));
                    RaisePropertyChanged(nameof(MaxSeasonNumber));

                    SelectedSeason = Seasons.FirstOrDefault(s => s.SeasonNumber == selectedSeason);

                    IsLoading = false;
                });
            },
                       async(error) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    IsLoading = false;
                });

                _toastNotificationService.ShowErrorNotification("An error happened. Please retry later.");
            });
        }
Beispiel #8
0
        public void ApplyFilter(bool reset, bool notifications = true)
        {
            if (AllDownloads == null || !AllDownloads.Any())
            {
                Fetch();
                return;
            }

            _mutexFilter.WaitOne();

            FavSeasonData currentFavSeason  = null;
            SeasonData    currentSeasonData = null;
            int           seasonNr          = -1;

            ObservableCollection <FavSeasonData> newSeasons    = new ObservableCollection <FavSeasonData>();
            ObservableCollection <DownloadData>  newNonSeasons = new ObservableCollection <DownloadData>();

            bool setNewEpisodes = false;
            bool setNewUpdates  = false;

            if (_isNewShow)
            {
                notifications = false;
            }
            reset = reset || _isNewShow;
            if (!reset)
            {
                newSeasons    = Seasons;
                newNonSeasons = NonSeasons;
            }

            UploadData currentUpload       = null;
            bool       ignoreCurrentUpload = false;

            foreach (var download in AllDownloads)
            {
                //upload stuff --------------------------------------------------------------------
                if (currentUpload == null || currentUpload != download.Upload)
                {
                    currentUpload       = download.Upload;
                    ignoreCurrentUpload = true;
                    do
                    {
                        UploadLanguage language = currentUpload.Language;
                        if (!Settings.Instance.MarkSubbedAsGerman && currentUpload.Subbed) //dont mark german-subbed as german
                        {
                            language &= ~UploadLanguage.German;                            //remove german
                        }

                        if ((language & FilterLanguage) == 0) //Filter: Language
                        {
                            break;
                        }

                        if (!String.IsNullOrWhiteSpace(FilterRuntime) &&     //Filter: Runtime
                            !(new Regex(FilterRuntime).Match(currentUpload.Runtime).Success))
                        {
                            break;
                        }


                        if (!String.IsNullOrWhiteSpace(FilterSize) &&     //Filter: Size
                            !(new Regex(FilterSize).Match(currentUpload.Size).Success))
                        {
                            break;
                        }

                        if (!String.IsNullOrWhiteSpace(FilterUploader) &&     //Filter: Uploader
                            !(new Regex(FilterUploader).Match(currentUpload.Uploader).Success))
                        {
                            break;
                        }

                        if (!String.IsNullOrWhiteSpace(FilterFormat) &&     //Filter: Format
                            !(new Regex(FilterFormat).Match(currentUpload.Format).Success))
                        {
                            break;
                        }

                        ignoreCurrentUpload = false;
                    } while (false);
                }

                if (ignoreCurrentUpload) //Filter: All upload stuff
                {
                    continue;
                }

                //episode stuff ---------------------

                if (!String.IsNullOrWhiteSpace(FilterName) && //Filter: Name
                    !(new Regex(FilterName).Match(download.Title).Success))
                {
                    continue;
                }

                if (!String.IsNullOrWhiteSpace(FilterHoster))
                {
                    var r   = new Regex(FilterHoster);
                    var dls = download.Links.Keys.Where(hoster => r.Match(hoster).Success).ToList(); //all keys that match the regex
                    if (!dls.Any())                                                                  //Filter: Hoster
                    {
                        continue;
                    }
                    for (int i = download.Links.Keys.Count - 1; i >= 0; i--)
                    {
                        string key = download.Links.Keys.ElementAt(i);
                        if (!dls.Contains(key))
                        {
                            download.Links.Remove(key);
                        }
                    }
                }

                //------------------------------------------

                //Season stuff ------------------------------------------------------------------------------------
                if (currentSeasonData == null || currentSeasonData != download.Upload.Season)
                {
                    currentSeasonData = download.Upload.Season;
                    seasonNr          = -1;
                    Match m2 = new Regex("(?:season|staffel)\\s*(\\d+)", RegexOptions.IgnoreCase).Match(currentSeasonData.Title);
                    if (m2.Success)
                    {
                        int.TryParse(m2.Groups[1].Value, out seasonNr);
                    }
                }

                if (seasonNr == -1)
                {
                    if (newNonSeasons.All(d => d.Title != download.Title))
                    {
                        newNonSeasons.Add(download);
                    }
                    continue;
                }

                if (currentFavSeason == null || currentFavSeason.Number != seasonNr)
                {
                    currentFavSeason = newSeasons.FirstOrDefault(favSeasonData => favSeasonData.Number == seasonNr) ??
                                       new FavSeasonData()
                    {
                        Number = seasonNr, Show = this
                    };

                    if (!newSeasons.Contains(currentFavSeason)) //season not yet added?
                    {
                        newSeasons.Add(currentFavSeason);
                    }
                }

                int episodeNr = -1;

                MatchCollection mts     = new Regex("S0{0,4}" + seasonNr + "\\.?E(\\d+)", RegexOptions.IgnoreCase).Matches(download.Title);
                MatchCollection mts_ep  = new Regex("[^A-Z]E(\\d+)", RegexOptions.IgnoreCase).Matches(download.Title);
                MatchCollection mts_alt = new Regex("\\bE(\\d+)\\b", RegexOptions.IgnoreCase).Matches(download.Title);
                if (mts.Count == 1 && mts_ep.Count == 1)
                //if there is exactly one match for "S<xx>E<yy>" and there is no second "E<zz>" (e.g. S01E01-E12)
                {
                    int.TryParse(mts[0].Groups[1].Value, out episodeNr);
                }
                else if (mts_alt.Count == 1) //if there's exactly one match for the alternative regex
                {
                    int.TryParse(mts_alt[0].Groups[1].Value, out episodeNr);
                }


                if (episodeNr == -1)
                {
                    if (currentFavSeason.NonEpisodes.All(d => d.Title != download.Title))
                    {
                        currentFavSeason.NonEpisodes.Add(download);
                    }
                    continue;
                }

                FavEpisodeData currentFavEpisode = currentFavSeason.Episodes.FirstOrDefault(episodeData => episodeData.Number == episodeNr);

                if (currentFavEpisode == null)
                {
                    currentFavEpisode        = new FavEpisodeData();
                    currentFavEpisode.Season = currentFavSeason;
                    currentFavEpisode.Number = episodeNr;
                    bool existed = false;

                    var oldSeason = Seasons.FirstOrDefault(s => s.Number == currentFavSeason.Number);
                    if (oldSeason != null)
                    {
                        var oldEpisode = oldSeason.Episodes.FirstOrDefault(e => e.Number == currentFavEpisode.Number);
                        if (oldEpisode != null) //we can copy old data to current episode
                        {
                            currentFavEpisode.Watched            = oldEpisode.Watched;
                            currentFavEpisode.Downloaded         = oldEpisode.Downloaded;
                            currentFavEpisode.EpisodeInformation = oldEpisode.EpisodeInformation;
                            existed = true;
                        }
                    }

                    if (notifications && !existed)
                    {
                        currentFavEpisode.NewEpisode = true;
                        setNewEpisodes = true;
                    }

                    currentFavSeason.Episodes.Add(currentFavEpisode);

                    currentFavEpisode.Downloads.Add(download);

                    if (ProviderData != null && (currentFavEpisode.EpisodeInformation == null || reset))
                    {
                        StaticInstance.ThreadPool.QueueWorkItem(() =>
                        {
                            //currentFavEpisode.ReviewInfoReview = SjInfo.ParseSjDeSite(InfoUrl, currentFavEpisode.Season.Number, currentFavEpisode.Number);
                            currentFavEpisode.EpisodeInformation = ProviderManager.GetProvider().GetEpisodeInformation(ProviderData, currentFavEpisode.Season.Number, currentFavEpisode.Number);
                        });
                    }
                }
                else
                {
                    FavEpisodeData oldEpisode = null;
                    var            oldSeason  = Seasons.FirstOrDefault(s => s.Number == currentFavSeason.Number);
                    if (oldSeason != null)
                    {
                        oldEpisode = oldSeason.Episodes.FirstOrDefault(e => e.Number == currentFavEpisode.Number);
                    }

                    if (currentFavEpisode.Downloads.All(d => d.Title != download.Title))
                    {
                        if (notifications && (oldEpisode == null || (!oldEpisode.NewEpisode && oldEpisode.Downloads.All(d => d.Title != download.Title))))
                        {
                            currentFavEpisode.NewUpdate = true;
                            setNewUpdates = true;
                        }
                        currentFavEpisode.Downloads.Add(download);
                    }
                }
            }

            if (reset)
            {
                Seasons.Clear();
                foreach (var season in newSeasons)
                {
                    Seasons.Add(season);
                }
                NonSeasons.Clear();
                foreach (var nonSeason in newNonSeasons)
                {
                    NonSeasons.Add(nonSeason);
                }
            }

            if (setNewEpisodes)
            {
                Notified    = false;
                NewEpisodes = true;
            }
            if (setNewUpdates)
            {
                NewUpdates = true;
            }

            RecalcNumbers();
            _mutexFilter.ReleaseMutex();
        }
Beispiel #9
0
        private void SelectFolderButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                WriteOutput($"Opening folder picker...", OutputMessageLevel.Normal);

                busyIndicator.IsBusy          = true;
                busyIndicator.BusyContent     = "opening folder...";
                busyIndicator.IsIndeterminate = true;

                if (!string.IsNullOrEmpty(Properties.Settings.Default.LastFolder))
                {
                    // Need to bump up one level from the last folder location
                    var topDirectoryInfo = Directory.GetParent(Properties.Settings.Default.LastFolder);

                    openFolderDialog.InitialDirectory = topDirectoryInfo.FullName;

                    WriteOutput($"Starting at saved folder.", OutputMessageLevel.Normal);
                }
                else
                {
                    WriteOutput($"No saved folder, starting at root.", OutputMessageLevel.Warning);
                }

                openFolderDialog.ShowDialog();

                if (openFolderDialog.DialogResult != true)
                {
                    WriteOutput($"Canceled folder selection.", OutputMessageLevel.Normal);
                    return;
                }
                else
                {
                    Properties.Settings.Default.LastFolder = openFolderDialog.FileName;
                    Properties.Settings.Default.Save();
                }

                Reset();

                busyIndicator.BusyContent = $"searching for seasons...";

                var seasonsResult = Directory.EnumerateDirectories(openFolderDialog.FileName).ToList();

                Seasons.Clear();

                foreach (var season in seasonsResult)
                {
                    Seasons.Add(season);

                    busyIndicator.BusyContent = $"added {season}";
                }

                if (Seasons.Count == 0)
                {
                    WriteOutput("No seasons detected, make sure there are subfolders with season number.", OutputMessageLevel.Warning);
                }
                else if (Seasons.Count == 1)
                {
                    WriteOutput($"Opened '{System.IO.Path.GetFileName(openFolderDialog.FileName)}' ({Seasons.Count} season).", OutputMessageLevel.Success);
                }
                else
                {
                    WriteOutput($"Opened '{System.IO.Path.GetFileName(openFolderDialog.FileName)}' ({Seasons.Count} seasons).", OutputMessageLevel.Success);
                }

                Analytics.TrackEvent("Video Folder Opened", new Dictionary <string, string>
                {
                    { "Seasons", Seasons.Count.ToString(CultureInfo.InvariantCulture) }
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                WriteOutput(ex.Message, OutputMessageLevel.Error);

                Crashes.TrackError(ex, new Dictionary <string, string>
                {
                    { "Folder Open", "TV Show" }
                });
            }
            finally
            {
                busyIndicator.BusyContent     = "";
                busyIndicator.IsBusy          = false;
                busyIndicator.IsIndeterminate = false;
            }
        }
Beispiel #10
0
 private void FillSeasons()
 {
     Seasons.Clear();
     Seasons.Add(Season.Summer);
     Seasons.Add(Season.Winter);
 }