示例#1
0
 private SearchedTvShow ConvertSearchedTvShow(JSONMedia jsonMedia)
 {
     return(new SearchedTvShow
     {
         TheTvDbId = jsonMedia.Id,
         Title = jsonMedia.Name,
         Banner = !string.IsNullOrWhiteSpace(jsonMedia.PosterPath) ? $"https://image.tmdb.org/t/p/w500{jsonMedia.PosterPath}" : null,
         FirstAired = jsonMedia.FirstAirDate,
     });
 }
示例#2
0
        private TvSeason[] ConvertSeasons(JSONMedia jsonMedia)
        {
            var seasons = jsonMedia.Seasons.Select(x =>
                                                   new NormalTvSeason
            {
                SeasonNumber = x.SeasonNumber,
                IsAvailable  = x.Status == MediaStatus.AVAILABLE,
                IsRequested  = ConvertRequestedState(x.Status)
            }).ToArray();

            if (jsonMedia.MediaInfo != null)
            {
                if (jsonMedia.MediaInfo.Requests != null && jsonMedia.MediaInfo.Requests.Any())
                {
                    foreach (var season in seasons)
                    {
                        var request = jsonMedia.MediaInfo.Requests
                                      .Where(x => x.Seasons.Any(s => s.SeasonNumber == season.SeasonNumber))
                                      .Where(x => x.Status == MediaRequestStatus.PENDING || x.Status == MediaRequestStatus.APPROVED)
                                      .FirstOrDefault();

                        if (request != null)
                        {
                            season.IsAvailable = false;
                            season.IsRequested = RequestedState.Full;
                        }
                    }
                }

                if (jsonMedia.MediaInfo != null && jsonMedia.MediaInfo.Seasons.Any())
                {
                    foreach (var season in seasons)
                    {
                        var mediaSeason = jsonMedia.MediaInfo.Seasons.FirstOrDefault(x => x.SeasonNumber == season.SeasonNumber);

                        if (mediaSeason != null && (mediaSeason.Status == MediaStatus.PROCESSING || mediaSeason.Status == MediaStatus.PARTIALLY_AVAILABLE || mediaSeason.Status == MediaStatus.AVAILABLE))
                        {
                            season.IsAvailable = mediaSeason.Status == MediaStatus.AVAILABLE;
                            season.IsRequested = ConvertRequestedState(mediaSeason.Status);
                        }
                    }
                }
            }

            return(seasons.Where(x => x.SeasonNumber > 0).ToArray());
        }
示例#3
0
 private Movie ConvertMovie(JSONMedia jsonMedia)
 {
     return(new Movie
     {
         TheMovieDbId = jsonMedia.Id.ToString(),
         Title = jsonMedia.Title,
         Available = jsonMedia.MediaInfo?.Status == MediaStatus.AVAILABLE,
         Quality = string.Empty,
         Requested = jsonMedia.MediaInfo?.Status == MediaStatus.PENDING ||
                     jsonMedia.MediaInfo?.Status == MediaStatus.PROCESSING ||
                     jsonMedia.MediaInfo?.Status == MediaStatus.PARTIALLY_AVAILABLE ||
                     jsonMedia.MediaInfo?.Status == MediaStatus.AVAILABLE,
         PlexUrl = jsonMedia.MediaInfo?.PlexUrl,
         Overview = jsonMedia.Overview,
         PosterPath = !string.IsNullOrWhiteSpace(jsonMedia.PosterPath) ? $"https://image.tmdb.org/t/p/w500{jsonMedia.PosterPath}" : null,
         ReleaseDate = jsonMedia.ReleaseDate,
     });
 }
示例#4
0
 private TvShow ConvertTvShow(JSONMedia jsonMedia)
 {
     return(new TvShow
     {
         TheTvDbId = jsonMedia.Id,
         Title = jsonMedia.Name,
         Banner = !string.IsNullOrWhiteSpace(jsonMedia.PosterPath) ? $"https://image.tmdb.org/t/p/w500{jsonMedia.PosterPath}" : null,
         FirstAired = jsonMedia.FirstAirDate,
         IsRequested = jsonMedia.MediaInfo?.Status == MediaStatus.PENDING ||
                       jsonMedia.MediaInfo?.Status == MediaStatus.PROCESSING ||
                       jsonMedia.MediaInfo?.Status == MediaStatus.PARTIALLY_AVAILABLE ||
                       jsonMedia.MediaInfo?.Status == MediaStatus.AVAILABLE,
         Quality = string.Empty,
         PlexUrl = jsonMedia.MediaInfo?.PlexUrl,
         Overview = jsonMedia.Overview,
         HasEnded = !jsonMedia.InProduction,
         Network = jsonMedia.Networks.First().Name,
         Status = jsonMedia.Status,
         Seasons = ConvertSeasons(jsonMedia)
     });
 }