jellyfin/MediaBrowser.Controller/Entities/PhotoAlbum.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2015-04-05 08:01:57 -07:00
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Users;
using System;
2014-08-28 21:06:30 -07:00
using System.Linq;
2014-10-19 20:04:45 -07:00
using System.Runtime.Serialization;
2015-04-05 08:01:57 -07:00
using System.Threading;
using System.Threading.Tasks;
2014-08-28 21:06:30 -07:00
namespace MediaBrowser.Controller.Entities
{
2015-04-05 08:01:57 -07:00
public class PhotoAlbum : Folder, IMetadataContainer
2014-08-28 21:06:30 -07:00
{
public override bool SupportsLocalMetadata
{
get
{
return false;
}
}
2014-10-19 20:04:45 -07:00
[IgnoreDataMember]
public override bool AlwaysScanInternalMetadataPath
{
get
{
return true;
}
}
2014-12-19 23:06:27 -07:00
protected override bool GetBlockUnratedValue(UserPolicy config)
2014-08-28 21:06:30 -07:00
{
return config.BlockUnratedItems.Contains(UnratedItem.Other);
}
2015-04-05 08:01:57 -07:00
public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken)
{
var items = GetRecursiveChildren().ToList();
var totalItems = items.Count;
var numComplete = 0;
// Refresh songs
foreach (var item in items)
{
cancellationToken.ThrowIfCancellationRequested();
await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
numComplete++;
double percent = numComplete;
percent /= totalItems;
progress.Report(percent * 100);
}
// Refresh current item
await RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
progress.Report(100);
}
2014-08-28 21:06:30 -07:00
}
}