Beispiel #1
0
        public async Task GetEpisodeDetails()
        {
            if (NavigationService.IsNetworkAvailable)
            {
                var index = SelectedEpisode.IndexNumber;
                if (SelectedEpisode != null && Episodes.IsNullOrEmpty())
                {
                    SetProgressBar(AppResources.SysTrayGettingEpisodeDetails);

                    try
                    {
                        if (string.IsNullOrEmpty(SelectedEpisode.SeriesId))
                        {
                            var episode = await ApiClient.GetItemAsync(SelectedEpisode.Id, AuthenticationService.Current.LoggedInUserId);
                            if (episode == null)
                            {
                                await _messageBox.ShowAsync(AppResources.ErrorEpisodeDetails);
                                NavigationService.GoBack();
                                return;
                            }

                            SelectedEpisode = episode;
                        }

                        var query = new EpisodeQuery
                        {
                            UserId = AuthenticationService.Current.LoggedInUserId,
                            SeasonId = SelectedEpisode.SeasonId,
                            SeriesId = SelectedEpisode.SeriesId,
                            Fields = new[]
                            {
                                ItemFields.ParentId,
                                ItemFields.Overview,
                                ItemFields.MediaSources, 
                            }
                        };

                        //Log.Info("Getting episodes for Season [{0}] ({1}) of TV Show [{2}] ({3})", SelectedSeason.Name, SelectedSeason.Id, SelectedTvSeries.Name, SelectedTvSeries.Id);

                        var episodes = await ApiClient.GetEpisodesAsync(query);
                        Episodes = episodes.Items.OrderBy(x => x.IndexNumber).ToList();
                    }
                    catch (HttpException ex)
                    {
                        Utils.HandleHttpException("GetEpisodeDetails()", ex, NavigationService, Log);
                    }

                    SetProgressBar();
                }
                
                if (SelectedEpisode != null)
                {
                    SelectedEpisode = Episodes.FirstOrDefault(x => x.IndexNumber == index);
                    CanResume = SelectedEpisode != null && SelectedEpisode.CanResume;
                }
            }
        }
Beispiel #2
0
        private async Task<bool> GetEpisodes()
        {
            try
            {
                var query = new EpisodeQuery
                {
                    UserId = AuthenticationService.Current.LoggedInUserId,
                    SeasonId = SelectedSeason.Id,
                    SeriesId = SelectedSeason.SeriesId,
                    Fields = new[]
                    {
                        ItemFields.ParentId,
                        ItemFields.Overview,
                        ItemFields.MediaSources, 
                    },
                    IsMissing = App.SpecificSettings.ShowMissingEpisodes,
                    IsVirtualUnaired = App.SpecificSettings.ShowUnairedEpisodes
                };

                Log.Info("Getting episodes for Season [{0}] ({1}) of TV Show [{2}] ({3})", SelectedSeason.Name, SelectedSeason.Id, SelectedTvSeries.Name, SelectedTvSeries.Id);

                var episodes = await ApiClient.GetEpisodesAsync(query);
                Episodes = episodes.Items.ToList();
                return true;
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException("GetEpisodes()", ex, NavigationService, Log);

                App.ShowMessage(AppResources.ErrorEpisodes);
                return false;
            }
        }