当前位置: 首页>>代码示例>>C#>>正文


C# BaseItem.RefreshMetadata方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Ceten,项目名称:MediaBrowser,代码行数:35,代码来源:ItemRefreshService.cs

示例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);
        }
开发者ID:jmarsh0507,项目名称:MediaBrowser,代码行数:11,代码来源:ChannelManager.cs

示例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);
        }
开发者ID:jabbera,项目名称:MediaBrowser,代码行数:24,代码来源:Folder.cs

示例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);
        }
开发者ID:rrb008,项目名称:MediaBrowser.Plugins,代码行数:62,代码来源:LocalTrailerDownloader.cs


注:本文中的BaseItem.RefreshMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。