本文整理汇总了C#中IHasImages类的典型用法代码示例。如果您正苦于以下问题:C# IHasImages类的具体用法?C# IHasImages怎么用?C# IHasImages使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IHasImages类属于命名空间,在下文中一共展示了IHasImages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
if (TvdbSeriesProvider.IsValidSeries(item.ProviderIds))
{
var language = item.GetPreferredMetadataLanguage();
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(item.ProviderIds, language, cancellationToken).ConfigureAwait(false);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
var seriesOffset = TvdbSeriesProvider.GetSeriesOffset(item.ProviderIds);
if (seriesOffset != null && seriesOffset.Value != 0)
return TvdbSeasonImageProvider.GetImages(path, language, seriesOffset.Value + 1, cancellationToken);
return GetImages(path, language, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
catch (DirectoryNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return new RemoteImageInfo[] { };
}
示例2: Supports
public bool Supports(IHasImages item)
{
// Save the http requests since we know it's not currently supported
// TODO: Check again periodically
if (item is Person)
{
return false;
}
// Save the http requests since we know it's not currently supported
if (item is Series || item is Season || item is Episode)
{
return false;
}
var channelItem = item as IChannelMediaItem;
if (channelItem != null)
{
if (channelItem.ContentType == ChannelMediaContentType.Movie)
{
return true;
}
if (channelItem.ContentType == ChannelMediaContentType.MovieExtra)
{
if (channelItem.ExtraType == ExtraType.Trailer)
{
return true;
}
}
}
return item is Movie;
}
示例3: GetAllImages
public Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken)
{
var season = (Season)item;
var seriesId = season.Series != null ? season.Series.GetProviderId(MetadataProviders.Tvdb) : null;
if (!string.IsNullOrEmpty(seriesId) && season.IndexNumber.HasValue)
{
// Process images
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesId);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
var result = GetImages(path, season.IndexNumber.Value, cancellationToken);
return Task.FromResult(result);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return Task.FromResult<IEnumerable<RemoteImageInfo>>(new RemoteImageInfo[] { });
}
示例4: GetAllImages
public Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
RemoteImageInfo info = null;
var album = item as MusicAlbum;
if (album != null)
{
info = GetInfo(album.LastFmImageUrl, album.LastFmImageSize);
}
var musicArtist = item as MusicArtist;
if (musicArtist != null)
{
info = GetInfo(musicArtist.LastFmImageUrl, musicArtist.LastFmImageSize);
}
if (info != null)
{
list.Add(info);
}
// The only info we have is size
return Task.FromResult<IEnumerable<RemoteImageInfo>>(list.OrderByDescending(i => i.Width ?? 0));
}
示例5: GetSupportedImages
public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
{
return new List<ImageType>
{
ImageType.Primary
};
}
示例6: GetImages
public List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService)
{
var parentPath = Path.GetDirectoryName(item.Path);
var parentPathFiles = directoryService.GetFileSystemEntries(parentPath)
.ToList();
var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path);
var files = GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles);
if (files.Count > 0)
{
return files;
}
var metadataPath = Path.Combine(parentPath, "metadata");
if (parentPathFiles.Any(i => string.Equals(i.FullName, metadataPath, StringComparison.OrdinalIgnoreCase)))
{
return GetFilesFromParentFolder(nameWithoutExtension, directoryService.GetFiles(metadataPath));
}
return new List<LocalImageInfo>();
}
示例7: GetImage
public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
{
var channelItem = (IChannelItem)item;
var imageResponse = new DynamicImageResponse();
if (!string.IsNullOrEmpty(channelItem.OriginalImageUrl))
{
var options = new HttpRequestOptions
{
CancellationToken = cancellationToken,
Url = channelItem.OriginalImageUrl
};
var response = await _httpClient.GetResponse(options).ConfigureAwait(false);
if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
{
imageResponse.HasImage = true;
imageResponse.Stream = response.Content;
imageResponse.SetFormatFromMimeType(response.ContentType);
}
else
{
_logger.Error("Provider did not return an image content type.");
}
}
return imageResponse;
}
示例8: Supports
public bool Supports(IHasImages item)
{
//var channelItem = item as IChannelMediaItem;
//if (channelItem != null)
//{
// if (channelItem.ContentType == ChannelMediaContentType.Movie)
// {
// return true;
// }
// if (channelItem.ContentType == ChannelMediaContentType.MovieExtra)
// {
// if (channelItem.ExtraType == ExtraType.Trailer)
// {
// return true;
// }
// }
//}
// Supports images for tv movies
//var tvProgram = item as LiveTvProgram;
//if (tvProgram != null && tvProgram.IsMovie)
//{
// return true;
//}
return item is Movie || item is BoxSet || item is MusicVideo;
}
示例9: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var season = (Season)item;
var series = season.Series;
if (series != null && season.IndexNumber.HasValue && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
{
var seriesProviderIds = series.ProviderIds;
var seasonNumber = season.IndexNumber.Value;
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesProviderIds, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(seriesDataPath))
{
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
return GetImages(path, item.GetPreferredMetadataLanguage(), seasonNumber, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
catch (DirectoryNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
}
return new RemoteImageInfo[] { };
}
示例10: Supports
public bool Supports(IHasImages item)
{
if (item is Photo)
{
return false;
}
if (!item.IsSaveLocalMetadataEnabled())
{
return true;
}
// Extracted images will be saved in here
if (item is Audio)
{
return true;
}
if (item.SupportsLocalMetadata && !item.AlwaysScanInternalMetadataPath)
{
return false;
}
return true;
}
示例11: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var season = (Season)item;
var series = season.Series;
var identity = season.Identities.OfType<SeasonIdentity>().FirstOrDefault(id => id.Type == MetadataProviders.Tvdb.ToString());
var seriesId = identity != null ? identity.SeriesId : null;
if (!string.IsNullOrEmpty(seriesId) && season.IndexNumber.HasValue)
{
await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesId, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
// Process images
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesId);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
int seasonNumber = AdjustForSeriesOffset(series, identity.SeasonIndex);
return GetImages(path, item.GetPreferredMetadataLanguage(), seasonNumber, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return new RemoteImageInfo[] { };
}
示例12: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var album = (MusicAlbum)item;
var list = new List<RemoteImageInfo>();
var artistMusicBrainzId = album.MusicArtist.GetProviderId(MetadataProviders.MusicBrainzArtist);
if (!string.IsNullOrEmpty(artistMusicBrainzId))
{
await FanartArtistProvider.Current.EnsureArtistXml(artistMusicBrainzId, cancellationToken).ConfigureAwait(false);
var artistXmlPath = FanartArtistProvider.GetArtistXmlPath(_config.CommonApplicationPaths, artistMusicBrainzId);
var musicBrainzReleaseGroupId = album.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
var musicBrainzId = album.GetProviderId(MetadataProviders.MusicBrainzAlbum);
try
{
AddImages(list, artistXmlPath, musicBrainzId, musicBrainzReleaseGroupId, cancellationToken);
}
catch (FileNotFoundException)
{
}
catch (DirectoryNotFoundException)
{
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
return list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0);
}
示例13: Supports
public bool Supports(IHasImages item)
{
if (item.SupportsLocalMetadata)
{
// Episode has it's own provider
if (item.IsOwnedItem || item is Episode || item is Audio || item is Photo)
{
return false;
}
return true;
}
if (item.LocationType == LocationType.Virtual)
{
var season = item as Season;
if (season != null)
{
var series = season.Series;
if (series != null && series.LocationType == LocationType.FileSystem)
{
return true;
}
}
}
return false;
}
示例14: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var series = (Series)item;
var seriesId = series.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(seriesId))
{
var language = item.GetPreferredMetadataLanguage();
await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesId, language, cancellationToken).ConfigureAwait(false);
// Process images
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesId);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
return GetImages(path, language, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return new RemoteImageInfo[] { };
}
示例15: GetImages
private async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, bool posters, bool thumbs, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
if (posters)
{
var posterPath = Path.Combine(_config.ApplicationPaths.CachePath, "imagesbyname", "remotestudioposters.txt");
await EnsurePosterList(posterPath, cancellationToken).ConfigureAwait(false);
list.Add(GetImage(item, posterPath, ImageType.Primary, "folder"));
}
cancellationToken.ThrowIfCancellationRequested();
if (thumbs)
{
var thumbsPath = Path.Combine(_config.ApplicationPaths.CachePath, "imagesbyname", "remotestudiothumbs.txt");
await EnsureThumbsList(thumbsPath, cancellationToken).ConfigureAwait(false);
list.Add(GetImage(item, thumbsPath, ImageType.Thumb, "thumb"));
}
return list.Where(i => i != null);
}