aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/MoviesService.cs9
-rw-r--r--MediaBrowser.Api/SimilarItemsHelper.cs16
-rw-r--r--MediaBrowser.Controller/Entities/TV/Episode.cs19
-rw-r--r--MediaBrowser.Controller/Entities/TV/Season.cs16
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs86
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs28
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs4
7 files changed, 70 insertions, 108 deletions
diff --git a/MediaBrowser.Api/MoviesService.cs b/MediaBrowser.Api/MoviesService.cs
index 23a803b20..9cd7c5b76 100644
--- a/MediaBrowser.Api/MoviesService.cs
+++ b/MediaBrowser.Api/MoviesService.cs
@@ -13,6 +13,13 @@ namespace MediaBrowser.Api
[Api(Description = "Finds movies and trailers similar to a given movie.")]
public class GetSimilarMovies : BaseGetSimilarItems
{
+ [ApiMember(Name = "IncludeTrailers", Description = "Whether or not to include trailers within the results. Defaults to true.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
+ public bool IncludeTrailers { get; set; }
+
+ public GetSimilarMovies()
+ {
+ IncludeTrailers = true;
+ }
}
/// <summary>
@@ -58,7 +65,7 @@ namespace MediaBrowser.Api
_libraryManager,
_userDataRepository,
Logger,
- request, item => item is Movie || item is Trailer,
+ request, item => item is Movie || (item is Trailer && request.IncludeTrailers),
SimilarItemsHelper.GetSimiliarityScore);
return ToOptimizedResult(result);
diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs
index bd4aecd0d..c96fc504f 100644
--- a/MediaBrowser.Api/SimilarItemsHelper.cs
+++ b/MediaBrowser.Api/SimilarItemsHelper.cs
@@ -123,7 +123,7 @@ namespace MediaBrowser.Api
return inputItems.Where(i => i.Id != currentItem.Id)
.Select(i => new Tuple<BaseItem, int>(i, getSimilarityScore(item, i)))
- .Where(i => i.Item2 > 0)
+ .Where(i => i.Item2 > 5)
.OrderByDescending(i => i.Item2)
.ThenByDescending(i => i.Item1.CriticRating ?? 0)
.Select(i => i.Item1);
@@ -157,23 +157,23 @@ namespace MediaBrowser.Api
points += item1.People.Where(i => item2PeopleNames.Contains(i.Name, StringComparer.OrdinalIgnoreCase)).Sum(i =>
{
- if (string.Equals(i.Name, PersonType.Director, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(i.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase))
{
return 5;
}
- if (string.Equals(i.Name, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(i.Type, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
- if (string.Equals(i.Name, PersonType.Composer, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(i.Type, PersonType.Composer, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
- if (string.Equals(i.Name, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(i.Type, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
- if (string.Equals(i.Name, PersonType.Writer, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(i.Type, PersonType.Writer, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
@@ -188,13 +188,13 @@ namespace MediaBrowser.Api
// Add if they came out within the same decade
if (diff < 10)
{
- points += 3;
+ points += 2;
}
// And more if within five years
if (diff < 5)
{
- points += 3;
+ points += 2;
}
}
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index 116997d96..7e8540ebe 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -1,7 +1,4 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Model.Entities;
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
@@ -132,20 +129,6 @@ namespace MediaBrowser.Controller.Entities.TV
}
/// <summary>
- /// We persist the MB Id of our series object so we can always find it no matter
- /// what context we happen to be loaded from.
- /// </summary>
- /// <value>The series item id.</value>
- public Guid SeriesItemId { get; set; }
-
- /// <summary>
- /// We persist the MB Id of our season object so we can always find it no matter
- /// what context we happen to be loaded from.
- /// </summary>
- /// <value>The season item id.</value>
- public Guid SeasonItemId { get; set; }
-
- /// <summary>
/// The _series
/// </summary>
private Series _series;
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs
index 79d608459..b4dc3eae4 100644
--- a/MediaBrowser.Controller/Entities/TV/Season.cs
+++ b/MediaBrowser.Controller/Entities/TV/Season.cs
@@ -1,11 +1,8 @@
-using System.Collections.Generic;
-using System.IO;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.IO;
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
-using MediaBrowser.Model.Entities;
using System;
+using System.Collections.Generic;
+using System.IO;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities.TV
@@ -83,13 +80,6 @@ namespace MediaBrowser.Controller.Entities.TV
}
/// <summary>
- /// We persist the MB Id of our series object so we can always find it no matter
- /// what context we happen to be loaded from.
- /// </summary>
- /// <value>The series item id.</value>
- public Guid SeriesItemId { get; set; }
-
- /// <summary>
/// The _series
/// </summary>
private Series _series;
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
index 91d79bda0..082a55ea0 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
@@ -154,7 +154,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ typeof(DirectoryNotFoundException), 404 }
},
- DebugMode = true
+ DebugMode = true,
+
+ ServiceName = ServerName,
+
+ LogFactory = LogManager.LogFactory,
+
+ EnableFeatures = Feature.Csv | Feature.Html | Feature.Json | Feature.Jsv | Feature.Metadata | Feature.Xml
});
container.Adapter = _containerAdapter;
@@ -162,56 +168,64 @@ namespace MediaBrowser.Server.Implementations.HttpServer
Plugins.Add(new SwaggerFeature());
Plugins.Add(new CorsFeature());
- ResponseFilters.Add((req, res, dto) =>
+ ResponseFilters.Add(FilterResponse);
+ }
+
+ /// <summary>
+ /// Filters the response.
+ /// </summary>
+ /// <param name="req">The req.</param>
+ /// <param name="res">The res.</param>
+ /// <param name="dto">The dto.</param>
+ private void FilterResponse(IHttpRequest req, IHttpResponse res, object 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;
}
}
- });
+ }
}
/// <summary>
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
index cc9016190..3969acac7 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
@@ -2,7 +2,6 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
-using System;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{
@@ -71,32 +70,5 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
return null;
}
-
- /// <summary>
- /// Sets the initial item values.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="args">The args.</param>
- protected override void SetInitialItemValues(Episode item, ItemResolveArgs args)
- {
- base.SetInitialItemValues(item, args);
-
- //fill in our season and series ids
- var season = args.Parent as Season;
- if (season != null)
- {
- item.SeasonItemId = season.Id;
- var series = season.Parent as Series;
- if (series != null)
- {
- item.SeriesItemId = series.Id;
- }
- }
- else
- {
- var series = args.Parent as Series;
- item.SeriesItemId = series != null ? series.Id : Guid.Empty;
- }
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index 7ad5d08db..c426fed25 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -1,7 +1,6 @@
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
-using System;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{
@@ -58,9 +57,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{
base.SetInitialItemValues(item, args);
- var series = args.Parent as Series;
- item.SeriesItemId = series != null ? series.Id : Guid.Empty;
-
Season.AddMetadataFiles(args);
}
}