updated nuget

This commit is contained in:
Luke Pulverenti 2014-12-01 07:43:34 -05:00
parent d7bdb744ca
commit dc8fb33a1f
33 changed files with 368 additions and 270 deletions

View File

@ -0,0 +1,49 @@
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Linq;
namespace MediaBrowser.Api
{
public interface IHasDtoOptions : IHasItemFields
{
bool? EnableImages { get; set; }
int? ImageTypeLimit { get; set; }
string EnableImageTypes { get; set; }
}
public static class HasDtoOptionsExtensions
{
public static DtoOptions GetDtoOptions(this IHasDtoOptions request)
{
var options = new DtoOptions();
options.Fields = request.GetItemFields().ToList();
options.EnableImages = request.EnableImages ?? true;
if (request.ImageTypeLimit.HasValue)
{
options.ImageTypeLimit = request.ImageTypeLimit.Value;
}
if (string.IsNullOrWhiteSpace(request.EnableImageTypes))
{
if (options.EnableImages)
{
// Get everything
options.ImageTypes = Enum.GetNames(typeof(ImageType))
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
.ToList();
}
}
else
{
options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList();
}
return options;
}
}
}

View File

@ -77,6 +77,7 @@
<Compile Include="Dlna\DlnaServerService.cs" />
<Compile Include="Dlna\DlnaService.cs" />
<Compile Include="FilterService.cs" />
<Compile Include="IHasDtoOptions.cs" />
<Compile Include="Library\ChapterService.cs" />
<Compile Include="Playback\Hls\MpegDashService.cs" />
<Compile Include="Playback\MediaInfoService.cs" />

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Constants;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
@ -103,6 +102,7 @@ namespace MediaBrowser.Api
private readonly IHttpClient _httpClient;
private readonly INetworkManager _netManager;
private readonly IJsonSerializer _serializer;
private const string MbAdminUrl = "http://www.mb3admin.com/admin/";
public PackageReviewService(IHttpClient client, INetworkManager net, IJsonSerializer serializer)
{
@ -132,7 +132,7 @@ namespace MediaBrowser.Api
parms += "&title=true";
}
var result = _httpClient.Get(Constants.MbAdminUrl + "/service/packageReview/retrieve" + parms, CancellationToken.None).Result;
var result = _httpClient.Get(MbAdminUrl + "/service/packageReview/retrieve" + parms, CancellationToken.None).Result;
var reviews = _serializer.DeserializeFromStream<List<PackageReviewInfo>>(result);
@ -153,7 +153,7 @@ namespace MediaBrowser.Api
{ "review", reviewText },
};
Task.WaitAll(_httpClient.Post(Constants.MbAdminUrl + "/service/packageReview/update", review, CancellationToken.None));
Task.WaitAll(_httpClient.Post(MbAdminUrl + "/service/packageReview/update", review, CancellationToken.None));
}
}
}

View File

@ -19,7 +19,7 @@ namespace MediaBrowser.Api
/// Class GetNextUpEpisodes
/// </summary>
[Route("/Shows/NextUp", "GET", Summary = "Gets a list of next up episodes")]
public class GetNextUpEpisodes : IReturn<ItemsResult>, IHasItemFields
public class GetNextUpEpisodes : IReturn<ItemsResult>, IHasDtoOptions
{
/// <summary>
/// Gets or sets the user id.
@ -58,10 +58,19 @@ namespace MediaBrowser.Api
/// <value>The parent id.</value>
[ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ParentId { get; set; }
[ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableImages { get; set; }
[ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? ImageTypeLimit { get; set; }
[ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string EnableImageTypes { get; set; }
}
[Route("/Shows/Upcoming", "GET", Summary = "Gets a list of upcoming episodes")]
public class GetUpcomingEpisodes : IReturn<ItemsResult>, IHasItemFields
public class GetUpcomingEpisodes : IReturn<ItemsResult>, IHasDtoOptions
{
/// <summary>
/// Gets or sets the user id.
@ -97,6 +106,15 @@ namespace MediaBrowser.Api
/// <value>The parent id.</value>
[ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ParentId { get; set; }
[ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableImages { get; set; }
[ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? ImageTypeLimit { get; set; }
[ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string EnableImageTypes { get; set; }
}
[Route("/Shows/{Id}/Similar", "GET", Summary = "Finds tv shows similar to a given one.")]
@ -252,9 +270,9 @@ namespace MediaBrowser.Api
var pagedItems = ApplyPaging(previousEpisodes, request.StartIndex, request.Limit);
var fields = request.GetItemFields().ToList();
var options = request.GetDtoOptions();
var returnItems = pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray();
var returnItems = pagedItems.Select(i => _dtoService.GetBaseItemDto(i, options, user)).ToArray();
var result = new ItemsResult
{
@ -283,9 +301,9 @@ namespace MediaBrowser.Api
var user = _userManager.GetUserById(request.UserId);
var fields = request.GetItemFields().ToList();
var options = request.GetDtoOptions();
var returnItems = result.Items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray();
var returnItems = result.Items.Select(i => _dtoService.GetBaseItemDto(i, options, user)).ToArray();
return ToOptimizedSerializedResultUsingCache(new ItemsResult
{

View File

@ -1,5 +1,4 @@
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using ServiceStack;
using System;
@ -8,7 +7,7 @@ using System.Linq;
namespace MediaBrowser.Api.UserLibrary
{
public abstract class BaseItemsRequest : IHasItemFields
public abstract class BaseItemsRequest : IHasDtoOptions
{
protected BaseItemsRequest()
{
@ -123,7 +122,7 @@ namespace MediaBrowser.Api.UserLibrary
public string Years { get; set; }
[ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool EnableImages { get; set; }
public bool? EnableImages { get; set; }
[ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? ImageTypeLimit { get; set; }
@ -213,35 +212,5 @@ namespace MediaBrowser.Api.UserLibrary
return val.Split(',');
}
public DtoOptions GetDtoOptions()
{
var options = new DtoOptions();
options.Fields = this.GetItemFields().ToList();
options.EnableImages = EnableImages;
if (ImageTypeLimit.HasValue)
{
options.ImageTypeLimit = ImageTypeLimit.Value;
}
if (string.IsNullOrWhiteSpace(EnableImageTypes))
{
if (options.EnableImages)
{
// Get everything
options.ImageTypes = Enum.GetNames(typeof(ImageType))
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
.ToList();
}
}
else
{
options.ImageTypes = (EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList();
}
return options;
}
}
}

View File

@ -221,7 +221,7 @@ namespace MediaBrowser.Api.UserLibrary
}
[Route("/Users/{UserId}/Items/Latest", "GET", Summary = "Gets latest media")]
public class GetLatestMedia : IReturn<List<BaseItemDto>>, IHasItemFields
public class GetLatestMedia : IReturn<List<BaseItemDto>>, IHasDtoOptions
{
/// <summary>
/// Gets or sets the user id.
@ -251,6 +251,15 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "GroupItems", Description = "Whether or not to group items into a parent container.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool GroupItems { get; set; }
[ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableImages { get; set; }
[ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? ImageTypeLimit { get; set; }
[ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string EnableImageTypes { get; set; }
public GetLatestMedia()
{
Limit = 20;
@ -362,7 +371,7 @@ namespace MediaBrowser.Api.UserLibrary
}
}
var fields = request.GetItemFields().ToList();
var options = request.GetDtoOptions();
var dtos = list.Select(i =>
{
@ -375,7 +384,7 @@ namespace MediaBrowser.Api.UserLibrary
childCount = i.Item2.Count;
}
var dto = _dtoService.GetBaseItemDto(item, fields, user);
var dto = _dtoService.GetBaseItemDto(item, options, user);
dto.ChildCount = childCount;

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Configuration;
using System.Net.Sockets;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
@ -134,9 +135,22 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
request.Referer = options.Referer;
}
request.ServicePoint.BindIPEndPointDelegate = BindIPEndPointCallback;
return request;
}
private static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
{
// Prefer local ipv4
if (remoteEndPoint.AddressFamily == AddressFamily.InterNetworkV6)
{
return new IPEndPoint(IPAddress.IPv6Any, 0);
}
return new IPEndPoint(IPAddress.Any, 0);
}
private void AddRequestHeaders(HttpWebRequest request, HttpRequestOptions options)
{
foreach (var header in options.RequestHeaders.ToList())

View File

@ -17,7 +17,9 @@ namespace MediaBrowser.Common.Implementations.Security
/// </summary>
public class PluginSecurityManager : ISecurityManager
{
private const string MBValidateUrl = Constants.Constants.MbAdminUrl + "service/registration/validate";
private const string MbAdminUrl = "http://www.mb3admin.com/admin/";
private const string MBValidateUrl = MbAdminUrl + "service/registration/validate";
/// <summary>
/// The _is MB supporter
@ -160,7 +162,7 @@ namespace MediaBrowser.Common.Implementations.Security
return new SupporterInfo();
}
var url = Constants.Constants.MbAdminUrl + "/service/supporter/retrieve?key=" + key;
var url = MbAdminUrl + "/service/supporter/retrieve?key=" + key;
using (var stream = await _httpClient.Get(url, CancellationToken.None).ConfigureAwait(false))
{

View File

@ -161,7 +161,7 @@ namespace MediaBrowser.Common.Implementations.Updates
{ "systemid", _applicationHost.SystemId }
};
using (var json = await _httpClient.Post(Constants.Constants.MbAdminUrl + "service/package/retrieveall", data, cancellationToken).ConfigureAwait(false))
using (var json = await _httpClient.Post(MbAdminUrl + "service/package/retrieveall", data, cancellationToken).ConfigureAwait(false))
{
cancellationToken.ThrowIfCancellationRequested();
@ -172,6 +172,7 @@ namespace MediaBrowser.Common.Implementations.Updates
}
private Tuple<List<PackageInfo>, DateTime> _lastPackageListResult;
private const string MbAdminUrl = "http://www.mb3admin.com/admin/";
/// <summary>
/// Gets all available packages.
@ -203,7 +204,7 @@ namespace MediaBrowser.Common.Implementations.Updates
}
}
using (var json = await _httpClient.Get(Constants.Constants.MbAdminUrl + "service/MB3Packages.json", cancellationToken).ConfigureAwait(false))
using (var json = await _httpClient.Get(MbAdminUrl + "service/MB3Packages.json", cancellationToken).ConfigureAwait(false))
{
cancellationToken.ThrowIfCancellationRequested();

View File

@ -1,8 +0,0 @@

namespace MediaBrowser.Common.Constants
{
public static class Constants
{
public const string MbAdminUrl = "http://www.mb3admin.com/admin/";
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
@ -55,28 +54,6 @@ namespace MediaBrowser.Common.Extensions
return sb.ToString();
}
/// <summary>
/// Removes the accent.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>System.String.</returns>
public static string RemoveAccent(this string text)
{
var normalizedString = text.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder();
foreach (var c in normalizedString)
{
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
}
/// <summary>
/// Gets the M d5.
/// </summary>
@ -109,35 +86,5 @@ namespace MediaBrowser.Common.Extensions
return key.GetMD5();
}
/// <summary>
/// Gets the attribute value.
/// </summary>
/// <param name="str">The STR.</param>
/// <param name="attrib">The attrib.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">attrib</exception>
public static string GetAttributeValue(this string str, string attrib)
{
if (string.IsNullOrEmpty(str))
{
throw new ArgumentNullException("str");
}
if (string.IsNullOrEmpty(attrib))
{
throw new ArgumentNullException("attrib");
}
string srch = "[" + attrib + "=";
int start = str.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
if (start > -1)
{
start += srch.Length;
int end = str.IndexOf(']', start);
return str.Substring(start, end - start);
}
return null;
}
}
}

View File

@ -1,122 +0,0 @@
using MediaBrowser.Common.Extensions;
using System;
using System.IO;
namespace MediaBrowser.Common.IO
{
/// <summary>
/// This is a wrapper for storing large numbers of files within a directory on a file system.
/// Simply pass a filename into GetResourcePath and it will return a full path location of where the file should be stored.
/// </summary>
public class FileSystemRepository
{
/// <summary>
/// Gets or sets the path.
/// </summary>
/// <value>The path.</value>
protected string Path { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemRepository" /> class.
/// </summary>
/// <param name="path">The path.</param>
/// <exception cref="System.ArgumentNullException"></exception>
public FileSystemRepository(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException();
}
Path = path;
}
/// <summary>
/// Gets the full path of where a resource should be stored within the repository
/// </summary>
/// <param name="uniqueName">Name of the unique.</param>
/// <param name="fileExtension">The file extension.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">
/// </exception>
public string GetResourcePath(string uniqueName, string fileExtension)
{
if (string.IsNullOrEmpty(uniqueName))
{
throw new ArgumentNullException("uniqueName");
}
if (string.IsNullOrEmpty(fileExtension))
{
throw new ArgumentNullException("fileExtension");
}
var filename = uniqueName.GetMD5() + fileExtension;
return GetResourcePath(filename);
}
/// <summary>
/// Gets the resource path.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public string GetResourcePath(string filename)
{
if (string.IsNullOrEmpty(filename))
{
throw new ArgumentNullException("filename");
}
var prefix = filename.Substring(0, 1);
var path = System.IO.Path.Combine(Path, prefix);
return System.IO.Path.Combine(path, filename);
}
/// <summary>
/// Determines if a resource is present in the repository
/// </summary>
/// <param name="uniqueName">Name of the unique.</param>
/// <param name="fileExtension">The file extension.</param>
/// <returns><c>true</c> if the specified unique name contains resource; otherwise, <c>false</c>.</returns>
public bool ContainsResource(string uniqueName, string fileExtension)
{
return ContainsFilePath(GetResourcePath(uniqueName, fileExtension));
}
/// <summary>
/// Determines if a file with a given name is present in the repository
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns><c>true</c> if the specified filename contains filename; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public bool ContainsFilename(string filename)
{
if (string.IsNullOrEmpty(filename))
{
throw new ArgumentNullException();
}
return ContainsFilePath(GetResourcePath(filename));
}
/// <summary>
/// Determines if a file is present in the repository
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [contains file path] [the specified path]; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public bool ContainsFilePath(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException();
}
return File.Exists(path);
}
}
}

View File

@ -57,12 +57,10 @@
<Compile Include="Configuration\ConfigurationUpdateEventArgs.cs" />
<Compile Include="Configuration\IConfigurationManager.cs" />
<Compile Include="Configuration\IConfigurationFactory.cs" />
<Compile Include="Constants\Constants.cs" />
<Compile Include="Events\EventHelper.cs" />
<Compile Include="Extensions\BaseExtensions.cs" />
<Compile Include="Extensions\ResourceNotFoundException.cs" />
<Compile Include="IDependencyContainer.cs" />
<Compile Include="IO\FileSystemRepository.cs" />
<Compile Include="IO\IFileSystem.cs" />
<Compile Include="IO\ProgressStream.cs" />
<Compile Include="IO\StreamDefaults.cs" />

View File

@ -361,6 +361,15 @@ namespace MediaBrowser.Controller.Entities
}
}
public bool ContainsPerson(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
}
return People.Any(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
}
public string GetInternalMetadataPath()
{
return GetInternalMetadataPath(ConfigurationManager.ApplicationPaths.InternalMetadataPath);

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
@ -23,6 +24,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
private readonly IServerConfigurationManager _config;
private readonly IUserManager _userManager;
private readonly ILocalizationManager _localization;
private readonly IChannelManager _channelManager;
public ContentDirectory(IDlnaManager dlna,
IUserDataManager userDataManager,
@ -31,7 +33,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
IServerConfigurationManager config,
IUserManager userManager,
ILogger logger,
IHttpClient httpClient, ILocalizationManager localization)
IHttpClient httpClient, ILocalizationManager localization, IChannelManager channelManager)
: base(logger, httpClient)
{
_dlna = dlna;
@ -41,6 +43,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
_config = config;
_userManager = userManager;
_localization = localization;
_channelManager = channelManager;
}
private int SystemUpdateId
@ -77,7 +80,8 @@ namespace MediaBrowser.Dlna.ContentDirectory
user,
SystemUpdateId,
_config,
_localization)
_localization,
_channelManager)
.ProcessControlRequest(request);
}

View File

@ -1,13 +1,16 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Dlna.Didl;
using MediaBrowser.Dlna.Server;
using MediaBrowser.Dlna.Service;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
@ -26,6 +29,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
public class ControlHandler : BaseControlHandler
{
private readonly ILibraryManager _libraryManager;
private readonly IChannelManager _channelManager;
private readonly IUserDataManager _userDataManager;
private readonly User _user;
@ -41,13 +45,14 @@ namespace MediaBrowser.Dlna.ContentDirectory
private readonly DeviceProfile _profile;
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config, ILocalizationManager localization)
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config, ILocalizationManager localization, IChannelManager channelManager)
: base(config, logger)
{
_libraryManager = libraryManager;
_userDataManager = userDataManager;
_user = user;
_systemUpdateId = systemUpdateId;
_channelManager = channelManager;
_profile = profile;
_didlBuilder = new DidlBuilder(profile, user, imageProcessor, serverAddress, userDataManager, localization);
@ -412,7 +417,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
var result = new QueryResult<ServerItem>
{
Items = items.Select(i => new ServerItem { Item = i }).ToArray(),
Items = items.Select(i => new ServerItem { Item = i, StubType = StubType.Folder }).ToArray(),
TotalRecordCount = items.Length
};
@ -426,6 +431,14 @@ namespace MediaBrowser.Dlna.ContentDirectory
return ApplyPaging(await GetMovieItems(movie).ConfigureAwait(false), startIndex, limit);
}
}
var person = item as Person;
if (person != null)
{
return await GetItemsFromPerson(person, user, startIndex, limit).ConfigureAwait(false);
}
return ApplyPaging(new QueryResult<ServerItem>(), startIndex, limit);
}
var folder = (Folder)item;
@ -463,6 +476,42 @@ namespace MediaBrowser.Dlna.ContentDirectory
};
}
private async Task<QueryResult<ServerItem>> GetItemsFromPerson(Person person, User user, int? startIndex, int? limit)
{
var items = user.RootFolder.GetRecursiveChildren(user)
.Where(i => i is Movie || i is Series)
.Where(i => i.ContainsPerson(person.Name))
.ToList();
var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
{
ContentTypes = new[] { ChannelMediaContentType.MovieExtra },
ExtraTypes = new[] { ExtraType.Trailer },
UserId = user.Id.ToString("N")
}, CancellationToken.None).ConfigureAwait(false);
items.AddRange(trailerResult.Items.Where(i => i.ContainsPerson(person.Name)));
items = _libraryManager.Sort(items, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending)
.Skip(startIndex ?? 0)
.Take(limit ?? int.MaxValue)
.ToList();
var serverItems = items.Select(i => new ServerItem
{
Item = i,
StubType = null
})
.ToArray();
return new QueryResult<ServerItem>
{
TotalRecordCount = serverItems.Length,
Items = serverItems
};
}
private QueryResult<ServerItem> ApplyPaging(QueryResult<ServerItem> result, int? startIndex, int? limit)
{
result.Items = result.Items.Skip(startIndex ?? 0).Take(limit ?? int.MaxValue).ToArray();
@ -482,17 +531,27 @@ namespace MediaBrowser.Dlna.ContentDirectory
{
return StubType.Folder;
}
}
if (movie.People.Count > 0)
{
return StubType.Folder;
}
if (EnablePeopleDisplay(item))
{
return StubType.Folder;
}
}
return null;
}
private bool EnablePeopleDisplay(BaseItem item)
{
if (item.People.Count > 0)
{
return item is Movie;
}
return false;
}
private Task<QueryResult<ServerItem>> GetMovieItems(Movie item)
{
var list = new List<BaseItem>();

View File

@ -6,6 +6,11 @@ namespace MediaBrowser.Model.Querying
/// </summary>
public enum ItemFields
{
/// <summary>
/// The alternate episode numbers
/// </summary>
AlternateEpisodeNumbers,
/// <summary>
/// The awards summary
/// </summary>
@ -161,6 +166,11 @@ namespace MediaBrowser.Model.Querying
/// </summary>
ScreenshotImageTags,
/// <summary>
/// The series studio
/// </summary>
SeriesStudio,
/// <summary>
/// The soundtrack ids
/// </summary>

View File

@ -283,6 +283,10 @@ namespace MediaBrowser.Model.Querying
public DateTime? MaxPremiereDate { get; set; }
public bool? EnableImages { get; set; }
public int? ImageTypeLimit { get; set; }
public string EnableImageTypes { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ItemQuery" /> class.
/// </summary>

View File

@ -101,6 +101,21 @@ namespace MediaBrowser.Model.Querying
/// </summary>
/// <value><c>null</c> if [is played] contains no value, <c>true</c> if [is played]; otherwise, <c>false</c>.</value>
public bool? IsPlayed { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable images].
/// </summary>
/// <value><c>null</c> if [enable images] contains no value, <c>true</c> if [enable images]; otherwise, <c>false</c>.</value>
public bool? EnableImages { get; set; }
/// <summary>
/// Gets or sets the image type limit.
/// </summary>
/// <value>The image type limit.</value>
public int? ImageTypeLimit { get; set; }
/// <summary>
/// Gets or sets the enable image types.
/// </summary>
/// <value>The enable image types.</value>
public string EnableImageTypes { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ItemsByNameQuery" /> class.

View File

@ -50,5 +50,20 @@ namespace MediaBrowser.Model.Querying
/// </summary>
/// <value><c>true</c> if [group items]; otherwise, <c>false</c>.</value>
public bool GroupItems { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable images].
/// </summary>
/// <value><c>null</c> if [enable images] contains no value, <c>true</c> if [enable images]; otherwise, <c>false</c>.</value>
public bool? EnableImages { get; set; }
/// <summary>
/// Gets or sets the image type limit.
/// </summary>
/// <value>The image type limit.</value>
public int? ImageTypeLimit { get; set; }
/// <summary>
/// Gets or sets the enable image types.
/// </summary>
/// <value>The enable image types.</value>
public string EnableImageTypes { get; set; }
}
}

View File

@ -38,5 +38,21 @@ namespace MediaBrowser.Model.Querying
/// </summary>
/// <value>The fields.</value>
public ItemFields[] Fields { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable images].
/// </summary>
/// <value><c>null</c> if [enable images] contains no value, <c>true</c> if [enable images]; otherwise, <c>false</c>.</value>
public bool? EnableImages { get; set; }
/// <summary>
/// Gets or sets the image type limit.
/// </summary>
/// <value>The image type limit.</value>
public int? ImageTypeLimit { get; set; }
/// <summary>
/// Gets or sets the enable image types.
/// </summary>
/// <value>The enable image types.</value>
public string EnableImageTypes { get; set; }
}
}

View File

@ -31,5 +31,20 @@
/// </summary>
/// <value>The fields.</value>
public ItemFields[] Fields { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable images].
/// </summary>
/// <value><c>null</c> if [enable images] contains no value, <c>true</c> if [enable images]; otherwise, <c>false</c>.</value>
public bool? EnableImages { get; set; }
/// <summary>
/// Gets or sets the image type limit.
/// </summary>
/// <value>The image type limit.</value>
public int? ImageTypeLimit { get; set; }
/// <summary>
/// Gets or sets the enable image types.
/// </summary>
/// <value>The enable image types.</value>
public string EnableImageTypes { get; set; }
}
}

View File

@ -787,12 +787,24 @@ namespace MediaBrowser.Server.Implementations.Drawing
Directory.CreateDirectory(parentDirectory);
using (var newImage = Image.FromStream(newImageStream.Stream, true, false))
// Save as png
if (newImageStream.Format == Model.Drawing.ImageFormat.Png)
{
//And then save it in the cache
using (var outputStream = _fileSystem.GetFileStream(enhancedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read, false))
{
newImage.Save(System.Drawing.Imaging.ImageFormat.Png, outputStream, 100);
await newImageStream.Stream.CopyToAsync(outputStream).ConfigureAwait(false);
}
}
else
{
using (var newImage = Image.FromStream(newImageStream.Stream, true, false))
{
//And then save it in the cache
using (var outputStream = _fileSystem.GetFileStream(enhancedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read, false))
{
newImage.Save(System.Drawing.Imaging.ImageFormat.Png, outputStream, 100);
}
}
}
}

View File

@ -1020,7 +1020,10 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.AlbumPrimaryImageTag = GetImageCacheTag(albumParent, ImageType.Primary);
}
dto.MediaSourceCount = 1;
//if (fields.Contains(ItemFields.MediaSourceCount))
//{
// Songs always have one
//}
}
var album = item as MusicAlbum;
@ -1057,7 +1060,10 @@ namespace MediaBrowser.Server.Implementations.Dto
if (fields.Contains(ItemFields.MediaSourceCount))
{
dto.MediaSourceCount = video.MediaSourceCount;
if (video.MediaSourceCount != 1)
{
dto.MediaSourceCount = video.MediaSourceCount;
}
}
if (fields.Contains(ItemFields.Chapters))
@ -1120,12 +1126,16 @@ namespace MediaBrowser.Server.Implementations.Dto
{
dto.IndexNumberEnd = episode.IndexNumberEnd;
dto.DvdSeasonNumber = episode.DvdSeasonNumber;
dto.DvdEpisodeNumber = episode.DvdEpisodeNumber;
if (fields.Contains(ItemFields.AlternateEpisodeNumbers))
{
dto.DvdSeasonNumber = episode.DvdSeasonNumber;
dto.DvdEpisodeNumber = episode.DvdEpisodeNumber;
dto.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
}
dto.AirsAfterSeasonNumber = episode.AirsAfterSeasonNumber;
dto.AirsBeforeEpisodeNumber = episode.AirsBeforeEpisodeNumber;
dto.AirsBeforeSeasonNumber = episode.AirsBeforeSeasonNumber;
dto.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
var episodeSeason = episode.Season;
if (episodeSeason != null)
@ -1163,9 +1173,21 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.SeriesId = GetDtoId(series);
dto.SeriesName = series.Name;
dto.AirTime = series.AirTime;
dto.SeriesStudio = series.Studios.FirstOrDefault();
dto.SeriesThumbImageTag = GetImageCacheTag(series, ImageType.Thumb);
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
if (options.GetImageLimit(ImageType.Thumb) > 0)
{
dto.SeriesThumbImageTag = GetImageCacheTag(series, ImageType.Thumb);
}
if (options.GetImageLimit(ImageType.Primary) > 0)
{
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
}
if (fields.Contains(ItemFields.SeriesStudio))
{
dto.SeriesStudio = series.Studios.FirstOrDefault();
}
}
}
@ -1183,7 +1205,10 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.AirTime = series.AirTime;
dto.SeriesStudio = series.Studios.FirstOrDefault();
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
if (options.GetImageLimit(ImageType.Primary) > 0)
{
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
}
}
}

View File

@ -12,6 +12,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
private readonly IApplicationHost _applicationHost;
private readonly INetworkManager _networkManager;
private readonly IHttpClient _httpClient;
private const string MbAdminUrl = "http://www.mb3admin.com/admin/";
public UsageReporter(IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient)
{
@ -37,7 +38,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{ "isservice", _applicationHost.IsRunningAsService.ToString().ToLower()}
};
return _httpClient.Post(Common.Constants.Constants.MbAdminUrl + "service/registration/ping", data, cancellationToken);
return _httpClient.Post(MbAdminUrl + "service/registration/ping", data, cancellationToken);
}
public Task ReportAppUsage(ClientInfo app, CancellationToken cancellationToken)
@ -59,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{ "platform", app.DeviceName },
};
return _httpClient.Post(Common.Constants.Constants.MbAdminUrl + "service/registration/ping", data, cancellationToken);
return _httpClient.Post(MbAdminUrl + "service/registration/ping", data, cancellationToken);
}
}

View File

@ -3,8 +3,6 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.FileOrganization;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.FileOrganization;
using MediaBrowser.Model.Logging;
using System;
@ -13,7 +11,6 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Server.Implementations.Library;
namespace MediaBrowser.Server.Implementations.FileOrganization
{

View File

@ -0,0 +1,37 @@
using System;
namespace MediaBrowser.Server.Implementations.Library
{
public static class PathExtensions
{
/// <summary>
/// Gets the attribute value.
/// </summary>
/// <param name="str">The STR.</param>
/// <param name="attrib">The attrib.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">attrib</exception>
public static string GetAttributeValue(this string str, string attrib)
{
if (string.IsNullOrEmpty(str))
{
throw new ArgumentNullException("str");
}
if (string.IsNullOrEmpty(attrib))
{
throw new ArgumentNullException("attrib");
}
string srch = "[" + attrib + "=";
int start = str.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
if (start > -1)
{
start += srch.Length;
int end = str.IndexOf(']', start);
return str.Substring(start, end - start);
}
return null;
}
}
}

View File

@ -182,6 +182,7 @@
<Compile Include="Library\EntityResolutionHelper.cs" />
<Compile Include="Library\LibraryManager.cs" />
<Compile Include="Library\MusicManager.cs" />
<Compile Include="Library\PathExtensions.cs" />
<Compile Include="Library\Resolvers\BaseVideoResolver.cs" />
<Compile Include="Library\Resolvers\PhotoAlbumResolver.cs" />
<Compile Include="Library\Resolvers\PhotoResolver.cs" />

View File

@ -446,7 +446,7 @@ namespace MediaBrowser.Server.Startup.Common
SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);
RegisterSingleInstance(SessionManager);
var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
RegisterSingleInstance<INewsService>(newsService);
var fileOrganizationService = new FileOrganizationService(TaskManager, FileOrganizationRepository, LogManager.GetLogger("FileOrganizationService"), LibraryMonitor, LibraryManager, ServerConfigurationManager, FileSystemManager, ProviderManager);
@ -481,7 +481,7 @@ namespace MediaBrowser.Server.Startup.Common
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, FileSystemManager, UserManager, ChannelManager, LiveTvManager, ApplicationPaths, playlistManager);
RegisterSingleInstance(UserViewManager);
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager);
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager);
RegisterSingleInstance<IContentDirectory>(contentDirectory);
NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);

View File

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

View File

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

View File

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

View File

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