update image processing

This commit is contained in:
Luke Pulverenti 2015-08-02 15:08:55 -04:00
parent 6d13cec38e
commit 47b1a4cafd
20 changed files with 72 additions and 25 deletions

View File

@ -189,7 +189,21 @@ namespace Emby.Drawing
dateModified = tuple.Item2; dateModified = tuple.Item2;
} }
var originalImageSize = GetImageSize(originalImagePath, dateModified); ImageSize originalImageSize;
try
{
originalImageSize = GetImageSize(originalImagePath, dateModified);
}
catch
{
// This is an arbitrary default, but don't fail the whole process over this
originalImageSize = new ImageSize
{
Width = 100,
Height = 100
};
}
// Determine the output size based on incoming parameters // Determine the output size based on incoming parameters
var newSize = DrawingUtils.Resize(originalImageSize, options.Width, options.Height, options.MaxWidth, options.MaxHeight); var newSize = DrawingUtils.Resize(originalImageSize, options.Width, options.Height, options.MaxWidth, options.MaxHeight);

View File

@ -854,7 +854,7 @@ namespace MediaBrowser.Api.Playback
state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationTokenSource.Token).ConfigureAwait(false); state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationTokenSource.Token).ConfigureAwait(false);
} }
if (state.MediaSource.RequiresOpening ?? false) if (state.MediaSource.RequiresOpening)
{ {
var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest
{ {

View File

@ -185,7 +185,7 @@ namespace MediaBrowser.Api.Playback
private async void DisposeLiveStream() private async void DisposeLiveStream()
{ {
if ((MediaSource.RequiresClosing ?? false) && string.IsNullOrWhiteSpace(Request.LiveStreamId)) if ((MediaSource.RequiresClosing) && string.IsNullOrWhiteSpace(Request.LiveStreamId))
{ {
try try
{ {

View File

@ -67,6 +67,7 @@ namespace MediaBrowser.Api
_config.Configuration.EnableLibraryMetadataSubFolder = true; _config.Configuration.EnableLibraryMetadataSubFolder = true;
_config.Configuration.EnableUserSpecificUserViews = true; _config.Configuration.EnableUserSpecificUserViews = true;
_config.Configuration.EnableCustomPathSubFolders = true; _config.Configuration.EnableCustomPathSubFolders = true;
_config.Configuration.DisableXmlSavers = true;
_config.SaveConfiguration(); _config.SaveConfiguration();
} }

View File

@ -11,4 +11,9 @@ namespace MediaBrowser.Controller.Library
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
string GetSavePath(IHasMetadata item); string GetSavePath(IHasMetadata item);
} }
public interface IConfigurableProvider
{
bool IsEnabled { get; }
}
} }

View File

@ -12,7 +12,7 @@ using System.Threading;
namespace MediaBrowser.LocalMetadata.Savers namespace MediaBrowser.LocalMetadata.Savers
{ {
public class EpisodeXmlSaver : IMetadataFileSaver public class EpisodeXmlProvider : IMetadataFileSaver, IConfigurableProvider
{ {
private readonly IItemRepository _itemRepository; private readonly IItemRepository _itemRepository;
@ -20,7 +20,7 @@ namespace MediaBrowser.LocalMetadata.Savers
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
public EpisodeXmlSaver(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) public EpisodeXmlProvider(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager)
{ {
_itemRepository = itemRepository; _itemRepository = itemRepository;
_config = config; _config = config;
@ -51,6 +51,11 @@ namespace MediaBrowser.LocalMetadata.Savers
} }
} }
public bool IsEnabled
{
get { return !_config.Configuration.DisableXmlSavers; }
}
/// <summary> /// <summary>
/// Saves the specified item. /// Saves the specified item.
/// </summary> /// </summary>

View File

@ -15,13 +15,13 @@ namespace MediaBrowser.LocalMetadata.Savers
/// <summary> /// <summary>
/// Saves movie.xml for movies, trailers and music videos /// Saves movie.xml for movies, trailers and music videos
/// </summary> /// </summary>
public class MovieXmlSaver : IMetadataFileSaver public class MovieXmlProvider : IMetadataFileSaver, IConfigurableProvider
{ {
private readonly IItemRepository _itemRepository; private readonly IItemRepository _itemRepository;
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
public MovieXmlSaver(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) public MovieXmlProvider(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager)
{ {
_itemRepository = itemRepository; _itemRepository = itemRepository;
_config = config; _config = config;
@ -36,6 +36,11 @@ namespace MediaBrowser.LocalMetadata.Savers
} }
} }
public bool IsEnabled
{
get { return !_config.Configuration.DisableXmlSavers; }
}
/// <summary> /// <summary>
/// Determines whether [is enabled for] [the specified item]. /// Determines whether [is enabled for] [the specified item].
/// </summary> /// </summary>

View File

@ -12,12 +12,12 @@ using System.Threading;
namespace MediaBrowser.LocalMetadata.Savers namespace MediaBrowser.LocalMetadata.Savers
{ {
public class SeriesXmlSaver : IMetadataFileSaver public class SeriesXmlProvider : IMetadataFileSaver, IConfigurableProvider
{ {
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
public SeriesXmlSaver(IServerConfigurationManager config, ILibraryManager libraryManager) public SeriesXmlProvider(IServerConfigurationManager config, ILibraryManager libraryManager)
{ {
_config = config; _config = config;
_libraryManager = libraryManager; _libraryManager = libraryManager;
@ -47,6 +47,11 @@ namespace MediaBrowser.LocalMetadata.Savers
return item is Series && updateType >= ItemUpdateType.MetadataDownload; return item is Series && updateType >= ItemUpdateType.MetadataDownload;
} }
public bool IsEnabled
{
get { return !_config.Configuration.DisableXmlSavers; }
}
private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary> /// <summary>

View File

@ -436,7 +436,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationToken).ConfigureAwait(false); state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationToken).ConfigureAwait(false);
} }
if (state.MediaSource.RequiresOpening ?? false) if (state.MediaSource.RequiresOpening)
{ {
var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest
{ {

View File

@ -136,7 +136,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private async void DisposeLiveStream() private async void DisposeLiveStream()
{ {
if (MediaSource.RequiresClosing ?? false) if (MediaSource.RequiresClosing)
{ {
try try
{ {

View File

@ -213,6 +213,8 @@ namespace MediaBrowser.Model.Configuration
public int SharingExpirationDays { get; set; } public int SharingExpirationDays { get; set; }
public bool DisableXmlSavers { 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>

View File

@ -26,9 +26,9 @@ namespace MediaBrowser.Model.Dto
public bool SupportsDirectStream { get; set; } public bool SupportsDirectStream { get; set; }
public bool SupportsDirectPlay { get; set; } public bool SupportsDirectPlay { get; set; }
public bool? RequiresOpening { get; set; } public bool RequiresOpening { get; set; }
public string OpenToken { get; set; } public string OpenToken { get; set; }
public bool? RequiresClosing { get; set; } public bool RequiresClosing { get; set; }
public string LiveStreamId { get; set; } public string LiveStreamId { get; set; }
public int? BufferMs { get; set; } public int? BufferMs { get; set; }

View File

@ -106,9 +106,15 @@ namespace MediaBrowser.Providers.Manager
_identityProviders = identityProviders.ToArray(); _identityProviders = identityProviders.ToArray();
_identityConverters = identityConverters.ToArray(); _identityConverters = identityConverters.ToArray();
_metadataProviders = metadataProviders.ToArray(); _metadataProviders = metadataProviders.ToArray();
_savers = metadataSavers.ToArray();
_imageSavers = imageSavers.ToArray(); _imageSavers = imageSavers.ToArray();
_externalIds = externalIds.OrderBy(i => i.Name).ToArray(); _externalIds = externalIds.OrderBy(i => i.Name).ToArray();
_savers = metadataSavers.Where(i =>
{
var configurable = i as IConfigurableProvider;
return configurable == null || configurable.IsEnabled;
}).ToArray();
} }
public Task<ItemUpdateType> RefreshSingleItem(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> RefreshSingleItem(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken)

View File

@ -449,7 +449,7 @@ namespace MediaBrowser.Server.Implementations.Library
LiveStreamInfo current; LiveStreamInfo current;
if (_openStreams.TryGetValue(id, out current)) if (_openStreams.TryGetValue(id, out current))
{ {
if (current.MediaSource.RequiresClosing ?? false) if (current.MediaSource.RequiresClosing)
{ {
var tuple = GetProvider(id); var tuple = GetProvider(id);

View File

@ -368,7 +368,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
info = await service.GetChannelStream(channel.ExternalId, mediaSourceId, cancellationToken).ConfigureAwait(false); info = await service.GetChannelStream(channel.ExternalId, mediaSourceId, cancellationToken).ConfigureAwait(false);
info.RequiresClosing = true; info.RequiresClosing = true;
if (info.RequiresClosing ?? false) if (info.RequiresClosing)
{ {
var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_";
@ -385,7 +385,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
info = await service.GetRecordingStream(recording.ExternalId, null, cancellationToken).ConfigureAwait(false); info = await service.GetRecordingStream(recording.ExternalId, null, cancellationToken).ConfigureAwait(false);
info.RequiresClosing = true; info.RequiresClosing = true;
if (info.RequiresClosing ?? false) if (info.RequiresClosing)
{ {
var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_";

View File

@ -59,6 +59,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
IEnumerable<MediaSourceInfo> sources; IEnumerable<MediaSourceInfo> sources;
var forceRequireOpening = false;
try try
{ {
if (item is ILiveTvRecording) if (item is ILiveTvRecording)
@ -78,6 +80,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false) sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false)
.ToList(); .ToList();
forceRequireOpening = true;
} }
var list = sources.ToList(); var list = sources.ToList();
@ -87,12 +91,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
source.Type = MediaSourceType.Default; source.Type = MediaSourceType.Default;
if (!source.RequiresOpening.HasValue) if (source.RequiresOpening || forceRequireOpening)
{ {
source.RequiresOpening = true; source.RequiresOpening = true;
} }
if (source.RequiresOpening.HasValue && source.RequiresOpening.Value) if (source.RequiresOpening)
{ {
var openKeys = new List<string>(); var openKeys = new List<string>();
openKeys.Add(item.GetType().Name); openKeys.Add(item.GetType().Name);

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.629</version> <version>3.0.631</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption.</description> <description>Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Emby 2013</copyright> <copyright>Copyright © Emby 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.629" /> <dependency id="MediaBrowser.Common" version="3.0.631" />
<dependency id="NLog" version="3.2.1" /> <dependency id="NLog" version="3.2.1" />
<dependency id="SimpleInjector" version="2.8.0" /> <dependency id="SimpleInjector" version="2.8.0" />
</dependencies> </dependencies>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.629</version> <version>3.0.631</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Emby Team</authors> <authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Model.Signed</id> <id>MediaBrowser.Model.Signed</id>
<version>3.0.629</version> <version>3.0.631</version>
<title>MediaBrowser.Model - Signed Edition</title> <title>MediaBrowser.Model - Signed Edition</title>
<authors>Emby Team</authors> <authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.629</version> <version>3.0.631</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Emby Team</authors> <authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Emby Server.</description> <description>Contains core components required to build plugins for Emby Server.</description>
<copyright>Copyright © Emby 2013</copyright> <copyright>Copyright © Emby 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.629" /> <dependency id="MediaBrowser.Common" version="3.0.631" />
<dependency id="Interfaces.IO" version="1.0.0.5" /> <dependency id="Interfaces.IO" version="1.0.0.5" />
</dependencies> </dependencies>
</metadata> </metadata>