public void Refresh()
        {
            IsLoading = true;

            _tvshowtimeApiService.GetWatchlist(0, 0)
            .Subscribe(async(watchlistResponse) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    _watchedOrUnwatchedEpisode = false;
                    _followedOrUnfollowedShow  = false;
                    LastLoadingDate            = DateTime.Now;

                    Episodes.Clear();

                    foreach (var episode in watchlistResponse.Episodes)
                    {
                        Episodes.Add(episode);
                    }

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

                _toastNotificationService.ShowErrorNotification("An error happened. Please retry later.");
            });
        }
Beispiel #2
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Episodes.Clear();

                var episodes = await GetEpisodes();

                foreach (var episode in episodes)
                {
                    Episodes.Add(episode);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #3
0
        private void RefreshEpisodesList()
        {
            Episodes.Clear();

            foreach (string season in SeasonsListBox.SelectedItems)
            {
                var folderName = System.IO.Path.GetFileName(season);

                if (string.IsNullOrEmpty(folderName))
                {
                    WriteOutput($"Could not identify directory.", OutputMessageLevel.Error);
                    return;
                }

                var episodesResult = Directory.EnumerateFiles(season);

                WriteOutput($"Searching {folderName} episodes...", OutputMessageLevel.Normal);

                foreach (var filePath in episodesResult)
                {
                    if (System.IO.Path.HasExtension(filePath))
                    {
                        Episodes.Add(filePath);

                        WriteOutput($"Adding {filePath}...", OutputMessageLevel.Normal, true);
                    }
                }

                WriteOutput($"Refreshed {folderName} {Episodes.Count} episodes.", OutputMessageLevel.Normal, true);
            }
        }
Beispiel #4
0
        private void SeasonsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            Episodes.Clear();

            foreach (string season in SeasonsListBox.SelectedItems)
            {
                var episodesResult = Directory.EnumerateFiles(season);

                foreach (var filePath in episodesResult)
                {
                    Episodes.Add(filePath);
                }
            }

            if (SeasonsListBox.SelectedItems.Count == 0)
            {
                WriteOutput("Selections cleared.", OutputMessageLevel.Warning);
            }
            else if (SeasonsListBox.SelectedItems.Count == 1)
            {
                WriteOutput($"{System.IO.Path.GetFileName(openFolderDialog.FileName)} selected ({Episodes.Count} episodes).", OutputMessageLevel.Informational);
            }
            else
            {
                WriteOutput($"{SeasonsListBox.SelectedItems.Count} seasons selected ({Episodes.Count} total episodes).", OutputMessageLevel.Informational);
            }

            Analytics.TrackEvent("Season Selection", new Dictionary <string, string>
            {
                { "Selected Seasons", SeasonsListBox.SelectedItems.Count.ToString(CultureInfo.InvariantCulture) }
            });
        }
Beispiel #5
0
 public void LoadPodcast(Podcast p)
 {
     Podcast = p;
     Episodes.Clear();
     foreach (var e in p.Episodes)
     {
         Episodes.Add(e);
     }
 }
        /// <summary>
        /// Update all fields of the object with the given information
        /// </summary>
        /// <param name="fields">the fields for the update</param>
        /// <param name="replaceEpisodes">Should the episodes be replaced or kept</param>
        internal void UpdateTvdbFields(TvdbSeriesFields fields, bool replaceEpisodes)
        {
            //Update series details
            Id            = fields.Id;
            Actors        = fields.Actors;
            AirsDayOfWeek = fields.AirsDayOfWeek;
            AirsTime      = fields.AirsTime;
            ContentRating = fields.ContentRating;
            FirstAired    = fields.FirstAired;
            Genre         = fields.Genre;
            ImdbId        = fields.ImdbId;
            Language      = fields.Language;
            Network       = fields.Network;
            NetworkID     = fields.NetworkID;
            Overview      = fields.Overview;
            Rating        = fields.Rating;
            RatingCount   = fields.RatingCount;
            Runtime       = fields.Runtime;
            TvDotComId    = fields.TvDotComId;
            SeriesName    = fields.SeriesName;
            Status        = fields.Status;
            BannerPath    = fields.BannerPath;
            FanartPath    = fields.FanartPath;
            PosterPath    = fields.PosterPath;
            LastUpdated   = fields.LastUpdated;
            Zap2itId      = fields.Zap2itId;

            if (replaceEpisodes)
            {
                if (Episodes != null && fields.EpisodesLoaded)
                {
                    //check for each episode if episode images have been loaded...
                    //if yes -> copy image
                    foreach (TvdbEpisode f in fields.Episodes)
                    {
                        foreach (TvdbEpisode e in Episodes)
                        {
                            if (e.Id == f.Id && e.Banner != null && e.Banner.IsLoaded)
                            {
                                f.Banner = e.Banner;
                                break;
                            }
                        }
                    }
                }
                EpisodesLoaded = fields.EpisodesLoaded;
                if (Episodes == null)
                {
                    Episodes = new UniqueList <TvdbEpisode>();
                }
                else
                {
                    Episodes.Clear();
                }
                Episodes.AddRange(fields.Episodes);
            }
        }
 public override void WireMessages()
 {
     Messenger.Default.Register <NotificationMessage>(this, m =>
     {
         if (m.Notification.Equals(Constants.Messages.ClearEpisodesMsg))
         {
             Episodes.Clear();
         }
     });
 }
Beispiel #8
0
        public void Refresh()
        {
            _currentPage               = 0;
            LastLoadingDate            = DateTime.Now;
            _watchedOrUnwatchedEpisode = false;
            _followedOrUnfollowedShow  = false;

            Episodes.Clear();

            LoadUpcomingEpisodes();
        }
Beispiel #9
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();
        }
        internal void SetEpisodes(List <TvdbEpisode> episodes)
        {
            foreach (KeyValuePair <TvdbLanguage, TvdbSeriesFields> kvp in _seriesTranslations)
            {
                if (kvp.Key.Abbriviation.Equals(Language.Abbriviation))
                {
                    kvp.Value.EpisodesLoaded = true;
                    kvp.Value.Episodes.Clear();
                    kvp.Value.Episodes.AddRange(episodes);
                }
            }

            EpisodesLoaded = true;
            Episodes.Clear();
            Episodes.AddRange(episodes);
        }
Beispiel #11
0
        private void LoadEpisodes(string url)
        {
            var podcastFinder = new iTunesPodcastFinder.PodcastFinder();
            var results       = podcastFinder.GetPodcastEpisodesAsync(url);

            Episodes.Clear();

            foreach (var item in results.Result.Episodes)
            {
                Episodes.Add(
                    new Episode
                {
                    Title       = item.Title,
                    Description = item.Summary,
                    Url         = item.FileUrl.ToString(),
                    Duration    = item.Duration.ToString()
                });
            }
        }
        private void Refresh()
        {
            _tvshowtimeApiService.GetWatchlist(0, 0)
            .Subscribe(async(watchlistResponse) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    Episodes.Clear();

                    foreach (var episode in watchlistResponse.Episodes)
                    {
                        Episodes.Add(episode);
                    }
                });
            },
                       (error) =>
            {
                throw new Exception();
            });
        }
        /// <summary>
        /// Update the info of the current series with the updated one
        /// </summary>
        /// <param name="series">TvdbSeries object</param>
        protected void UpdateSeriesInfo(TvdbSeries series)
        {
            Actors        = series.Actors;
            AirsDayOfWeek = series.AirsDayOfWeek;
            AirsTime      = series.AirsTime;
            BannerPath    = series.BannerPath;
            Banners       = series.Banners;
            ContentRating = series.ContentRating;
            FanartPath    = series.FanartPath;
            FirstAired    = series.FirstAired;
            Genre         = series.Genre;
            Id            = series.Id;
            ImdbId        = series.ImdbId;
            Language      = series.Language;
            LastUpdated   = series.LastUpdated;
            Network       = series.Network;
            Overview      = series.Overview;
            Rating        = series.Rating;
            Runtime       = series.Runtime;
            SeriesName    = series.SeriesName;
            Status        = series.Status;
            TvDotComId    = series.TvDotComId;
            Zap2itId      = series.Zap2itId;

            if (series.EpisodesLoaded)
            {//check if the old series has any images loaded already -> if yes, save them
                if (EpisodesLoaded)
                {
                    foreach (TvdbEpisode oe in Episodes)
                    {
                        foreach (TvdbEpisode ne in series.Episodes)
                        {
                            if (oe.SeasonNumber == ne.SeasonNumber &&
                                oe.EpisodeNumber == ne.EpisodeNumber)
                            {
                                if (oe.Banner != null && oe.Banner.IsLoaded)
                                {
                                    ne.Banner = oe.Banner;
                                }
                            }
                        }
                    }
                }

                Episodes.Clear();
                Episodes.AddRange(series.Episodes);
            }

            if (series.TvdbActorsLoaded)
            {//check if the old series has any images loaded already -> if yes, save them
                if (TvdbActorsLoaded)
                {
                    foreach (TvdbActor oa in TvdbActors)
                    {
                        foreach (TvdbActor na in series.TvdbActors)
                        {
                            if (oa.Id == na.Id)
                            {
                                if (oa.ActorImage != null && oa.ActorImage.IsLoaded)
                                {
                                    na.ActorImage = oa.ActorImage;
                                }
                            }
                        }
                    }
                }
                TvdbActors = series.TvdbActors;
            }

            if (series.BannersLoaded)
            {
                //check if the old series has any images loaded already -> if yes, save them
                if (BannersLoaded)
                {
                    foreach (TvdbBanner ob in Banners)
                    {
                        foreach (TvdbBanner nb in series.Banners)
                        {
                            if (ob.BannerPath.Equals(nb.BannerPath))//I have to check for the banner path since the Update file doesn't include IDs
                            {
                                if (ob.BannerImage != null && ob.IsLoaded)
                                {
                                    nb.BannerImage = ob.BannerImage;
                                }

                                if (ob.GetType() == typeof(TvdbFanartBanner))
                                {
                                    TvdbFanartBanner newFaBanner = (TvdbFanartBanner)nb;
                                    TvdbFanartBanner oldFaBanner = (TvdbFanartBanner)ob;

                                    if (oldFaBanner.ThumbImage != null && oldFaBanner.IsThumbLoaded)
                                    {
                                        newFaBanner.ThumbImage = oldFaBanner.ThumbImage;
                                    }

                                    if (oldFaBanner.ThumbImage != null && oldFaBanner.IsVignetteLoaded)
                                    {
                                        newFaBanner.VignetteImage = oldFaBanner.VignetteImage;
                                    }
                                }
                            }
                        }
                    }
                }
                Banners = series.Banners;
            }
        }
Beispiel #14
0
        public override void WireMessages()
        {
            Messenger.Default.Register <NotificationMessage>(this, m =>
            {
                if (m.Notification.Equals(Constants.Messages.ClearEpisodesMsg))
                {
                    Episodes.Clear();
                }

                if (m.Notification.Equals(Constants.Messages.RefreshResumeMsg))
                {
                    var id    = (string)m.Sender;
                    var ticks = (long)m.Target;
                    if (id == SelectedEpisode.Id)
                    {
                        if (SelectedEpisode.UserData == null)
                        {
                            SelectedEpisode.UserData = new UserItemDataDto();
                        }

                        SelectedEpisode.UserData.PlaybackPositionTicks = ticks;

                        SelectedEpisode.HasPlayed();

                        CanResume = SelectedEpisode.CanResume;
                    }
                }
            });

            Messenger.Default.Register <SyncNotificationMessage>(this, m =>
            {
                if (m.Notification.Equals(Constants.Messages.SyncJobFinishedMsg))
                {
                    switch (m.ItemType.ToLower())
                    {
                    case "episode":
                        if (SelectedEpisode != null && SelectedEpisode.Id == m.ItemId)
                        {
                            SelectedEpisode.IsSynced = true;
                        }

                        if (!Episodes.IsNullOrEmpty())
                        {
                            var episode = Episodes.FirstOrDefault(x => x.Id == m.ItemId);
                            if (episode != null)
                            {
                                episode.IsSynced = true;
                            }
                        }
                        break;

                    case "season":
                        if (SelectedSeason != null)
                        {
                            SelectedSeason.IsSynced = true;
                        }

                        if (!Seasons.IsNullOrEmpty())
                        {
                            var season = Seasons.FirstOrDefault(x => x.Id == m.ItemId);
                            if (season != null)
                            {
                                season.IsSynced = true;
                            }
                        }
                        break;

                    case "series":
                        if (SelectedTvSeries != null)
                        {
                            SelectedTvSeries.IsSynced = true;
                        }
                        break;
                    }
                }
            });
        }