Ejemplo n.º 1
0
        private async Task AssignTrailers(IHasTrailers item, BaseItem[] channelTrailers)
        {
            if (item is Game)
            {
                return;
            }

            var imdbId = item.GetProviderId(MetadataProviders.Imdb);
            var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);

            var trailers = channelTrailers.Where(i =>
            {
                if (!string.IsNullOrWhiteSpace(imdbId) &&
                    string.Equals(imdbId, i.GetProviderId(MetadataProviders.Imdb), StringComparison.OrdinalIgnoreCase))
                {
                    return true;
                }
                if (!string.IsNullOrWhiteSpace(tmdbId) &&
                    string.Equals(tmdbId, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase))
                {
                    return true;
                }
                return false;
            });

            var trailerIds = trailers.Select(i => i.Id)
                .ToList();

            if (!trailerIds.SequenceEqual(item.RemoteTrailerIds))
            {
                item.RemoteTrailerIds = trailerIds;

                var baseItem = (BaseItem)item;
                await baseItem.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None)
                        .ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
		private ReportStatResult GetResultProductionYears(ReportStatResult result, BaseItem[] items, int topItem = 5)
		{
			this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderYears"), topItem,
					items.Where(x => x.ProductionYear != null && x.ProductionYear > 0)
						.GroupBy(x => x.ProductionYear)
						.OrderByDescending(x => x.Count())
						.Take(topItem)
						.Select(x => new ReportStatItem
						{
							Name = x.Key.ToString(),
							Value = x.Count().ToString()
						})
			);

			return result;
		}
Ejemplo n.º 3
0
		private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
		{
			this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderParentalRatings"), topItem,
					   items.Where(x => x.OfficialRating != null)
						   .GroupBy(x => x.OfficialRating)
						   .OrderByDescending(x => x.Count())
						   .Take(topItem)
						   .Select(x => new ReportStatItem
						   {
							   Name = x.Key.ToString(),
							   Value = x.Count().ToString()
						   })
			   );

			return result;
		}