本文整理汇总了C#中BaseItem.IsSaveLocalMetadataEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# BaseItem.IsSaveLocalMetadataEnabled方法的具体用法?C# BaseItem.IsSaveLocalMetadataEnabled怎么用?C# BaseItem.IsSaveLocalMetadataEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseItem
的用法示例。
在下文中一共展示了BaseItem.IsSaveLocalMetadataEnabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEnabledFor
/// <summary>
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!item.IsFolder)
{
return false;
}
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
// If new metadata has been downloaded and save local is on
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
{
if (!(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) &&
!(item is Season))
{
return true;
}
}
// If new metadata has been downloaded or metadata was manually edited, proceed
if (wasMetadataDownloaded || wasMetadataEdited)
{
if (item is AggregateFolder || item is UserRootFolder || item is CollectionFolder)
{
return true;
}
}
return false;
}
示例2: IsEnabledFor
/// <summary>
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
// If new metadata has been downloaded and save local is on
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
{
if (item is MusicArtist)
{
return true;
}
}
// If new metadata has been downloaded or metadata was manually edited, proceed
if (wasMetadataDownloaded || wasMetadataEdited)
{
var artist = item as MusicArtist;
if (artist != null && artist.IsAccessedByName)
{
return true;
}
}
return false;
}
示例3: IsEnabledFor
/// <summary>
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
// If new metadata has been downloaded and save local is on
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
{
return item is GameSystem;
}
return false;
}
示例4: IsEnabledFor
/// <summary>
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
// If new metadata has been downloaded and save local is on
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
{
var trailer = item as Trailer;
// Don't support local trailers
if (trailer != null)
{
return !trailer.IsLocalTrailer;
}
// Check parent for null to avoid running this against things like video backdrops
return item is Video && !(item is Episode) && item.Parent != null;
}
return false;
}
示例5: SaveImage
/// <summary>
/// Saves the image.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="source">The source.</param>
/// <param name="mimeType">Type of the MIME.</param>
/// <param name="type">The type.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <param name="sourceUrl">The source URL.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">mimeType</exception>
public async Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, string sourceUrl, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(mimeType))
{
throw new ArgumentNullException("mimeType");
}
var saveLocally = item.IsSaveLocalMetadataEnabled() && item.Parent != null && !(item is Audio);
if (item is IItemByName || item is User)
{
saveLocally = true;
}
if (type != ImageType.Primary && item is Episode)
{
saveLocally = false;
}
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
{
saveLocally = false;
var season = item as Season;
// If season is virtual under a physical series, save locally if using compatible convention
if (season != null && _config.Configuration.ImageSavingConvention == ImageSavingConvention.Compatible)
{
var series = season.Series;
if (series != null)
{
var seriesLocationType = series.LocationType;
if (seriesLocationType == LocationType.FileSystem || seriesLocationType == LocationType.Offline)
{
saveLocally = true;
}
}
}
}
if (type == ImageType.Backdrop && imageIndex == null)
{
imageIndex = item.BackdropImagePaths.Count;
}
else if (type == ImageType.Screenshot && imageIndex == null)
{
var hasScreenshots = (IHasScreenshots)item;
imageIndex = hasScreenshots.ScreenshotImagePaths.Count;
}
var index = imageIndex ?? 0;
var paths = GetSavePaths(item, type, imageIndex, mimeType, saveLocally);
// If there are more than one output paths, the stream will need to be seekable
if (paths.Length > 1 && !source.CanSeek)
{
var memoryStream = new MemoryStream();
using (source)
{
await source.CopyToAsync(memoryStream).ConfigureAwait(false);
}
memoryStream.Position = 0;
source = memoryStream;
}
var currentPath = GetCurrentImagePath(item, type, index);
using (source)
{
var isFirst = true;
foreach (var path in paths)
{
// Seek back to the beginning
if (!isFirst)
{
source.Position = 0;
}
await SaveImageToLocation(source, path, cancellationToken).ConfigureAwait(false);
isFirst = false;
}
}
//.........这里部分代码省略.........
示例6: SaveMetadataForItem
private async void SaveMetadataForItem(BaseItem item, ItemUpdateType updateReason)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote ||
locationType == LocationType.Virtual)
{
return;
}
if (!item.SupportsLocalMetadata)
{
return;
}
if (!item.IsSaveLocalMetadataEnabled())
{
return;
}
try
{
await _providerManager.SaveMetadata(item, updateReason, new[] { BaseNfoSaver.SaverName }).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.ErrorException("Error saving metadata for {0}", ex, item.Path ?? item.Name);
}
}