本文整理汇总了C#中BaseItem.RefreshMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# BaseItem.RefreshMetadata方法的具体用法?C# BaseItem.RefreshMetadata怎么用?C# BaseItem.RefreshMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseItem
的用法示例。
在下文中一共展示了BaseItem.RefreshMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshItem
/// <summary>
/// Refreshes the item.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>Task.</returns>
private async Task RefreshItem(RefreshItem request, BaseItem item)
{
var options = GetRefreshOptions(request);
try
{
await item.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false);
if (item.IsFolder)
{
// Collection folders don't validate their children so we'll have to simulate that here
var collectionFolder = item as CollectionFolder;
if (collectionFolder != null)
{
await RefreshCollectionFolderChildren(request, collectionFolder).ConfigureAwait(false);
}
else
{
var folder = (Folder)item;
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None, options, request.Recursive).ConfigureAwait(false);
}
}
}
catch (Exception ex)
{
Logger.ErrorException("Error refreshing library", ex);
}
}
示例2: RefreshIfNeeded
private async Task RefreshIfNeeded(BaseItem program, CancellationToken cancellationToken)
{
if (_refreshedItems.ContainsKey(program.Id))
{
return;
}
await program.RefreshMetadata(cancellationToken).ConfigureAwait(false);
_refreshedItems.TryAdd(program.Id, true);
}
示例3: RefreshChildMetadata
private async Task RefreshChildMetadata(BaseItem child, MetadataRefreshOptions refreshOptions, bool recursive, IProgress<double> progress, CancellationToken cancellationToken)
{
var container = child as IMetadataContainer;
if (container != null)
{
await container.RefreshAllMetadata(refreshOptions, progress, cancellationToken).ConfigureAwait(false);
}
else
{
await child.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
if (recursive)
{
var folder = child as Folder;
if (folder != null)
{
await folder.RefreshMetadataRecursive(refreshOptions, true, progress, cancellationToken);
}
}
}
progress.Report(100);
}
示例4: DownloadTrailerForItem
/// <summary>
/// Downloads the trailer for item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
public async Task DownloadTrailerForItem(BaseItem item, CancellationToken cancellationToken)
{
var url = await GetTrailerUrl(item, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(url))
{
return;
}
var responseInfo = await _httpClient.GetTempFileResponse(new HttpRequestOptions
{
Url = url,
CancellationToken = cancellationToken,
Progress = new Progress<double>(),
UserAgent = GetUserAgent(url)
});
var extension = responseInfo.ContentType.Split('/').Last();
if (string.Equals("quicktime", extension, StringComparison.OrdinalIgnoreCase))
{
extension = "mov";
}
var savePath = Directory.Exists(item.Path) ?
Path.Combine(item.Path, Path.GetFileNameWithoutExtension(item.Path) + "-trailer." + extension) :
Path.Combine(Path.GetDirectoryName(item.Path), Path.GetFileNameWithoutExtension(item.Path) + "-trailer." + extension);
if (!EntityResolutionHelper.IsVideoFile(savePath))
{
_logger.Warn("Unrecognized video extension {0}", savePath);
return;
}
_directoryWatchers.TemporarilyIgnore(savePath);
_logger.Info("Moving {0} to {1}", responseInfo.TempFilePath, savePath);
try
{
var parentPath = Path.GetDirectoryName(savePath);
if (!Directory.Exists(parentPath))
{
Directory.CreateDirectory(parentPath);
}
File.Move(responseInfo.TempFilePath, savePath);
}
finally
{
_directoryWatchers.RemoveTempIgnore(savePath);
}
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}