add image download setting
This commit is contained in:
parent
1661c21152
commit
2c3113ced7
|
@ -204,6 +204,8 @@ namespace MediaBrowser.Model.Configuration
|
|||
|
||||
public int MigrationVersion { get; set; }
|
||||
|
||||
public bool DownloadImagesInAdvance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||
/// </summary>
|
||||
|
|
|
@ -18,6 +18,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
|
||||
namespace MediaBrowser.Providers.Manager
|
||||
|
@ -520,6 +521,16 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
private bool EnableImageStub(IHasImages item, ImageType type)
|
||||
{
|
||||
if (item is LiveTvProgram)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_config.Configuration.DownloadImagesInAdvance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.LocationType == LocationType.Remote || item.LocationType == LocationType.Virtual)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -283,12 +283,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
||||
{
|
||||
personEntity.SetImage(new ItemImageInfo
|
||||
{
|
||||
Path = person.ImageUrl,
|
||||
Type = ImageType.Primary,
|
||||
IsPlaceholder = true
|
||||
}, 0);
|
||||
await AddPersonImage(personEntity, person.ImageUrl, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
saveEntity = true;
|
||||
updateType = updateType | ItemUpdateType.ImageUpdate;
|
||||
|
@ -302,6 +297,23 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
private async Task AddPersonImage(Person personEntity, string imageUrl, CancellationToken cancellationToken)
|
||||
{
|
||||
if (ServerConfigurationManager.Configuration.DownloadImagesInAdvance)
|
||||
{
|
||||
await ProviderManager.SaveImage(personEntity, imageUrl, null, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
personEntity.SetImage(new ItemImageInfo
|
||||
{
|
||||
Path = imageUrl,
|
||||
Type = ImageType.Primary,
|
||||
IsPlaceholder = true
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Task _cachedTask = Task.FromResult(true);
|
||||
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
|
@ -729,6 +729,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer, info)).Trim() + ".ts";
|
||||
|
||||
recordPath = Path.Combine(recordPath, recordingFileName);
|
||||
recordPath = EnsureFileUnique(recordPath);
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
|
||||
|
||||
var recordingId = info.Id.GetMD5().ToString("N");
|
||||
|
@ -862,6 +863,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
}
|
||||
}
|
||||
|
||||
private string EnsureFileUnique(string path)
|
||||
{
|
||||
var originalPath = path;
|
||||
var index = 1;
|
||||
|
||||
while (_fileSystem.FileExists(path))
|
||||
{
|
||||
var parent = Path.GetDirectoryName(originalPath);
|
||||
var name = Path.GetFileNameWithoutExtension(originalPath);
|
||||
name += "-" + index.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
path = Path.ChangeExtension(Path.Combine(parent, name), Path.GetExtension(originalPath));
|
||||
index++;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private async Task<IRecorder> GetRecorder()
|
||||
{
|
||||
if (GetConfiguration().EnableRecordingEncoding)
|
||||
|
|
Loading…
Reference in New Issue
Block a user