From dabf25777870124872f733563bf2d142a613c0ad Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 13 Apr 2013 16:20:04 -0400 Subject: more service stack logging --- .../HttpServer/HttpServer.cs | 72 +++++++++++----------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs index b1402eec7..4c7dd1da6 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs @@ -105,6 +105,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer DefaultRedirectPath = defaultRedirectpath; _logger = logger; + ServiceStack.Logging.LogManager.LogFactory = new NLogFactory(); + EndpointHostConfig.Instance.ServiceStackHandlerFactoryPath = null; EndpointHostConfig.Instance.MetadataRedirectPath = "metadata"; @@ -136,58 +138,56 @@ namespace MediaBrowser.Server.Implementations.HttpServer Plugins.Add(new SwaggerFeature()); Plugins.Add(new CorsFeature()); - ServiceStack.Logging.LogManager.LogFactory = new NLogFactory(); - ResponseFilters.Add((req, res, dto) => + { + var exception = dto as Exception; + + if (exception != null) { - var exception = dto as Exception; + _logger.ErrorException("Error processing request for {0}", exception, req.RawUrl); - if (exception != null) + if (!string.IsNullOrEmpty(exception.Message)) { - _logger.ErrorException("Error processing request for {0}", exception, req.RawUrl); - - if (!string.IsNullOrEmpty(exception.Message)) - { - var error = exception.Message.Replace(Environment.NewLine, " "); - error = RemoveControlCharacters(error); + var error = exception.Message.Replace(Environment.NewLine, " "); + error = RemoveControlCharacters(error); - res.AddHeader("X-Application-Error-Code", error); - } + res.AddHeader("X-Application-Error-Code", error); } + } - if (dto is CompressedResult) - { - // Per Google PageSpeed - // This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed. - // The correct version of the resource is delivered based on the client request header. - // This is a good choice for applications that are singly homed and depend on public proxies for user locality. - res.AddHeader("Vary", "Accept-Encoding"); - } + if (dto is CompressedResult) + { + // Per Google PageSpeed + // This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed. + // The correct version of the resource is delivered based on the client request header. + // This is a good choice for applications that are singly homed and depend on public proxies for user locality. + res.AddHeader("Vary", "Accept-Encoding"); + } - var hasOptions = dto as IHasOptions; + var hasOptions = dto as IHasOptions; - if (hasOptions != null) + if (hasOptions != null) + { + // Content length has to be explicitly set on on HttpListenerResponse or it won't be happy + string contentLength; + + if (hasOptions.Options.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength)) { - // Content length has to be explicitly set on on HttpListenerResponse or it won't be happy - string contentLength; + var length = long.Parse(contentLength, UsCulture); - if (hasOptions.Options.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength)) + if (length > 0) { - var length = long.Parse(contentLength, UsCulture); - - if (length > 0) - { - var response = (HttpListenerResponse) res.OriginalResponse; + var response = (HttpListenerResponse)res.OriginalResponse; - response.ContentLength64 = length; + response.ContentLength64 = length; - // Disable chunked encoding. Technically this is only needed when using Content-Range, but - // anytime we know the content length there's no need for it - response.SendChunked = false; - } + // Disable chunked encoding. Technically this is only needed when using Content-Range, but + // anytime we know the content length there's no need for it + response.SendChunked = false; } } - }); + } + }); } /// -- cgit v1.2.3 From 5a3c46fd5e6fb1435d4d19db6b6624b061ff101a Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 13 Apr 2013 17:45:29 -0400 Subject: Have DirectoryWatchers ignore some files --- MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs index c33975a64..684b72cc9 100644 --- a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs +++ b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs @@ -38,6 +38,11 @@ namespace MediaBrowser.Server.Implementations.IO /// private readonly ConcurrentDictionary _tempIgnoredPaths = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + /// + /// Any file name ending in any of these will be ignored by the watchers + /// + private readonly List _alwaysIgnoreFiles = new List {"thumbs.db","small.jpg","albumart.jpg"}; + /// /// The timer lock /// @@ -313,10 +318,18 @@ namespace MediaBrowser.Server.Implementations.IO /// The instance containing the event data. void watcher_Changed(object sender, FileSystemEventArgs e) { + // Ignore when someone manually creates a new folder if (e.ChangeType == WatcherChangeTypes.Created && e.Name == "New folder") { return; } + + // Ignore certain files + if (_alwaysIgnoreFiles.Any(f => e.Name.EndsWith(f, StringComparison.OrdinalIgnoreCase))) + { + return; + } + if (_tempIgnoredPaths.ContainsKey(e.FullPath)) { Logger.Info("Watcher requested to ignore change to " + e.FullPath); -- cgit v1.2.3 From 7f1fdbf223f95dfc1435a8ff1b82fd635cc9b1d9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 13 Apr 2013 19:43:41 -0400 Subject: add GuestStar distinction --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 22 ++++++++++++++++------ MediaBrowser.Api/UserLibrary/PersonsService.cs | 1 - MediaBrowser.Controller/Entities/BaseItem.cs | 6 +++--- MediaBrowser.Controller/Entities/Folder.cs | 2 +- .../Providers/BaseItemXmlParser.cs | 14 +++++++++++++- .../Providers/ImagesByNameProvider.cs | 15 ++++++++++++++- .../Providers/TV/RemoteEpisodeProvider.cs | 6 +++--- .../Providers/TV/RemoteSeriesProvider.cs | 2 +- MediaBrowser.Model/Entities/PersonType.cs | 4 ++++ MediaBrowser.Model/Querying/ItemQuery.cs | 2 +- .../Library/LibraryManager.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 14 files changed, 62 insertions(+), 24 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index c907dfe9b..cd6bd7854 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -38,8 +38,8 @@ namespace MediaBrowser.Api.UserLibrary /// If the Person filter is used, this can also be used to restrict to a specific person type /// /// The type of the person. - [ApiMember(Name = "PersonType", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string PersonType { get; set; } + [ApiMember(Name = "PersonTypes", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string PersonTypes { get; set; } /// /// Search characters used to find items @@ -448,11 +448,21 @@ namespace MediaBrowser.Api.UserLibrary // Apply person filter if (!string.IsNullOrEmpty(personName)) { - var personType = request.PersonType; + var personTypes = request.PersonTypes; - items = !string.IsNullOrEmpty(personType) - ? items.Where(item => item.People != null && item.People.Any(p => p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(personType, StringComparison.OrdinalIgnoreCase))) - : items.Where(item => item.People != null && item.People.Any(p => p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase))); + if (string.IsNullOrEmpty(personTypes)) + { + items = items.Where(item => item.People != null && item.People.Any(p => string.Equals(p.Name, personName, StringComparison.OrdinalIgnoreCase))); + } + else + { + var types = personTypes.Split(','); + + items = items.Where(item => + item.People != null && + item.People.Any(p => + p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && types.Contains(p.Type, StringComparer.OrdinalIgnoreCase))); + } } return items; diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs index 698530eb5..fe5cf39f6 100644 --- a/MediaBrowser.Api/UserLibrary/PersonsService.cs +++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs @@ -89,7 +89,6 @@ namespace MediaBrowser.Api.UserLibrary { var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.Type)); - return personTypes.Length == 0 ? people : diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d8a0db69a..3c60d3a39 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the name. /// /// The name. - public virtual string Name { get; set; } + public string Name { get; set; } /// /// Gets or sets the id. @@ -477,7 +477,7 @@ namespace MediaBrowser.Controller.Entities /// /// The end date. public DateTime? EndDate { get; set; } - + /// /// Gets or sets the display type of the media. /// @@ -569,7 +569,7 @@ namespace MediaBrowser.Controller.Entities /// /// The production locations. public List ProductionLocations { get; set; } - + /// /// Gets or sets the community rating. /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index fed6bb7de..5816b23f8 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. protected IEnumerable GetIndexByPerformer(User user) { - return GetIndexByPerson(user, new List { PersonType.Actor, PersonType.MusicArtist }, LocalizedStrings.Instance.GetString("PerformerDispPref")); + return GetIndexByPerson(user, new List { PersonType.Actor, PersonType.MusicArtist, PersonType.GuestStar }, LocalizedStrings.Instance.GetString("PerformerDispPref")); } /// diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index d539ed771..e0091cd80 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -242,7 +242,6 @@ namespace MediaBrowser.Controller.Providers } case "Actors": - case "GuestStars": { foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor })) { @@ -255,6 +254,19 @@ namespace MediaBrowser.Controller.Providers break; } + case "GuestStars": + { + foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar })) + { + if (string.IsNullOrWhiteSpace(p.Name)) + { + continue; + } + item.AddPerson(p); + } + break; + } + case "Trailer": { var val = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs b/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs index 53ff94720..1c4c783c4 100644 --- a/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs +++ b/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs @@ -63,7 +63,20 @@ namespace MediaBrowser.Controller.Providers { // If the IBN location exists return the last modified date of any file in it var location = GetLocation(item); - return Directory.Exists(location) ? FileSystem.GetFiles(location).Select(f => f.CreationTimeUtc > f.LastWriteTimeUtc ? f.CreationTimeUtc : f.LastWriteTimeUtc).Max() : DateTime.MinValue; + + if (!Directory.Exists(location)) + { + return DateTime.MinValue; + } + + var files = FileSystem.GetFiles(location).ToList(); + + if (files.Count == 0) + { + return DateTime.MinValue; + } + + return files.Select(f => f.CreationTimeUtc > f.LastWriteTimeUtc ? f.CreationTimeUtc : f.LastWriteTimeUtc).Max(); } /// diff --git a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs index 6be0881b4..b5c6df7ec 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs @@ -263,21 +263,21 @@ namespace MediaBrowser.Controller.Providers.TV var actors = doc.SafeGetString("//GuestStars"); if (actors != null) { - episode.AddPeople(actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Actor", Name = str })); + episode.AddPeople(actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str })); } var directors = doc.SafeGetString("//Director"); if (directors != null) { - episode.AddPeople(directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Director", Name = str })); + episode.AddPeople(directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.Director, Name = str })); } var writers = doc.SafeGetString("//Writer"); if (writers != null) { - episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Writer", Name = str })); + episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.Writer, Name = str })); } if (ConfigurationManager.Configuration.SaveLocalMeta) diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs index f4e6d7893..89cb89289 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs @@ -322,7 +322,7 @@ namespace MediaBrowser.Controller.Providers.TV personNode.AppendChild(doc.ImportNode(subNode, true)); //need to add the type var typeNode = doc.CreateNode(XmlNodeType.Element, "Type", null); - typeNode.InnerText = "Actor"; + typeNode.InnerText = PersonType.Actor; personNode.AppendChild(typeNode); actorsNode.AppendChild(personNode); } diff --git a/MediaBrowser.Model/Entities/PersonType.cs b/MediaBrowser.Model/Entities/PersonType.cs index fca1fbf20..e8c46e29a 100644 --- a/MediaBrowser.Model/Entities/PersonType.cs +++ b/MediaBrowser.Model/Entities/PersonType.cs @@ -26,5 +26,9 @@ namespace MediaBrowser.Model.Entities /// The music artist /// public const string MusicArtist = "MusicArtist"; + /// + /// The guest star + /// + public const string GuestStar = "GuestStar"; } } diff --git a/MediaBrowser.Model/Querying/ItemQuery.cs b/MediaBrowser.Model/Querying/ItemQuery.cs index 86886d751..59a5e938d 100644 --- a/MediaBrowser.Model/Querying/ItemQuery.cs +++ b/MediaBrowser.Model/Querying/ItemQuery.cs @@ -120,7 +120,7 @@ namespace MediaBrowser.Model.Querying /// If the Person filter is used, this can also be used to restrict to a specific person type /// /// The type of the person. - public string PersonType { get; set; } + public string[] PersonTypes { get; set; } /// /// Search characters used to find items diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 3bb5472df..ca261a393 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -696,7 +696,7 @@ namespace MediaBrowser.Server.Implementations.Library var tasks = new List(); - var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director }; + var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director, PersonType.GuestStar }; var people = RootFolder.RecursiveChildren .Where(c => c.People != null) diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index ee5dd453d..861112b50 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.73 + 3.0.75 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 5b721d6c1..f034329f9 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.73 + 3.0.75 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index f420da078..1797f275c 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.73 + 3.0.75 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3