本文整理汇总了C#中BaseItem.HasImage方法的典型用法代码示例。如果您正苦于以下问题:C# BaseItem.HasImage方法的具体用法?C# BaseItem.HasImage怎么用?C# BaseItem.HasImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseItem
的用法示例。
在下文中一共展示了BaseItem.HasImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NeedsRefreshInternal
/// <summary>
/// Needses the refresh internal.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tvdb)))
{
return false;
}
if (!ConfigurationManager.Configuration.DownloadSeriesImages.Art &&
!ConfigurationManager.Configuration.DownloadSeriesImages.Logo &&
!ConfigurationManager.Configuration.DownloadSeriesImages.Thumb &&
!ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops &&
!ConfigurationManager.Configuration.DownloadSeriesImages.Banner)
{
return false;
}
if (item.HasImage(ImageType.Art) &&
item.HasImage(ImageType.Logo) &&
item.HasImage(ImageType.Banner) &&
item.HasImage(ImageType.Thumb) &&
item.BackdropImagePaths.Count > 0)
{
return false;
}
return base.NeedsRefreshInternal(item, providerInfo);
}
示例2: NeedsRefreshInternal
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (item.HasImage(ImageType.Primary) && item.HasImage(ImageType.Thumb))
{
return false;
}
// Try again periodically in case new images were added
if ((DateTime.UtcNow - providerInfo.LastRefreshed).TotalDays > 7)
{
return true;
}
return base.NeedsRefreshInternal(item, providerInfo);
}
示例3: FetchAsync
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{
if (item.HasImage(ImageType.Primary) && item.HasImage(ImageType.Thumb))
{
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, MusicGenresManualImageProvider.ProviderName).ConfigureAwait(false);
await DownloadImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
示例4: FetchAsync
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
if (item.HasImage(ImageType.Primary))
{
SetLastRefreshed(item, DateTime.UtcNow);
return true;
}
try
{
await DownloadImage(item, cancellationToken).ConfigureAwait(false);
}
catch (HttpException ex)
{
// Don't fail the provider on a 404
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
SetLastRefreshed(item, DateTime.UtcNow);
return true;
}
示例5: FetchAsync
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{
if (item.HasImage(ImageType.Primary))
{
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
var changed = true;
try
{
changed = await DownloadImage((LiveTvProgram)item, cancellationToken).ConfigureAwait(false);
}
catch (HttpException ex)
{
// Don't fail the provider on a 404
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
if (changed)
{
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
}
return changed;
}
示例6: NeedsRefreshInternal
/// <summary>
/// Needses the refresh internal.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (item.HasImage(ImageType.Primary))
{
return false;
}
return base.NeedsRefreshInternal(item, providerInfo);
}
示例7: FetchAsync
/// <summary>
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
/// </summary>
/// <param name="item">The item.</param>
/// <param name="force">if set to <c>true</c> [force].</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
if (!item.HasImage(ImageType.Primary))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualLastFmImageProvider.ProviderName).ConfigureAwait(false);
await DownloadImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow);
return true;
}
示例8: DownloadImages
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, CancellationToken cancellationToken)
{
if (!item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images))
{
var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
if (image != null)
{
await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken)
.ConfigureAwait(false);
}
}
}
示例9: NeedsRefreshInternal
/// <summary>
/// Needses the refresh internal.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (item.HasImage(ImageType.Primary))
{
return false;
}
if (string.IsNullOrWhiteSpace(GetImageUrl(item)))
{
return false;
}
return base.NeedsRefreshInternal(item, providerInfo);
}
示例10: GetItemInfo
/// <summary>
/// Converts a BaseItem to a BaseItemInfo
/// </summary>
/// <param name="item">The item.</param>
/// <param name="chapterOwner">The chapter owner.</param>
/// <param name="mediaSourceId">The media source identifier.</param>
/// <returns>BaseItemInfo.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
private BaseItemInfo GetItemInfo(BaseItem item, BaseItem chapterOwner, string mediaSourceId)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
var info = new BaseItemInfo
{
Id = GetDtoId(item),
Name = item.Name,
MediaType = item.MediaType,
Type = item.GetClientTypeName(),
RunTimeTicks = item.RunTimeTicks,
IndexNumber = item.IndexNumber,
ParentIndexNumber = item.ParentIndexNumber,
PremiereDate = item.PremiereDate,
ProductionYear = item.ProductionYear
};
info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
if (info.PrimaryImageTag != null)
{
info.PrimaryImageItemId = GetDtoId(item);
}
var episode = item as Episode;
if (episode != null)
{
info.IndexNumberEnd = episode.IndexNumberEnd;
}
var hasSeries = item as IHasSeries;
if (hasSeries != null)
{
info.SeriesName = hasSeries.SeriesName;
}
var recording = item as ILiveTvRecording;
if (recording != null && recording.RecordingInfo != null)
{
if (recording.RecordingInfo.IsSeries)
{
info.Name = recording.RecordingInfo.EpisodeTitle;
info.SeriesName = recording.RecordingInfo.Name;
if (string.IsNullOrWhiteSpace(info.Name))
{
info.Name = recording.RecordingInfo.Name;
}
}
}
var audio = item as Audio;
if (audio != null)
{
info.Album = audio.Album;
info.Artists = audio.Artists;
if (info.PrimaryImageTag == null)
{
var album = audio.Parents.OfType<MusicAlbum>().FirstOrDefault();
if (album != null && album.HasImage(ImageType.Primary))
{
info.PrimaryImageTag = GetImageCacheTag(album, ImageType.Primary);
if (info.PrimaryImageTag != null)
{
info.PrimaryImageItemId = GetDtoId(album);
}
}
}
}
var musicVideo = item as MusicVideo;
if (musicVideo != null)
{
info.Album = musicVideo.Album;
if (!string.IsNullOrWhiteSpace(musicVideo.Artist))
{
info.Artists.Add(musicVideo.Artist);
}
}
var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
var logoItem = item.HasImage(ImageType.Logo) ? item : null;
if (thumbItem == null)
{
if (episode != null)
//.........这里部分代码省略.........
示例11: FetchFromXml
/// <summary>
/// Fetches from XML.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="xmlFilePath">The XML file path.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task FetchFromXml(BaseItem item, string xmlFilePath, CancellationToken cancellationToken)
{
var doc = new XmlDocument();
doc.Load(xmlFilePath);
cancellationToken.ThrowIfCancellationRequested();
string path;
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo))
{
var node =
doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ??
doc.SelectSingleNode("//fanart/music/musiclogos/musiclogo/@url");
path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path))
{
try
{
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Logo, null, cancellationToken)
.ConfigureAwait(false);
}
catch (HttpException ex)
{
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
}
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && item.BackdropImagePaths.Count == 0)
{
var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url");
if (nodes != null)
{
var numBackdrops = 0;
item.BackdropImagePaths = new List<string>();
foreach (XmlNode node in nodes)
{
path = node.Value;
if (!string.IsNullOrEmpty(path))
{
try
{
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Backdrop, numBackdrops, cancellationToken)
.ConfigureAwait(false);
numBackdrops++;
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
}
catch (HttpException ex)
{
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
}
}
}
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art))
{
var node =
doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ??
doc.SelectSingleNode("//fanart/music/musicarts/musicart/@url");
path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path))
{
try
{
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Art, null, cancellationToken)
.ConfigureAwait(false);
}
catch (HttpException ex)
{
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
}
}
//.........这里部分代码省略.........
示例12: NeedsRefreshInternal
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (item.HasImage(ImageType.Primary) && item.HasImage(ImageType.Banner) && item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.TvOptions.MaxBackdrops)
{
return false;
}
return base.NeedsRefreshInternal(item, providerInfo);
}
示例13: DownloadImages
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, int backdropLimit, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
if (!item.HasImage(ImageType.Primary))
{
var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
if (image != null)
{
await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken)
.ConfigureAwait(false);
}
}
if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner))
{
var image = images.FirstOrDefault(i => i.Type == ImageType.Banner);
if (image != null)
{
await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Banner, null, cancellationToken)
.ConfigureAwait(false);
}
}
}
if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit && !item.LockedFields.Contains(MetadataFields.Backdrops))
{
foreach (var backdrop in images.Where(i => i.Type == ImageType.Backdrop &&
(!i.Width.HasValue ||
i.Width.Value >= ConfigurationManager.Configuration.TvOptions.MinBackdropWidth)))
{
var url = backdrop.Url;
if (item.ContainsImageWithSourceUrl(url))
{
continue;
}
await _providerManager.SaveImage(item, url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Backdrop, null, cancellationToken).ConfigureAwait(false);
if (item.BackdropImagePaths.Count >= backdropLimit) break;
}
}
}
示例14: ProcessImages
/// <summary>
/// Processes the images.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="images">The images.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task.</returns>
protected virtual async Task<ProviderRefreshStatus> ProcessImages(BaseItem item, MovieImages images, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var status = ProviderRefreshStatus.Success;
// poster
if (images.posters != null && images.posters.Count > 0 && !item.HasImage(ImageType.Primary))
{
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
// get highest rated poster for our language
var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
if (poster == null && !ConfigurationManager.Configuration.PreferredMetadataLanguage.Equals("en"))
{
// couldn't find our specific language, find english (if that wasn't our language)
poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase));
}
if (poster == null)
{
//still couldn't find it - try highest rated null one
poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 == null);
}
if (poster == null)
{
//finally - just get the highest rated one
poster = postersSortedByVote.FirstOrDefault();
}
if (poster != null)
{
var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{
Url = tmdbImageUrl + poster.file_path,
CancellationToken = cancellationToken
}).ConfigureAwait(false);
await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(poster.file_path), ImageType.Primary, null, cancellationToken)
.ConfigureAwait(false);
}
}
cancellationToken.ThrowIfCancellationRequested();
// backdrops - only download if earlier providers didn't find any (fanart)
if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
{
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;
for (var i = 0; i < images.backdrops.Count; i++)
{
var bdName = "backdrop" + (i == 0 ? "" : i.ToString(CultureInfo.InvariantCulture));
var hasLocalBackdrop = item.LocationType == LocationType.FileSystem && ConfigurationManager.Configuration.SaveLocalMeta ? item.HasLocalImage(bdName) : item.BackdropImagePaths.Count > i;
if (!hasLocalBackdrop)
{
var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{
Url = tmdbImageUrl + images.backdrops[i].file_path,
CancellationToken = cancellationToken
}).ConfigureAwait(false);
await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(images.backdrops[i].file_path), ImageType.Backdrop, item.BackdropImagePaths.Count, cancellationToken)
.ConfigureAwait(false);
}
if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops)
{
break;
}
}
}
return status;
}
示例15: FetchFromXml
/// <summary>
/// Fetches from XML.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="images">The images.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task FetchFromXml(BaseItem item, List<RemoteImageInfo> images , CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary))
{
await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo))
{
await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art))
{
await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner))
{
await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops;
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops &&
item.BackdropImagePaths.Count < backdropLimit)
{
foreach (var image in images.Where(i => i.Type == ImageType.Backdrop))
{
await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Backdrop, null, cancellationToken)
.ConfigureAwait(false);
if (item.BackdropImagePaths.Count >= backdropLimit) break;
}
}
}