factor device pixel ratio into downloaded image size

This commit is contained in:
Luke Pulverenti 2014-05-23 19:58:28 -04:00
parent 40836f194b
commit 1e532d4f53
24 changed files with 200 additions and 71 deletions

View File

@ -118,20 +118,20 @@ namespace MediaBrowser.Api.Images
public object Get(GetMediaInfoImages request)
{
return ToOptimizedResult(GetImageList(_appPaths.MediaInfoImagesPath));
return ToOptimizedResult(GetImageList(_appPaths.MediaInfoImagesPath, true));
}
public object Get(GetRatingImages request)
{
return ToOptimizedResult(GetImageList(_appPaths.RatingsPath));
return ToOptimizedResult(GetImageList(_appPaths.RatingsPath, true));
}
public object Get(GetGeneralImages request)
{
return ToOptimizedResult(GetImageList(_appPaths.GeneralPath));
return ToOptimizedResult(GetImageList(_appPaths.GeneralPath, false));
}
private List<ImageByNameInfo> GetImageList(string path)
private List<ImageByNameInfo> GetImageList(string path, bool supportsThemes)
{
try
{
@ -142,7 +142,7 @@ namespace MediaBrowser.Api.Images
{
Name = Path.GetFileNameWithoutExtension(i.FullName),
FileLength = i.Length,
Theme = GetThemeName(i.FullName, path),
Theme = supportsThemes ? GetThemeName(i.FullName, path) : null,
Format = i.Extension.ToLower().TrimStart('.')
})
.OrderBy(i => i.Name)

View File

@ -42,6 +42,12 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "IsFavorite", Description = "Filter by channels that are favorites, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsFavorite { get; set; }
[ApiMember(Name = "IsLiked", Description = "Filter by channels that are liked, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsLiked { get; set; }
[ApiMember(Name = "IsDisliked", Description = "Filter by channels that are disliked, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsDisliked { get; set; }
}
[Route("/LiveTv/Channels/{Id}", "GET", Summary = "Gets a live tv channel")]
@ -294,7 +300,9 @@ namespace MediaBrowser.Api.LiveTv
UserId = request.UserId,
StartIndex = request.StartIndex,
Limit = request.Limit,
IsFavorite = request.IsFavorite
IsFavorite = request.IsFavorite,
IsLiked = request.IsLiked,
IsDisliked = request.IsDisliked
}, CancellationToken.None).Result;

View File

@ -53,10 +53,5 @@ namespace MediaBrowser.Controller.Channels
return base.LocationType;
}
}
public override string GetClientTypeName()
{
return "audio.channelItem";
}
}
}

View File

@ -33,10 +33,5 @@ namespace MediaBrowser.Controller.Channels
{
Tags = new List<string>();
}
public override string GetClientTypeName()
{
return "folder.channelItem";
}
}
}

View File

@ -77,10 +77,5 @@ namespace MediaBrowser.Controller.Channels
return base.LocationType;
}
}
public override string GetClientTypeName()
{
return "video.channelItem";
}
}
}

View File

@ -22,11 +22,17 @@ namespace MediaBrowser.Controller.Channels
/// <value>The data version.</value>
string DataVersion { get; }
/// <summary>
/// Gets the home page URL.
/// </summary>
/// <value>The home page URL.</value>
string HomePageUrl { get; }
/// <summary>
/// Gets the channel information.
/// </summary>
/// <returns>ChannelInfo.</returns>
ChannelInfo GetChannelInfo();
/// <returns>ChannelFeatures.</returns>
ChannelFeatures GetChannelFeatures();
/// <summary>
/// Determines whether [is enabled for] [the specified user].
@ -52,6 +58,14 @@ namespace MediaBrowser.Controller.Channels
/// <returns>Task{IEnumerable{ChannelItem}}.</returns>
Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken);
/// <summary>
/// Gets all media.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{ChannelItemResult}.</returns>
Task<ChannelItemResult> GetAllMedia(InternalAllChannelItemsQuery query, CancellationToken cancellationToken);
/// <summary>
/// Gets the channel image.
/// </summary>

View File

@ -12,4 +12,14 @@ namespace MediaBrowser.Controller.Channels
public int? Limit { get; set; }
}
public class InternalAllChannelItemsQuery
{
public User User { get; set; }
public int? StartIndex { get; set; }
public int? Limit { get; set; }
}
}

View File

@ -77,6 +77,9 @@
<Compile Include="..\MediaBrowser.Model\ApiClient\SessionUpdatesEventArgs.cs">
<Link>ApiClient\SessionUpdatesEventArgs.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Channels\ChannelFeatures.cs">
<Link>Channels\ChannelFeatures.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Channels\ChannelInfo.cs">
<Link>Channels\ChannelInfo.cs</Link>
</Compile>

View File

@ -64,6 +64,9 @@
<Compile Include="..\MediaBrowser.Model\ApiClient\SessionUpdatesEventArgs.cs">
<Link>ApiClient\SessionUpdatesEventArgs.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Channels\ChannelFeatures.cs">
<Link>Channels\ChannelFeatures.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Channels\ChannelInfo.cs">
<Link>Channels\ChannelInfo.cs</Link>
</Compile>

View File

@ -59,6 +59,30 @@ namespace MediaBrowser.Model.ApiClient
Task<T> GetAsync<T>(string url, CancellationToken cancellationToken)
where T : class;
/// <summary>
/// Gets the url needed to stream an audio file
/// </summary>
/// <param name="options">The options.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentNullException">options</exception>
string GetAudioStreamUrl(StreamOptions options);
/// <summary>
/// Gets the url needed to stream a video file
/// </summary>
/// <param name="options">The options.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentNullException">options</exception>
string GetVideoStreamUrl(VideoStreamOptions options);
/// <summary>
/// Formulates a url for streaming video using the HLS protocol
/// </summary>
/// <param name="options">The options.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentNullException">options</exception>
string GetHlsVideoStreamUrl(VideoStreamOptions options);
/// <summary>
/// Reports the capabilities.
/// </summary>

View File

@ -0,0 +1,43 @@
using System.Collections.Generic;
namespace MediaBrowser.Model.Channels
{
public class ChannelFeatures
{
/// <summary>
/// Gets or sets a value indicating whether this instance can search.
/// </summary>
/// <value><c>true</c> if this instance can search; otherwise, <c>false</c>.</value>
public bool CanSearch { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance can index all media.
/// </summary>
/// <value><c>true</c> if this instance can index all media; otherwise, <c>false</c>.</value>
public bool CanGetAllMedia { get; set; }
/// <summary>
/// Gets or sets the media types.
/// </summary>
/// <value>The media types.</value>
public List<ChannelMediaType> MediaTypes { get; set; }
/// <summary>
/// Gets or sets the content types.
/// </summary>
/// <value>The content types.</value>
public List<ChannelMediaContentType> ContentTypes { get; set; }
/// <summary>
/// Represents the maximum number of records the channel allows retrieving at a time
/// </summary>
public int? MaxPageSize { get; set; }
public ChannelFeatures()
{
MediaTypes = new List<ChannelMediaType>();
ContentTypes = new List<ChannelMediaContentType>();
}
}
}

View File

@ -1,35 +1,30 @@
using System.Collections.Generic;

namespace MediaBrowser.Model.Channels
{
public class ChannelInfo
{
/// <summary>
/// Gets the home page URL.
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
public string Id { get; set; }
/// <summary>
/// Gets or sets the home page URL.
/// </summary>
/// <value>The home page URL.</value>
public string HomePageUrl { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance can search.
/// Gets or sets the features.
/// </summary>
/// <value><c>true</c> if this instance can search; otherwise, <c>false</c>.</value>
public bool CanSearch { get; set; }
public List<ChannelMediaType> MediaTypes { get; set; }
public List<ChannelMediaContentType> ContentTypes { get; set; }
/// <summary>
/// Represents the maximum number of records the channel allows retrieving at a time
/// </summary>
public int? MaxPageSize { get; set; }
public ChannelInfo()
{
MediaTypes = new List<ChannelMediaType>();
ContentTypes = new List<ChannelMediaContentType>();
}
/// <value>The features.</value>
public ChannelFeatures Features { get; set; }
}
}

View File

@ -45,4 +45,5 @@ namespace MediaBrowser.Model.Channels
SortBy = new string[] { };
}
}
}

View File

@ -170,8 +170,8 @@ namespace MediaBrowser.Model.Configuration
public bool EnableTmdbUpdates { get; set; }
public bool EnableFanArtUpdates { get; set; }
public bool RequireManualLoginForMobileApps { get; set; }
public bool RequireManualLoginForOtherApps { get; set; }
public bool RequireMobileManualLogin { get; set; }
public bool RequireNonMobileManualLogin { get; set; }
/// <summary>
/// Gets or sets the image saving convention.
@ -223,6 +223,9 @@ namespace MediaBrowser.Model.Configuration
public SubtitleOptions SubtitleOptions { get; set; }
[Obsolete]
public string[] ManualLoginClients { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary>
@ -263,6 +266,8 @@ namespace MediaBrowser.Model.Configuration
SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
SortRemoveWords = new[] { "the", "a", "an" };
ManualLoginClients = new string[] { };
SeasonZeroDisplayName = "Specials";
LiveTvOptions = new LiveTvOptions();

View File

@ -17,6 +17,18 @@ namespace MediaBrowser.Model.LiveTv
/// </summary>
/// <value><c>null</c> if [is favorite] contains no value, <c>true</c> if [is favorite]; otherwise, <c>false</c>.</value>
public bool? IsFavorite { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is liked.
/// </summary>
/// <value><c>null</c> if [is liked] contains no value, <c>true</c> if [is liked]; otherwise, <c>false</c>.</value>
public bool? IsLiked { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is disliked.
/// </summary>
/// <value><c>null</c> if [is disliked] contains no value, <c>true</c> if [is disliked]; otherwise, <c>false</c>.</value>
public bool? IsDisliked { get; set; }
/// <summary>
/// Gets or sets the user identifier.

View File

@ -59,6 +59,7 @@
<Compile Include="ApiClient\IServerEvents.cs" />
<Compile Include="ApiClient\GeneralCommandEventArgs.cs" />
<Compile Include="ApiClient\SessionUpdatesEventArgs.cs" />
<Compile Include="Channels\ChannelFeatures.cs" />
<Compile Include="Channels\ChannelInfo.cs" />
<Compile Include="Channels\ChannelItemQuery.cs" />
<Compile Include="Channels\ChannelMediaContentType.cs" />

View File

@ -609,10 +609,14 @@ namespace MediaBrowser.Providers.TV
var roles = nameGroup.Count() > 1 ? nameGroup[1].Trim() : null;
if (roles != null)
roles = roles.EndsWith(")") ? roles.Substring(0, roles.Length - 1) : roles;
return new PersonInfo { Type = PersonType.GuestStar, Name = name, Role = roles };
}))
{
item.AddPerson(person);
if (!string.IsNullOrWhiteSpace(person.Name))
{
item.AddPerson(person);
}
}
}

View File

@ -215,9 +215,7 @@ namespace MediaBrowser.Server.Implementations.Channels
isNew = true;
}
var info = channelInfo.GetChannelInfo();
item.HomePageUrl = info.HomePageUrl;
item.HomePageUrl = channelInfo.HomePageUrl;
item.OriginalChannelName = channelInfo.Name;
if (string.IsNullOrEmpty(item.Name))
@ -258,7 +256,7 @@ namespace MediaBrowser.Server.Implementations.Channels
// Find the corresponding channel provider plugin
var channelProvider = GetChannelProvider(channel);
var channelInfo = channelProvider.GetChannelInfo();
var channelInfo = channelProvider.GetChannelFeatures();
int? providerStartIndex = null;
int? providerLimit = null;
@ -448,7 +446,7 @@ namespace MediaBrowser.Server.Implementations.Channels
{
// Increment this as needed to force new downloads
// Incorporate Name because it's being used to convert channel entity to provider
return externalId + (channelProvider.DataVersion ?? string.Empty) + (channelProvider.Name ?? string.Empty) + "12";
return externalId + (channelProvider.DataVersion ?? string.Empty) + (channelProvider.Name ?? string.Empty) + "13";
}
private async Task<BaseItem> GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Channel internalChannel, CancellationToken cancellationToken)
@ -473,7 +471,7 @@ namespace MediaBrowser.Server.Implementations.Channels
}
else if (info.MediaType == ChannelMediaType.Audio)
{
id = idToHash.GetMBId(typeof(ChannelFolderItem));
id = idToHash.GetMBId(typeof(ChannelAudioItem));
item = _libraryManager.GetItemById(id) as ChannelAudioItem;

View File

@ -64,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.Dto
// always load the most suitable full subtitles
stream = full.FirstOrDefault();
}
// load forced subs if we have found no suitable full subtitles
stream = stream ?? forced.FirstOrDefault();
@ -86,17 +86,13 @@ namespace MediaBrowser.Server.Implementations.Dto
var orderStreams = streams
.Where(i => i.Type == type);
if (languagePreferences.Count == 0)
{
return orderStreams.OrderBy(i => i.IsDefault)
.ThenBy(i => i.Index)
.ToList();
}
// Give some preferance to external text subs for better performance
return orderStreams.OrderBy(i => languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase)))
.ThenBy(i => i.IsDefault)
.ThenBy(i => i.Index)
.ToList();
.ThenBy(i => i.IsDefault)
.ThenBy(i => !i.IsGraphicalSubtitleStream)
.ThenBy(i => i.IsExternal)
.ThenBy(i => i.Index)
.ToList();
}
}
}

View File

@ -150,6 +150,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv
channels = channels
.Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite == val);
}
if (query.IsLiked.HasValue)
{
var val = query.IsLiked.Value;
channels = channels
.Where(i =>
{
var likes = _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Likes;
return likes.HasValue && likes.Value == val;
});
}
if (query.IsDisliked.HasValue)
{
var val = query.IsDisliked.Value;
channels = channels
.Where(i =>
{
var likes = _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Likes;
return likes.HasValue && likes.Value != val;
});
}
}
channels = channels.OrderBy(i =>

View File

@ -785,5 +785,6 @@
"HeaderLiveTv": "Live TV",
"HeaderReports": "Reports",
"HeaderMetadataManager": "Metadata Manager",
"HeaderPreferences": "Preferences"
"HeaderPreferences": "Preferences",
"MessageLoadingChannels": "Loading channel content..."
}

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.374</version>
<version>3.0.378</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.374" />
<dependency id="MediaBrowser.Common" version="3.0.378" />
<dependency id="NLog" version="2.1.0" />
<dependency id="SimpleInjector" version="2.5.0" />
<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.374</version>
<version>3.0.378</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/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.374</version>
<version>3.0.378</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.374" />
<dependency id="MediaBrowser.Common" version="3.0.378" />
</dependencies>
</metadata>
<files>