Merge pull request #2701 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-06-11 17:59:25 -04:00 committed by GitHub
commit e9d2fb13e0
3 changed files with 40 additions and 54 deletions

View File

@ -172,13 +172,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var allImages = (images[imageIndex].data ?? new List<ScheduleDirect.ImageData>()).ToList(); var allImages = (images[imageIndex].data ?? new List<ScheduleDirect.ImageData>()).ToList();
var imagesWithText = allImages.Where(i => string.Equals(i.text, "yes", StringComparison.OrdinalIgnoreCase)).ToList(); var imagesWithText = allImages.Where(i => string.Equals(i.text, "yes", StringComparison.OrdinalIgnoreCase)).ToList();
var imagesWithoutText = allImages.Where(i => string.Equals(i.text, "no", StringComparison.OrdinalIgnoreCase)).ToList();
double desiredAspect = IsMovie(programEntry) ? 0.666666667 : wideAspect; double desiredAspect = IsMovie(programEntry) ? 0.666666667 : wideAspect;
programEntry.primaryImage = GetProgramImage(ApiUrl, imagesWithText, null, true, desiredAspect) ?? programEntry.primaryImage = GetProgramImage(ApiUrl, imagesWithText, true, desiredAspect) ??
GetProgramImage(ApiUrl, allImages, null, true, desiredAspect); GetProgramImage(ApiUrl, allImages, true, desiredAspect);
programEntry.thumbImage = GetProgramImage(ApiUrl, imagesWithText, null, true, wideAspect); programEntry.thumbImage = GetProgramImage(ApiUrl, imagesWithText, true, wideAspect);
// Don't supply the same image twice // Don't supply the same image twice
if (string.Equals(programEntry.primaryImage, programEntry.thumbImage, StringComparison.Ordinal)) if (string.Equals(programEntry.primaryImage, programEntry.thumbImage, StringComparison.Ordinal))
@ -186,6 +187,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
programEntry.thumbImage = null; programEntry.thumbImage = null;
} }
programEntry.backdropImage = GetProgramImage(ApiUrl, imagesWithoutText, true, wideAspect);
//programEntry.bannerImage = GetProgramImage(ApiUrl, data, "Banner", false) ?? //programEntry.bannerImage = GetProgramImage(ApiUrl, data, "Banner", false) ??
// GetProgramImage(ApiUrl, data, "Banner-L1", false) ?? // GetProgramImage(ApiUrl, data, "Banner-L1", false) ??
// GetProgramImage(ApiUrl, data, "Banner-LO", false) ?? // GetProgramImage(ApiUrl, data, "Banner-LO", false) ??
@ -396,62 +399,19 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return date; return date;
} }
private string GetProgramImage(string apiUrl, List<ScheduleDirect.ImageData> images, string category, bool returnDefaultImage, double desiredAspect) private string GetProgramImage(string apiUrl, List<ScheduleDirect.ImageData> images, bool returnDefaultImage, double desiredAspect)
{ {
string url = null; string url = null;
var matches = images; var matches = images;
if (!string.IsNullOrWhiteSpace(category))
{
matches = images
.Where(i => string.Equals(i.category, category, StringComparison.OrdinalIgnoreCase))
.ToList();
if (matches.Count == 0)
{
if (!returnDefaultImage)
{
return null;
}
matches = images;
}
}
matches = matches matches = matches
.OrderBy(i => Math.Abs(desiredAspect - GetApsectRatio(i))) .OrderBy(i => Math.Abs(desiredAspect - GetApsectRatio(i)))
.ThenByDescending(GetSizeOrder) .ThenByDescending(GetSizeOrder)
.ToList(); .ToList();
//var match = matches.FirstOrDefault(i =>
//{
// if (!string.IsNullOrWhiteSpace(i.width))
// {
// int value;
// if (int.TryParse(i.width, out value))
// {
// return value <= desiredWidth;
// }
// }
// return false;
//});
var match = matches.FirstOrDefault(); var match = matches.FirstOrDefault();
if (match == null)
{
// Get the second lowest quality image, when possible
if (matches.Count > 1)
{
match = matches[matches.Count - 2];
}
else
{
match = matches.FirstOrDefault();
}
}
if (match == null) if (match == null)
{ {
return null; return null;
@ -1243,6 +1203,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public bool hasImageArtwork { get; set; } public bool hasImageArtwork { get; set; }
public string primaryImage { get; set; } public string primaryImage { get; set; }
public string thumbImage { get; set; } public string thumbImage { get; set; }
public string backdropImage { get; set; }
public string bannerImage { get; set; } public string bannerImage { get; set; }
public string imageID { get; set; } public string imageID { get; set; }
public string md5 { get; set; } public string md5 { get; set; }

View File

@ -679,8 +679,7 @@ namespace Emby.Server.Implementations.LiveTv
item.SetImage(new ItemImageInfo item.SetImage(new ItemImageInfo
{ {
Path = info.ImagePath, Path = info.ImagePath,
Type = ImageType.Primary, Type = ImageType.Primary
IsPlaceholder = true
}, 0); }, 0);
} }
else if (!string.IsNullOrWhiteSpace(info.ImageUrl)) else if (!string.IsNullOrWhiteSpace(info.ImageUrl))
@ -688,8 +687,7 @@ namespace Emby.Server.Implementations.LiveTv
item.SetImage(new ItemImageInfo item.SetImage(new ItemImageInfo
{ {
Path = info.ImageUrl, Path = info.ImageUrl,
Type = ImageType.Primary, Type = ImageType.Primary
IsPlaceholder = true
}, 0); }, 0);
} }
} }
@ -700,9 +698,34 @@ namespace Emby.Server.Implementations.LiveTv
{ {
item.SetImage(new ItemImageInfo item.SetImage(new ItemImageInfo
{ {
Path = info.ImageUrl, Path = info.ThumbImageUrl,
Type = ImageType.Thumb, Type = ImageType.Thumb
IsPlaceholder = true
}, 0);
}
}
if (!item.HasImage(ImageType.Logo))
{
if (!string.IsNullOrWhiteSpace(info.LogoImageUrl))
{
item.SetImage(new ItemImageInfo
{
Path = info.LogoImageUrl,
Type = ImageType.Logo
}, 0);
}
}
if (!item.HasImage(ImageType.Backdrop))
{
if (!string.IsNullOrWhiteSpace(info.BackdropImageUrl))
{
item.SetImage(new ItemImageInfo
{
Path = info.BackdropImageUrl,
Type = ImageType.Backdrop
}, 0); }, 0);
} }

View File

@ -111,6 +111,8 @@ namespace MediaBrowser.Controller.LiveTv
public string LogoImageUrl { get; set; } public string LogoImageUrl { get; set; }
public string BackdropImageUrl { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance has image. /// Gets or sets a value indicating whether this instance has image.
/// </summary> /// </summary>