mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
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 int MigrationVersion { get; set; }
|
||||||
|
|
||||||
|
public bool DownloadImagesInAdvance { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -18,6 +18,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Manager
|
namespace MediaBrowser.Providers.Manager
|
||||||
@ -520,6 +521,16 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
private bool EnableImageStub(IHasImages item, ImageType type)
|
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)
|
if (item.LocationType == LocationType.Remote || item.LocationType == LocationType.Virtual)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -283,12 +283,7 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
||||||
{
|
{
|
||||||
personEntity.SetImage(new ItemImageInfo
|
await AddPersonImage(personEntity, person.ImageUrl, cancellationToken).ConfigureAwait(false);
|
||||||
{
|
|
||||||
Path = person.ImageUrl,
|
|
||||||
Type = ImageType.Primary,
|
|
||||||
IsPlaceholder = true
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
saveEntity = true;
|
saveEntity = true;
|
||||||
updateType = updateType | ItemUpdateType.ImageUpdate;
|
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);
|
private readonly Task _cachedTask = Task.FromResult(true);
|
||||||
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
|
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";
|
var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer, info)).Trim() + ".ts";
|
||||||
|
|
||||||
recordPath = Path.Combine(recordPath, recordingFileName);
|
recordPath = Path.Combine(recordPath, recordingFileName);
|
||||||
|
recordPath = EnsureFileUnique(recordPath);
|
||||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
|
||||||
|
|
||||||
var recordingId = info.Id.GetMD5().ToString("N");
|
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()
|
private async Task<IRecorder> GetRecorder()
|
||||||
{
|
{
|
||||||
if (GetConfiguration().EnableRecordingEncoding)
|
if (GetConfiguration().EnableRecordingEncoding)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user