Merge pull request #2325 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-12-03 15:01:21 -05:00 committed by GitHub
commit e455af7c5c
13 changed files with 80 additions and 112 deletions

View file

@ -148,7 +148,7 @@ namespace Emby.Drawing.ImageMagick
{ {
using (var originalImage = new MagickWand(inputPath)) using (var originalImage = new MagickWand(inputPath))
{ {
ScaleImage(originalImage, width, height); ScaleImage(originalImage, width, height, options.Blur ?? 0);
if (autoOrient) if (autoOrient)
{ {
@ -170,7 +170,7 @@ namespace Emby.Drawing.ImageMagick
{ {
using (var originalImage = new MagickWand(inputPath)) using (var originalImage = new MagickWand(inputPath))
{ {
ScaleImage(originalImage, width, height); ScaleImage(originalImage, width, height, options.Blur ?? 0);
if (autoOrient) if (autoOrient)
{ {
@ -221,13 +221,13 @@ namespace Emby.Drawing.ImageMagick
} }
} }
private void ScaleImage(MagickWand wand, int width, int height) private void ScaleImage(MagickWand wand, int width, int height, int blur)
{ {
var highQuality = false; var useResize = blur > 1;
if (highQuality) if (useResize)
{ {
wand.CurrentImage.ResizeImage(width, height); wand.CurrentImage.ResizeImage(width, height, FilterTypes.GaussianFilter, blur);
} }
else else
{ {

View file

@ -236,7 +236,7 @@ namespace Emby.Drawing
var quality = options.Quality; var quality = options.Quality;
var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]); var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]);
var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.BackgroundColor, options.ForegroundLayer); var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.Blur, options.BackgroundColor, options.ForegroundLayer);
var imageProcessingLockTaken = false; var imageProcessingLockTaken = false;
@ -469,7 +469,7 @@ namespace Emby.Drawing
/// <summary> /// <summary>
/// Gets the cache file path based on a set of parameters /// Gets the cache file path based on a set of parameters
/// </summary> /// </summary>
private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, string backgroundColor, string foregroundLayer) private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, int? blur, string backgroundColor, string foregroundLayer)
{ {
var filename = originalPath; var filename = originalPath;
@ -498,6 +498,11 @@ namespace Emby.Drawing
filename += "p=" + unwatchedCount.Value; filename += "p=" + unwatchedCount.Value;
} }
if (blur.HasValue)
{
filename += "blur=" + blur.Value;
}
if (!string.IsNullOrEmpty(backgroundColor)) if (!string.IsNullOrEmpty(backgroundColor))
{ {
filename += "b=" + backgroundColor; filename += "b=" + backgroundColor;

View file

@ -47,36 +47,6 @@ namespace Emby.Server.Implementations.Library.Validators
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
private bool DownloadMetadata(PersonInfo i, PeopleMetadataOptions options)
{
if (i.IsType(PersonType.Actor))
{
return options.DownloadActorMetadata;
}
if (i.IsType(PersonType.Director))
{
return options.DownloadDirectorMetadata;
}
if (i.IsType(PersonType.Composer))
{
return options.DownloadComposerMetadata;
}
if (i.IsType(PersonType.Writer))
{
return options.DownloadWriterMetadata;
}
if (i.IsType(PersonType.Producer))
{
return options.DownloadProducerMetadata;
}
if (i.IsType(PersonType.GuestStar))
{
return options.DownloadGuestStarMetadata;
}
return options.DownloadOtherPeopleMetadata;
}
/// <summary> /// <summary>
/// Validates the people. /// Validates the people.
/// </summary> /// </summary>
@ -89,28 +59,13 @@ namespace Emby.Server.Implementations.Library.Validators
innerProgress.RegisterAction(pct => progress.Report(pct * .15)); innerProgress.RegisterAction(pct => progress.Report(pct * .15));
var peopleOptions = _config.Configuration.PeopleMetadataOptions;
var people = _libraryManager.GetPeople(new InternalPeopleQuery()); var people = _libraryManager.GetPeople(new InternalPeopleQuery());
var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase); var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
foreach (var person in people) foreach (var person in people)
{ {
var isMetadataEnabled = DownloadMetadata(person, peopleOptions); dict[person.Name] = true;
bool currentValue;
if (dict.TryGetValue(person.Name, out currentValue))
{
if (!currentValue && isMetadataEnabled)
{
dict[person.Name] = true;
}
}
else
{
dict[person.Name] = isMetadataEnabled;
}
} }
var numComplete = 0; var numComplete = 0;

View file

@ -35,13 +35,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
// Randomize the default start hour because this operation can really hammer internet metadata providers return new[]
var startHour = new Random(_appHost.SystemId.GetHashCode()).Next(0, 8); {
return new[] {
// Every so often // Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerDaily, TimeOfDayTicks = TimeSpan.FromHours(startHour).Ticks} new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
IntervalTicks = TimeSpan.FromDays(7).Ticks
}
}; };
} }

View file

@ -64,6 +64,8 @@ namespace MediaBrowser.Api.Images
[ApiMember(Name = "UnplayedCount", Description = "Optional unplayed count overlay to render", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "UnplayedCount", Description = "Optional unplayed count overlay to render", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? UnplayedCount { get; set; } public int? UnplayedCount { get; set; }
public int? Blur { get; set; }
[ApiMember(Name = "BackgroundColor", Description = "Optional. Apply a background color for transparent images.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "BackgroundColor", Description = "Optional. Apply a background color for transparent images.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string BackgroundColor { get; set; } public string BackgroundColor { get; set; }

View file

@ -624,6 +624,7 @@ namespace MediaBrowser.Api.Images
AddPlayedIndicator = request.AddPlayedIndicator, AddPlayedIndicator = request.AddPlayedIndicator,
PercentPlayed = request.PercentPlayed ?? 0, PercentPlayed = request.PercentPlayed ?? 0,
UnplayedCount = request.UnplayedCount, UnplayedCount = request.UnplayedCount,
Blur = request.Blur,
BackgroundColor = request.BackgroundColor, BackgroundColor = request.BackgroundColor,
ForegroundLayer = request.ForegroundLayer, ForegroundLayer = request.ForegroundLayer,
SupportedOutputFormats = supportedFormats SupportedOutputFormats = supportedFormats

View file

@ -35,6 +35,7 @@ namespace MediaBrowser.Controller.Drawing
public bool AddPlayedIndicator { get; set; } public bool AddPlayedIndicator { get; set; }
public int? UnplayedCount { get; set; } public int? UnplayedCount { get; set; }
public int? Blur { get; set; }
public double PercentPlayed { get; set; } public double PercentPlayed { get; set; }
@ -84,6 +85,7 @@ namespace MediaBrowser.Controller.Drawing
!AddPlayedIndicator && !AddPlayedIndicator &&
PercentPlayed.Equals(0) && PercentPlayed.Equals(0) &&
!UnplayedCount.HasValue && !UnplayedCount.HasValue &&
!Blur.HasValue &&
string.IsNullOrEmpty(BackgroundColor) && string.IsNullOrEmpty(BackgroundColor) &&
string.IsNullOrEmpty(ForegroundLayer); string.IsNullOrEmpty(ForegroundLayer);
} }

View file

@ -188,7 +188,13 @@ namespace MediaBrowser.MediaEncoding.Probing
private void FetchFromItunesInfo(string xml, MediaInfo info) private void FetchFromItunesInfo(string xml, MediaInfo info)
{ {
// Make things simpler and strip out the dtd // Make things simpler and strip out the dtd
xml = xml.Substring(xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase)); var plistIndex = xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase);
if (plistIndex != -1)
{
xml = xml.Substring(plistIndex);
}
xml = "<?xml version=\"1.0\"?>" + xml; xml = "<?xml version=\"1.0\"?>" + xml;
// <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>cast</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Blender Foundation</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Janus Bager Kristensen</string>\n\t\t</dict>\n\t</array>\n\t<key>directors</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Sacha Goedegebure</string>\n\t\t</dict>\n\t</array>\n\t<key>studio</key>\n\t<string>Blender Foundation</string>\n</dict>\n</plist>\n // <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>cast</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Blender Foundation</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Janus Bager Kristensen</string>\n\t\t</dict>\n\t</array>\n\t<key>directors</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Sacha Goedegebure</string>\n\t\t</dict>\n\t</array>\n\t<key>studio</key>\n\t<string>Blender Foundation</string>\n</dict>\n</plist>\n
@ -196,36 +202,44 @@ namespace MediaBrowser.MediaEncoding.Probing
{ {
using (var streamReader = new StreamReader(stream)) using (var streamReader = new StreamReader(stream))
{ {
// Use XmlReader for best performance try
using (var reader = XmlReader.Create(streamReader))
{ {
reader.MoveToContent(); // Use XmlReader for best performance
reader.Read(); using (var reader = XmlReader.Create(streamReader))
// Loop through each element
while (!reader.EOF)
{ {
if (reader.NodeType == XmlNodeType.Element) reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{ {
switch (reader.Name) if (reader.NodeType == XmlNodeType.Element)
{ {
case "dict": switch (reader.Name)
using (var subtree = reader.ReadSubtree()) {
{ case "dict":
ReadFromDictNode(subtree, info); using (var subtree = reader.ReadSubtree())
} {
break; ReadFromDictNode(subtree, info);
default: }
reader.Skip(); break;
break; default:
reader.Skip();
break;
}
}
else
{
reader.Read();
} }
} }
else
{
reader.Read();
}
} }
} }
catch (XmlException)
{
// I've seen probe examples where the iTunMOVI value is just "<"
// So we should not allow this to fail the entire probing operation
}
} }
} }
} }

View file

@ -1,19 +0,0 @@
namespace MediaBrowser.Model.Configuration
{
public class PeopleMetadataOptions
{
public bool DownloadActorMetadata { get; set; }
public bool DownloadDirectorMetadata { get; set; }
public bool DownloadProducerMetadata { get; set; }
public bool DownloadWriterMetadata { get; set; }
public bool DownloadComposerMetadata { get; set; }
public bool DownloadOtherPeopleMetadata { get; set; }
public bool DownloadGuestStarMetadata { get; set; }
public PeopleMetadataOptions()
{
DownloadActorMetadata = true;
DownloadDirectorMetadata = true;
}
}
}

View file

@ -181,8 +181,6 @@ namespace MediaBrowser.Model.Configuration
public string UICulture { get; set; } public string UICulture { get; set; }
public PeopleMetadataOptions PeopleMetadataOptions { get; set; }
public bool SaveMetadataHidden { get; set; } public bool SaveMetadataHidden { get; set; }
public NameValuePair[] ContentTypes { get; set; } public NameValuePair[] ContentTypes { get; set; }
@ -260,8 +258,6 @@ namespace MediaBrowser.Model.Configuration
UICulture = "en-us"; UICulture = "en-us";
PeopleMetadataOptions = new PeopleMetadataOptions();
MetadataOptions = new[] MetadataOptions = new[]
{ {
new MetadataOptions(1, 1280) {ItemType = "Book"}, new MetadataOptions(1, 1280) {ItemType = "Book"},

View file

@ -118,7 +118,9 @@ namespace MediaBrowser.Model.Entities
private string AddLanguageIfNeeded(string title) private string AddLanguageIfNeeded(string title)
{ {
if (!string.IsNullOrEmpty(Language) && !string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) && title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) == -1) if (!string.IsNullOrEmpty(Language) &&
!string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) &&
!IsLanguageInTitle(title, Language))
{ {
title = StringHelper.FirstToUpper(Language) + " " + title; title = StringHelper.FirstToUpper(Language) + " " + title;
} }
@ -126,6 +128,16 @@ namespace MediaBrowser.Model.Entities
return title; return title;
} }
private bool IsLanguageInTitle(string title, string language)
{
if (title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) != -1)
{
return true;
}
return false;
}
public string NalLengthSize { get; set; } public string NalLengthSize { get; set; }
/// <summary> /// <summary>

View file

@ -84,7 +84,6 @@
<Compile Include="Configuration\FanartOptions.cs" /> <Compile Include="Configuration\FanartOptions.cs" />
<Compile Include="Configuration\LibraryOptions.cs" /> <Compile Include="Configuration\LibraryOptions.cs" />
<Compile Include="Configuration\MetadataConfiguration.cs" /> <Compile Include="Configuration\MetadataConfiguration.cs" />
<Compile Include="Configuration\PeopleMetadataOptions.cs" />
<Compile Include="Configuration\XbmcMetadataOptions.cs" /> <Compile Include="Configuration\XbmcMetadataOptions.cs" />
<Compile Include="Configuration\SubtitlePlaybackMode.cs" /> <Compile Include="Configuration\SubtitlePlaybackMode.cs" />
<Compile Include="Connect\ConnectAuthenticationExchangeResult.cs" /> <Compile Include="Connect\ConnectAuthenticationExchangeResult.cs" />

View file

@ -377,7 +377,7 @@ namespace MediaBrowser.Providers.TV
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds) internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
{ {
string id; string id;
if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id) && !string.IsNullOrEmpty(id)) if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id))
{ {
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))
@ -386,7 +386,7 @@ namespace MediaBrowser.Providers.TV
} }
} }
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id)) if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id))
{ {
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))
@ -405,7 +405,7 @@ namespace MediaBrowser.Providers.TV
try try
{ {
string seriesId; string seriesId;
if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrWhiteSpace(seriesId))
{ {
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
@ -419,7 +419,7 @@ namespace MediaBrowser.Providers.TV
return seriesDataPath; return seriesDataPath;
} }
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId) && !string.IsNullOrWhiteSpace(seriesId))
{ {
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);