fixed user image scaling

This commit is contained in:
Luke Pulverenti 2014-05-02 10:49:28 -04:00
parent c7c72dd1a8
commit 3228f50895
9 changed files with 74 additions and 43 deletions

View File

@ -1,8 +1,7 @@
using MediaBrowser.Common.Configuration; using System.Globalization;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO; using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
@ -48,6 +47,8 @@ namespace MediaBrowser.Api.Images
/// <value>The id.</value> /// <value>The id.</value>
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Id { get; set; } public string Id { get; set; }
public string Params { get; set; }
} }
/// <summary> /// <summary>
@ -358,9 +359,47 @@ namespace MediaBrowser.Api.Images
_libraryManager.RootFolder : _libraryManager.RootFolder :
_libraryManager.GetItemById(request.Id); _libraryManager.GetItemById(request.Id);
if (!string.IsNullOrEmpty(request.Params))
{
ParseOptions(request, request.Params);
}
return GetImage(request, item); return GetImage(request, item);
} }
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
private void ParseOptions(ImageRequest request, string options)
{
var vals = options.Split(';');
for (var i = 0; i < vals.Length; i++)
{
var val = vals[i];
if (string.IsNullOrWhiteSpace(val))
{
continue;
}
if (i == 0)
{
request.Tag = val;
}
else if (i == 1)
{
request.Format = (ImageOutputFormat)Enum.Parse(typeof(ImageOutputFormat), val, true);
}
else if (i == 2)
{
request.MaxWidth = int.Parse(val, _usCulture);
}
else if (i == 3)
{
request.MaxHeight = int.Parse(val, _usCulture);
}
}
}
/// <summary> /// <summary>
/// Gets the specified request. /// Gets the specified request.
/// </summary> /// </summary>

View File

@ -502,9 +502,6 @@ namespace MediaBrowser.Api.UserLibrary
return userdata != null && userdata.IsFavorite; return userdata != null && userdata.IsFavorite;
}); });
case ItemFilter.IsRecentlyAdded:
return items.Where(item => item.IsRecentlyAdded());
case ItemFilter.IsResumable: case ItemFilter.IsResumable:
return items.Where(item => return items.Where(item =>
{ {

View File

@ -948,16 +948,6 @@ namespace MediaBrowser.Controller.Entities
return GetType().Name; return GetType().Name;
} }
/// <summary>
/// Determines if the item is considered new based on user settings
/// </summary>
/// <returns><c>true</c> if [is recently added] [the specified user]; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public bool IsRecentlyAdded()
{
return (DateTime.UtcNow - DateCreated).TotalDays < ConfigurationManager.Configuration.RecentItemDays;
}
/// <summary> /// <summary>
/// Gets the linked child. /// Gets the linked child.
/// </summary> /// </summary>

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net; using System.Collections.Generic;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
@ -672,22 +673,29 @@ namespace MediaBrowser.Dlna.Didl
private ImageUrlInfo GetImageUrl(ImageDownloadInfo info, int? maxWidth, int? maxHeight) private ImageUrlInfo GetImageUrl(ImageDownloadInfo info, int? maxWidth, int? maxHeight)
{ {
var url = string.Format("{0}/Items/{1}/Images/{2}?tag={3}&format=jpg", var url = string.Format("{0}/Items/{1}/Images/{2}?params=",
_serverAddress, _serverAddress,
info.ItemId, info.ItemId,
info.Type, info.Type);
info.ImageTag);
var options = new List<string>
{
info.ImageTag,
"jpg"
};
if (maxWidth.HasValue) if (maxWidth.HasValue)
{ {
url += "&maxWidth=" + maxWidth.Value.ToString(_usCulture); options.Add(maxWidth.Value.ToString(_usCulture));
} }
if (maxHeight.HasValue) if (maxHeight.HasValue)
{ {
url += "&maxHeight=" + maxHeight.Value.ToString(_usCulture); options.Add(maxHeight.Value.ToString(_usCulture));
} }
url += string.Join(";", options.ToArray());
var width = info.Width; var width = info.Width;
var height = info.Height; var height = info.Height;

View File

@ -123,12 +123,6 @@ namespace MediaBrowser.Model.Configuration
/// <value><c>true</c> if [show log window]; otherwise, <c>false</c>.</value> /// <value><c>true</c> if [show log window]; otherwise, <c>false</c>.</value>
public bool ShowLogWindow { get; set; } public bool ShowLogWindow { get; set; }
/// <summary>
/// Gets or sets the recent item days.
/// </summary>
/// <value>The recent item days.</value>
public int RecentItemDays { get; set; }
/// <summary> /// <summary>
/// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated. /// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated.
/// </summary> /// </summary>
@ -227,9 +221,6 @@ namespace MediaBrowser.Model.Configuration
public NotificationOptions NotificationOptions { get; set; } public NotificationOptions NotificationOptions { get; set; }
[Obsolete("Please use RequireManualLoginForMobileApps")]
public string[] ManualLoginClients { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary> /// </summary>
@ -258,8 +249,6 @@ namespace MediaBrowser.Model.Configuration
RealtimeMonitorDelay = 30; RealtimeMonitorDelay = 30;
RecentItemDays = 10;
EnableInternetProviders = true; //initial installs will need these EnableInternetProviders = true; //initial installs will need these
PathSubstitutions = new PathSubstitution[] { }; PathSubstitutions = new PathSubstitution[] { };
@ -295,8 +284,6 @@ namespace MediaBrowser.Model.Configuration
UICulture = "en-us"; UICulture = "en-us";
NotificationOptions = new NotificationOptions(); NotificationOptions = new NotificationOptions();
ManualLoginClients = new string[] { };
} }
} }

View File

@ -27,10 +27,6 @@ namespace MediaBrowser.Model.Querying
/// </summary> /// </summary>
IsFavorite = 5, IsFavorite = 5,
/// <summary> /// <summary>
/// The item is recently added
/// </summary>
IsRecentlyAdded = 6,
/// <summary>
/// The item is resumable /// The item is resumable
/// </summary> /// </summary>
IsResumable = 7, IsResumable = 7,

View File

@ -1458,10 +1458,10 @@ namespace MediaBrowser.Server.Implementations.Dto
recursiveItemCount++; recursiveItemCount++;
// Check is recently added // Check is recently added
if (child.IsRecentlyAdded()) //if (child.IsRecentlyAdded())
{ //{
rcentlyAddedItemCount++; // rcentlyAddedItemCount++;
} //}
var isUnplayed = true; var isUnplayed = true;

View File

@ -621,5 +621,7 @@
"ButtonVolumeUp": "Volume up", "ButtonVolumeUp": "Volume up",
"ButtonVolumeDown": "Volume down", "ButtonVolumeDown": "Volume down",
"ButtonMute": "Mute", "ButtonMute": "Mute",
"HeaderLatestMedia": "Latest Media" "HeaderLatestMedia": "Latest Media",
"OptionNoSubtitles": "No Subtitles",
"OptionSpecialFeatures": "Special Features"
} }

View File

@ -2025,6 +2025,18 @@
<None Include="dashboard-ui\css\fonts\OpenSans-Light.woff"> <None Include="dashboard-ui\css\fonts\OpenSans-Light.woff">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="dashboard-ui\css\fonts\RobotoLight.woff">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="dashboard-ui\css\fonts\RobotoMedium.woff">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="dashboard-ui\css\fonts\RobotoRegular.woff">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="dashboard-ui\css\fonts\RobotoThin.woff">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="WebMarkupMin.Configuration.xsd"> <None Include="WebMarkupMin.Configuration.xsd">
<SubType>Designer</SubType> <SubType>Designer</SubType>