Skip to content

Commit

Permalink
consolidate interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Aug 7, 2017
1 parent cc679f3 commit 52aeb3c
Show file tree
Hide file tree
Showing 62 changed files with 462 additions and 472 deletions.
16 changes: 8 additions & 8 deletions Emby.Drawing/ImageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public async Task<Tuple<string, string, DateTime>> ProcessImage(ImageProcessingO
}

var originalImage = options.Image;
IHasImages item = options.Item;
IHasMetadata item = options.Item;

if (!originalImage.IsLocalFile)
{
Expand Down Expand Up @@ -606,7 +606,7 @@ private string ImageSizeFile
/// <param name="image">The image.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public string GetImageCacheTag(IHasImages item, ItemImageInfo image)
public string GetImageCacheTag(IHasMetadata item, ItemImageInfo image)
{
if (item == null)
{
Expand All @@ -631,7 +631,7 @@ public string GetImageCacheTag(IHasImages item, ItemImageInfo image)
/// <param name="imageEnhancers">The image enhancers.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public string GetImageCacheTag(IHasImages item, ItemImageInfo image, List<IImageEnhancer> imageEnhancers)
public string GetImageCacheTag(IHasMetadata item, ItemImageInfo image, List<IImageEnhancer> imageEnhancers)
{
if (item == null)
{
Expand Down Expand Up @@ -672,7 +672,7 @@ public string GetImageCacheTag(IHasImages item, ItemImageInfo image, List<IImage
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{System.String}.</returns>
public async Task<string> GetEnhancedImage(IHasImages item, ImageType imageType, int imageIndex)
public async Task<string> GetEnhancedImage(IHasMetadata item, ImageType imageType, int imageIndex)
{
var enhancers = GetSupportedEnhancers(item, imageType).ToList();

Expand All @@ -684,7 +684,7 @@ public async Task<string> GetEnhancedImage(IHasImages item, ImageType imageType,
}

private async Task<Tuple<string, DateTime>> GetEnhancedImage(ItemImageInfo image,
IHasImages item,
IHasMetadata item,
int imageIndex,
List<IImageEnhancer> enhancers)
{
Expand Down Expand Up @@ -729,7 +729,7 @@ private async Task<Tuple<string, DateTime>> GetEnhancedImage(ItemImageInfo image
/// item
/// </exception>
private async Task<string> GetEnhancedImageInternal(string originalImagePath,
IHasImages item,
IHasMetadata item,
ImageType imageType,
int imageIndex,
IEnumerable<IImageEnhancer> supportedEnhancers,
Expand Down Expand Up @@ -783,7 +783,7 @@ private async Task<string> GetEnhancedImageInternal(string originalImagePath,
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{EnhancedImage}.</returns>
private async Task ExecuteImageEnhancers(IEnumerable<IImageEnhancer> imageEnhancers, string inputPath, string outputPath, IHasImages item, ImageType imageType, int imageIndex)
private async Task ExecuteImageEnhancers(IEnumerable<IImageEnhancer> imageEnhancers, string inputPath, string outputPath, IHasMetadata item, ImageType imageType, int imageIndex)
{
// Run the enhancers sequentially in order of priority
foreach (var enhancer in imageEnhancers)
Expand Down Expand Up @@ -868,7 +868,7 @@ public void CreateImageCollage(ImageCollageOptions options)
_logger.Info("Completed creation of image collage and saved to {0}", options.OutputPath);
}

public IEnumerable<IImageEnhancer> GetSupportedEnhancers(IHasImages item, ImageType imageType)
public IEnumerable<IImageEnhancer> GetSupportedEnhancers(IHasMetadata item, ImageType imageType)
{
return ImageEnhancers.Where(i =>
{
Expand Down
8 changes: 4 additions & 4 deletions Emby.Server.Implementations/Channels/ChannelImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public ChannelImageProvider(IChannelManager channelManager)
_channelManager = channelManager;
}

public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
public IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return GetChannel(item).GetSupportedChannelImages();
}

public Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
public Task<DynamicImageResponse> GetImage(IHasMetadata item, ImageType type, CancellationToken cancellationToken)
{
var channel = GetChannel(item);

Expand All @@ -35,12 +35,12 @@ public string Name
get { return "Channel Image Provider"; }
}

public bool Supports(IHasImages item)
public bool Supports(IHasMetadata item)
{
return item is Channel;
}

private IChannel GetChannel(IHasImages item)
private IChannel GetChannel(IHasMetadata item)
{
var channel = (Channel)item;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CollectionImageProvider(IFileSystem fileSystem, IProviderManager provider
{
}

protected override bool Supports(IHasImages item)
protected override bool Supports(IHasMetadata item)
{
// Right now this is the only way to prevent this image from getting created ahead of internet image providers
if (!item.IsLocked)
Expand All @@ -32,7 +32,7 @@ protected override bool Supports(IHasImages item)
return base.Supports(item);
}

protected override List<BaseItem> GetItemsWithImages(IHasImages item)
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var playlist = (BoxSet)item;

Expand Down Expand Up @@ -76,7 +76,7 @@ protected override List<BaseItem> GetItemsWithImages(IHasImages item)
return GetFinalItems(items, 2);
}

protected override string CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
protected override string CreateImage(IHasMetadata item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
{
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
}
Expand Down
4 changes: 2 additions & 2 deletions Emby.Server.Implementations/Dto/DtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,12 +1581,12 @@ private string GetMappedPath(BaseItem item, BaseItem ownerItem)
/// <param name="dto">The dto.</param>
/// <param name="item">The item.</param>
/// <returns>Task.</returns>
public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item)
public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasMetadata item)
{
dto.PrimaryImageAspectRatio = GetPrimaryImageAspectRatio(item);
}

public double? GetPrimaryImageAspectRatio(IHasImages item)
public double? GetPrimaryImageAspectRatio(IHasMetadata item)
{
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);

Expand Down
28 changes: 14 additions & 14 deletions Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ protected BaseDynamicImageProvider(IFileSystem fileSystem, IProviderManager prov
ImageProcessor = imageProcessor;
}

protected virtual bool Supports(IHasImages item)
protected virtual bool Supports(IHasMetadata item)
{
return true;
}

public virtual IEnumerable<ImageType> GetSupportedImages(IHasImages item)
public virtual IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return new List<ImageType>
{
Expand All @@ -51,7 +51,7 @@ public virtual IEnumerable<ImageType> GetSupportedImages(IHasImages item)
};
}

private IEnumerable<ImageType> GetEnabledImages(IHasImages item)
private IEnumerable<ImageType> GetEnabledImages(IHasMetadata item)
{
//var options = ProviderManager.GetMetadataOptions(item);

Expand Down Expand Up @@ -84,7 +84,7 @@ public async Task<ItemUpdateType> FetchAsync(T item, MetadataRefreshOptions opti
return updateType;
}

protected async Task<ItemUpdateType> FetchAsync(IHasImages item, ImageType imageType, MetadataRefreshOptions options, CancellationToken cancellationToken)
protected async Task<ItemUpdateType> FetchAsync(IHasMetadata item, ImageType imageType, MetadataRefreshOptions options, CancellationToken cancellationToken)
{
var image = item.GetImageInfo(imageType, 0);

Expand All @@ -106,7 +106,7 @@ protected async Task<ItemUpdateType> FetchAsync(IHasImages item, ImageType image
return await FetchToFileInternal(item, items, imageType, cancellationToken).ConfigureAwait(false);
}

protected async Task<ItemUpdateType> FetchToFileInternal(IHasImages item,
protected async Task<ItemUpdateType> FetchToFileInternal(IHasMetadata item,
List<BaseItem> itemsWithImages,
ImageType imageType,
CancellationToken cancellationToken)
Expand All @@ -132,14 +132,14 @@ protected async Task<ItemUpdateType> FetchToFileInternal(IHasImages item,
return ItemUpdateType.ImageUpdate;
}

protected abstract List<BaseItem> GetItemsWithImages(IHasImages item);
protected abstract List<BaseItem> GetItemsWithImages(IHasMetadata item);

protected string CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
protected string CreateThumbCollage(IHasMetadata primaryItem, List<BaseItem> items, string outputPath)
{
return CreateCollage(primaryItem, items, outputPath, 640, 360);
}

protected virtual IEnumerable<string> GetStripCollageImagePaths(IHasImages primaryItem, IEnumerable<BaseItem> items)
protected virtual IEnumerable<string> GetStripCollageImagePaths(IHasMetadata primaryItem, IEnumerable<BaseItem> items)
{
return items
.Select(i =>
Expand All @@ -161,22 +161,22 @@ protected virtual IEnumerable<string> GetStripCollageImagePaths(IHasImages prima
.Where(i => !string.IsNullOrWhiteSpace(i));
}

protected string CreatePosterCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
protected string CreatePosterCollage(IHasMetadata primaryItem, List<BaseItem> items, string outputPath)
{
return CreateCollage(primaryItem, items, outputPath, 400, 600);
}

protected string CreateSquareCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
protected string CreateSquareCollage(IHasMetadata primaryItem, List<BaseItem> items, string outputPath)
{
return CreateCollage(primaryItem, items, outputPath, 600, 600);
}

protected string CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
protected string CreateThumbCollage(IHasMetadata primaryItem, List<BaseItem> items, string outputPath, int width, int height)
{
return CreateCollage(primaryItem, items, outputPath, width, height);
}

private string CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
private string CreateCollage(IHasMetadata primaryItem, List<BaseItem> items, string outputPath, int width, int height)
{
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));

Expand Down Expand Up @@ -207,7 +207,7 @@ public string Name
get { return "Dynamic Image Provider"; }
}

protected virtual string CreateImage(IHasImages item,
protected virtual string CreateImage(IHasMetadata item,
List<BaseItem> itemsWithImages,
string outputPathWithoutExtension,
ImageType imageType,
Expand Down Expand Up @@ -267,7 +267,7 @@ public bool HasChanged(IHasMetadata item, IDirectoryService directoryServicee)
return false;
}

protected bool HasChanged(IHasImages item, ImageType type)
protected bool HasChanged(IHasMetadata item, ImageType type)
{
var image = item.GetImageInfo(type, 0);

Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Library/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2856,7 +2856,7 @@ public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
return ItemRepository.UpdatePeople(item.Id, people);
}

public async Task<ItemImageInfo> ConvertImageToLocal(IHasImages item, ItemImageInfo image, int imageIndex)
public async Task<ItemImageInfo> ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex)
{
foreach (var url in image.Path.Split('|'))
{
Expand Down
6 changes: 3 additions & 3 deletions Emby.Server.Implementations/LiveTv/ChannelImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public ChannelImageProvider(ILiveTvManager liveTvManager, IHttpClient httpClient
_appHost = appHost;
}

public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
public IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return new[] { ImageType.Primary };
}

public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
public async Task<DynamicImageResponse> GetImage(IHasMetadata item, ImageType type, CancellationToken cancellationToken)
{
var liveTvItem = (LiveTvChannel)item;

Expand Down Expand Up @@ -67,7 +67,7 @@ public string Name
get { return "Live TV Service Provider"; }
}

public bool Supports(IHasImages item)
public bool Supports(IHasMetadata item)
{
return item is LiveTvChannel;
}
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public LiveTvTunerInfoDto GetTunerInfoDto(string serviceName, LiveTvTunerInfo in
return dto;
}

internal string GetImageTag(IHasImages info)
internal string GetImageTag(IHasMetadata info)
{
try
{
Expand Down
6 changes: 3 additions & 3 deletions Emby.Server.Implementations/LiveTv/RecordingImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public RecordingImageProvider(ILiveTvManager liveTvManager)
_liveTvManager = liveTvManager;
}

public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
public IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return new[] { ImageType.Primary };
}

public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
public async Task<DynamicImageResponse> GetImage(IHasMetadata item, ImageType type, CancellationToken cancellationToken)
{
var liveTvItem = (ILiveTvRecording)item;

Expand Down Expand Up @@ -58,7 +58,7 @@ public string Name
get { return "Live TV Service Provider"; }
}

public bool Supports(IHasImages item)
public bool Supports(IHasMetadata item)
{
return item is ILiveTvRecording;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public EncodingManager(IFileSystem fileSystem,
/// Gets the chapter images data path.
/// </summary>
/// <value>The chapter images data path.</value>
private string GetChapterImagesPath(IHasImages item)
private string GetChapterImagesPath(IHasMetadata item)
{
return Path.Combine(item.GetInternalMetadataPath(), "chapters");
}
Expand Down
4 changes: 2 additions & 2 deletions Emby.Server.Implementations/Photos/PhotoAlbumImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager provider
{
}

protected override List<BaseItem> GetItemsWithImages(IHasImages item)
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var photoAlbum = (PhotoAlbum)item;
var items = GetFinalItems(photoAlbum.Children.ToList());

return items;
}

protected override string CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
protected override string CreateImage(IHasMetadata item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
{
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
}
Expand Down
10 changes: 5 additions & 5 deletions Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerMa
{
}

protected override List<BaseItem> GetItemsWithImages(IHasImages item)
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var playlist = (Playlist)item;

Expand Down Expand Up @@ -81,7 +81,7 @@ public MusicGenreImageProvider(IFileSystem fileSystem, IProviderManager provider
_libraryManager = libraryManager;
}

protected override List<BaseItem> GetItemsWithImages(IHasImages item)
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var items = _libraryManager.GetItemList(new InternalItemsQuery
{
Expand All @@ -98,7 +98,7 @@ protected override List<BaseItem> GetItemsWithImages(IHasImages item)
return GetFinalItems(items);
}

//protected override Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
//protected override Task<string> CreateImage(IHasMetadata item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
//{
// return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
//}
Expand All @@ -113,7 +113,7 @@ public GenreImageProvider(IFileSystem fileSystem, IProviderManager providerManag
_libraryManager = libraryManager;
}

protected override List<BaseItem> GetItemsWithImages(IHasImages item)
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var items = _libraryManager.GetItemList(new InternalItemsQuery
{
Expand All @@ -130,7 +130,7 @@ protected override List<BaseItem> GetItemsWithImages(IHasImages item)
return GetFinalItems(items);
}

//protected override Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
//protected override Task<string> CreateImage(IHasMetadata item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
//{
// return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
//}
Expand Down
Loading

0 comments on commit 52aeb3c

Please sign in to comment.