fixed ffprobe running over and over

This commit is contained in:
Luke Pulverenti 2013-09-25 11:11:23 -04:00
parent 3ee73bb7c2
commit 2d9b48d00f
17 changed files with 80 additions and 38 deletions

View File

@ -180,7 +180,7 @@ namespace MediaBrowser.Api
if (job.ActiveRequestCount == 0) if (job.ActiveRequestCount == 0)
{ {
var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 60000; var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 180000;
if (job.KillTimer == null) if (job.KillTimer == null)
{ {

View File

@ -385,7 +385,7 @@ namespace MediaBrowser.Controller.Providers
var sb = new StringBuilder(); var sb = new StringBuilder();
var extensions = FileStampExtensionsDictionary; var extensions = FileStampExtensionsDictionary;
var numExtensions = extensions.Count; var numExtensions = FilestampExtensions.Length;
// Record the name of each file // Record the name of each file
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order // Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order

View File

@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Session
/// </summary> /// </summary>
/// <value>The name of the now viewing item.</value> /// <value>The name of the now viewing item.</value>
public string NowViewingItemName { get; set; } public string NowViewingItemName { get; set; }
/// <summary> /// <summary>
/// Gets or sets the now playing item. /// Gets or sets the now playing item.
/// </summary> /// </summary>
@ -107,7 +107,7 @@ namespace MediaBrowser.Controller.Session
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is muted; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is muted; otherwise, <c>false</c>.</value>
public bool IsMuted { get; set; } public bool IsMuted { get; set; }
/// <summary> /// <summary>
/// Gets or sets the device id. /// Gets or sets the device id.
/// </summary> /// </summary>
@ -139,7 +139,7 @@ namespace MediaBrowser.Controller.Session
return WebSockets.Any(i => i.State == WebSocketState.Open); return WebSockets.Any(i => i.State == WebSocketState.Open);
} }
return (DateTime.UtcNow - LastActivityDate).TotalMinutes <= 5; return (DateTime.UtcNow - LastActivityDate).TotalMinutes <= 10;
} }
} }

View File

@ -178,6 +178,7 @@ namespace MediaBrowser.Providers.MediaInfo
} }
} }
SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;
} }

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -58,7 +59,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { }); XmlSaverHelpers.Save(builder, xmlFilePath, new List<string> { });
// Set last refreshed so that the provider doesn't trigger after the file save // Set last refreshed so that the provider doesn't trigger after the file save
PersonProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow); PersonProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -70,7 +71,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { }); XmlSaverHelpers.Save(builder, xmlFilePath, new List<string> { });
// Set last refreshed so that the provider doesn't trigger after the file save // Set last refreshed so that the provider doesn't trigger after the file save
ArtistProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow); ArtistProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -57,7 +58,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { }); XmlSaverHelpers.Save(builder, xmlFilePath, new List<string> { });
BoxSetProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow); BoxSetProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);
} }

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -87,7 +88,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new[] XmlSaverHelpers.Save(builder, xmlFilePath, new List<string>
{ {
"FirstAired", "FirstAired",
"SeasonNumber", "SeasonNumber",

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
@ -77,7 +78,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { }); XmlSaverHelpers.Save(builder, xmlFilePath, new List<string> { });
FolderProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow); FolderProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);
} }

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Providers.Movies; using MediaBrowser.Providers.Movies;
@ -66,7 +67,7 @@ namespace MediaBrowser.Providers.Savers
if (!string.IsNullOrEmpty(game.GameSystem)) if (!string.IsNullOrEmpty(game.GameSystem))
{ {
builder.Append("<GameSystem><![CDATA[" + game.GameSystem + "]]></GameSystem>"); builder.Append("<GameSystem>" + SecurityElement.Escape(game.GameSystem) + "</GameSystem>");
} }
XmlSaverHelpers.AddCommonNodes(item, builder); XmlSaverHelpers.AddCommonNodes(item, builder);
@ -75,7 +76,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new[] XmlSaverHelpers.Save(builder, xmlFilePath, new List<string>
{ {
"Players", "Players",
"GameSystem" "GameSystem"

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -103,7 +104,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new[] XmlSaverHelpers.Save(builder, xmlFilePath, new List<string>
{ {
"IMDBrating", "IMDBrating",
"Description", "Description",

View File

@ -1,4 +1,5 @@
using System.Security; using System.Collections.Generic;
using System.Security;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Providers.Movies; using MediaBrowser.Providers.Movies;
@ -57,7 +58,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new[] XmlSaverHelpers.Save(builder, xmlFilePath, new List<string>
{ {
"PlaceOfBirth" "PlaceOfBirth"
}); });

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
@ -57,7 +58,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { }); XmlSaverHelpers.Save(builder, xmlFilePath, new List<string> { });
SeasonProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow); SeasonProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);
} }

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration; using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -105,7 +106,7 @@ namespace MediaBrowser.Providers.Savers
var xmlFilePath = GetSavePath(item); var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new[] XmlSaverHelpers.Save(builder, xmlFilePath, new List<string>
{ {
"id", "id",
"SeriesName", "SeriesName",

View File

@ -29,13 +29,11 @@ namespace MediaBrowser.Providers.Savers
/// <param name="xml">The XML.</param> /// <param name="xml">The XML.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="xmlTagsUsed">The XML tags used.</param> /// <param name="xmlTagsUsed">The XML tags used.</param>
public static void Save(StringBuilder xml, string path, IEnumerable<string> xmlTagsUsed) public static void Save(StringBuilder xml, string path, List<string> xmlTagsUsed)
{ {
if (File.Exists(path)) if (File.Exists(path))
{ {
var tags = xmlTagsUsed.ToList(); xmlTagsUsed.AddRange(new[]
tags.AddRange(new[]
{ {
"MediaInfo", "MediaInfo",
"ContentRating", "ContentRating",
@ -88,7 +86,7 @@ namespace MediaBrowser.Providers.Savers
}); });
var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase); var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase);
xml.Insert(position, GetCustomTags(path, tags)); xml.Insert(position, GetCustomTags(path, xmlTagsUsed));
} }
var xmlDocument = new XmlDocument(); var xmlDocument = new XmlDocument();
@ -142,17 +140,46 @@ namespace MediaBrowser.Providers.Savers
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="xmlTagsUsed">The XML tags used.</param> /// <param name="xmlTagsUsed">The XML tags used.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
private static string GetCustomTags(string path, ICollection<string> xmlTagsUsed) private static string GetCustomTags(string path, IEnumerable<string> xmlTagsUsed)
{ {
var doc = new XmlDocument(); var settings = new XmlReaderSettings
doc.Load(path); {
CheckCharacters = false,
IgnoreProcessingInstructions = true,
IgnoreComments = true,
ValidationType = ValidationType.None
};
var nodes = doc.DocumentElement.ChildNodes.Cast<XmlNode>() var tagsDictionary = xmlTagsUsed.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
.Where(i => !xmlTagsUsed.Contains(i.Name))
.Select(i => i.OuterXml)
.ToArray();
return string.Join(Environment.NewLine, nodes); var builder = new StringBuilder();
using (var streamReader = new StreamReader(path, Encoding.UTF8))
{
// Use XmlReader for best performance
using (var reader = XmlReader.Create(streamReader, settings))
{
reader.MoveToContent();
// Loop through each element
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (!tagsDictionary.ContainsKey(reader.Name))
{
builder.AppendLine(reader.ReadOuterXml());
}
else
{
reader.Skip();
}
}
}
}
}
return builder.ToString();
} }
/// <summary> /// <summary>

View File

@ -57,7 +57,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// <summary> /// <summary>
/// The FF probe resource pool /// The FF probe resource pool
/// </summary> /// </summary>
private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(2, 2); private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(1, 1);
public string FFMpegPath { get; private set; } public string FFMpegPath { get; private set; }

View File

@ -159,6 +159,10 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
{ {
previouslyFailedImages = new List<string>(); previouslyFailedImages = new List<string>();
} }
catch (DirectoryNotFoundException)
{
previouslyFailedImages = new List<string>();
}
foreach (var video in videos) foreach (var video in videos)
{ {