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) public object Get(GetMediaInfoImages request)
{ {
return ToOptimizedResult(GetImageList(_appPaths.MediaInfoImagesPath)); return ToOptimizedResult(GetImageList(_appPaths.MediaInfoImagesPath, true));
} }
public object Get(GetRatingImages request) public object Get(GetRatingImages request)
{ {
return ToOptimizedResult(GetImageList(_appPaths.RatingsPath)); return ToOptimizedResult(GetImageList(_appPaths.RatingsPath, true));
} }
public object Get(GetGeneralImages request) 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 try
{ {
@ -142,7 +142,7 @@ namespace MediaBrowser.Api.Images
{ {
Name = Path.GetFileNameWithoutExtension(i.FullName), Name = Path.GetFileNameWithoutExtension(i.FullName),
FileLength = i.Length, FileLength = i.Length,
Theme = GetThemeName(i.FullName, path), Theme = supportsThemes ? GetThemeName(i.FullName, path) : null,
Format = i.Extension.ToLower().TrimStart('.') Format = i.Extension.ToLower().TrimStart('.')
}) })
.OrderBy(i => i.Name) .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")] [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; } 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")] [Route("/LiveTv/Channels/{Id}", "GET", Summary = "Gets a live tv channel")]
@ -294,7 +300,9 @@ namespace MediaBrowser.Api.LiveTv
UserId = request.UserId, UserId = request.UserId,
StartIndex = request.StartIndex, StartIndex = request.StartIndex,
Limit = request.Limit, Limit = request.Limit,
IsFavorite = request.IsFavorite IsFavorite = request.IsFavorite,
IsLiked = request.IsLiked,
IsDisliked = request.IsDisliked
}, CancellationToken.None).Result; }, CancellationToken.None).Result;

View File

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

View File

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

View File

@ -77,10 +77,5 @@ namespace MediaBrowser.Controller.Channels
return base.LocationType; 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> /// <value>The data version.</value>
string DataVersion { get; } string DataVersion { get; }
/// <summary>
/// Gets the home page URL.
/// </summary>
/// <value>The home page URL.</value>
string HomePageUrl { get; }
/// <summary> /// <summary>
/// Gets the channel information. /// Gets the channel information.
/// </summary> /// </summary>
/// <returns>ChannelInfo.</returns> /// <returns>ChannelFeatures.</returns>
ChannelInfo GetChannelInfo(); ChannelFeatures GetChannelFeatures();
/// <summary> /// <summary>
/// Determines whether [is enabled for] [the specified user]. /// Determines whether [is enabled for] [the specified user].
@ -52,6 +58,14 @@ namespace MediaBrowser.Controller.Channels
/// <returns>Task{IEnumerable{ChannelItem}}.</returns> /// <returns>Task{IEnumerable{ChannelItem}}.</returns>
Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken); 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> /// <summary>
/// Gets the channel image. /// Gets the channel image.
/// </summary> /// </summary>

View File

@ -12,4 +12,14 @@ namespace MediaBrowser.Controller.Channels
public int? Limit { get; set; } 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"> <Compile Include="..\MediaBrowser.Model\ApiClient\SessionUpdatesEventArgs.cs">
<Link>ApiClient\SessionUpdatesEventArgs.cs</Link> <Link>ApiClient\SessionUpdatesEventArgs.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Channels\ChannelFeatures.cs">
<Link>Channels\ChannelFeatures.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Channels\ChannelInfo.cs"> <Compile Include="..\MediaBrowser.Model\Channels\ChannelInfo.cs">
<Link>Channels\ChannelInfo.cs</Link> <Link>Channels\ChannelInfo.cs</Link>
</Compile> </Compile>

View File

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

View File

@ -59,6 +59,30 @@ namespace MediaBrowser.Model.ApiClient
Task<T> GetAsync<T>(string url, CancellationToken cancellationToken) Task<T> GetAsync<T>(string url, CancellationToken cancellationToken)
where T : class; 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> /// <summary>
/// Reports the capabilities. /// Reports the capabilities.
/// </summary> /// </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 namespace MediaBrowser.Model.Channels
{ {
public class ChannelInfo public class ChannelInfo
{ {
/// <summary> /// <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> /// </summary>
/// <value>The home page URL.</value> /// <value>The home page URL.</value>
public string HomePageUrl { get; set; } public string HomePageUrl { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance can search. /// Gets or sets the features.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance can search; otherwise, <c>false</c>.</value> /// <value>The features.</value>
public bool CanSearch { get; set; } public ChannelFeatures Features { 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>();
} }
}
} }

View File

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

View File

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

View File

@ -18,6 +18,18 @@ namespace MediaBrowser.Model.LiveTv
/// <value><c>null</c> if [is favorite] contains no value, <c>true</c> if [is favorite]; otherwise, <c>false</c>.</value> /// <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; } 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> /// <summary>
/// Gets or sets the user identifier. /// Gets or sets the user identifier.
/// </summary> /// </summary>

View File

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

View File

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

View File

@ -215,9 +215,7 @@ namespace MediaBrowser.Server.Implementations.Channels
isNew = true; isNew = true;
} }
var info = channelInfo.GetChannelInfo(); item.HomePageUrl = channelInfo.HomePageUrl;
item.HomePageUrl = info.HomePageUrl;
item.OriginalChannelName = channelInfo.Name; item.OriginalChannelName = channelInfo.Name;
if (string.IsNullOrEmpty(item.Name)) if (string.IsNullOrEmpty(item.Name))
@ -258,7 +256,7 @@ namespace MediaBrowser.Server.Implementations.Channels
// Find the corresponding channel provider plugin // Find the corresponding channel provider plugin
var channelProvider = GetChannelProvider(channel); var channelProvider = GetChannelProvider(channel);
var channelInfo = channelProvider.GetChannelInfo(); var channelInfo = channelProvider.GetChannelFeatures();
int? providerStartIndex = null; int? providerStartIndex = null;
int? providerLimit = null; int? providerLimit = null;
@ -448,7 +446,7 @@ namespace MediaBrowser.Server.Implementations.Channels
{ {
// Increment this as needed to force new downloads // Increment this as needed to force new downloads
// Incorporate Name because it's being used to convert channel entity to provider // 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) 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) else if (info.MediaType == ChannelMediaType.Audio)
{ {
id = idToHash.GetMBId(typeof(ChannelFolderItem)); id = idToHash.GetMBId(typeof(ChannelAudioItem));
item = _libraryManager.GetItemById(id) as ChannelAudioItem; item = _libraryManager.GetItemById(id) as ChannelAudioItem;

View File

@ -86,15 +86,11 @@ namespace MediaBrowser.Server.Implementations.Dto
var orderStreams = streams var orderStreams = streams
.Where(i => i.Type == type); .Where(i => i.Type == type);
if (languagePreferences.Count == 0) // Give some preferance to external text subs for better performance
{
return orderStreams.OrderBy(i => i.IsDefault)
.ThenBy(i => i.Index)
.ToList();
}
return orderStreams.OrderBy(i => languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase))) return orderStreams.OrderBy(i => languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase)))
.ThenBy(i => i.IsDefault) .ThenBy(i => i.IsDefault)
.ThenBy(i => !i.IsGraphicalSubtitleStream)
.ThenBy(i => i.IsExternal)
.ThenBy(i => i.Index) .ThenBy(i => i.Index)
.ToList(); .ToList();
} }

View File

@ -150,6 +150,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv
channels = channels channels = channels
.Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite == val); .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 => channels = channels.OrderBy(i =>

View File

@ -785,5 +785,6 @@
"HeaderLiveTv": "Live TV", "HeaderLiveTv": "Live TV",
"HeaderReports": "Reports", "HeaderReports": "Reports",
"HeaderMetadataManager": "Metadata Manager", "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"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.374</version> <version>3.0.378</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <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> <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> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <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="NLog" version="2.1.0" />
<dependency id="SimpleInjector" version="2.5.0" /> <dependency id="SimpleInjector" version="2.5.0" />
<dependency id="sharpcompress" version="0.10.2" /> <dependency id="sharpcompress" version="0.10.2" />

View File

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

View File

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