Merge pull request #1888 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-06-29 13:59:44 -04:00 committed by GitHub
commit d62fe71135
13 changed files with 119 additions and 88 deletions

View File

@ -79,6 +79,8 @@ namespace MediaBrowser.Api
{
[ApiMember(Name = "Path", Description = "Path", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Path { get; set; }
[ApiMember(Name = "PathType", Description = "PathType", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string PathType { get; set; }
}
public class ConfigurationService : BaseApiService
@ -110,7 +112,7 @@ namespace MediaBrowser.Api
public void Post(UpdateMediaEncoderPath request)
{
var task = _mediaEncoder.UpdateEncoderPath(request.Path);
var task = _mediaEncoder.UpdateEncoderPath(request.Path, request.PathType);
Task.WaitAll(task);
}

View File

@ -55,7 +55,7 @@
<HintPath>..\packages\morelinq.1.4.0\lib\net35\MoreLinq.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.3.4\lib\net45\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.3.5\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Patterns.Logging">
@ -65,8 +65,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="SimpleInjector, Version=3.1.5.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.1.5\lib\net45\SimpleInjector.dll</HintPath>
<Reference Include="SimpleInjector, Version=3.2.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.2.0\lib\net45\SimpleInjector.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />

View File

@ -2,7 +2,7 @@
<packages>
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" />
<package id="morelinq" version="1.4.0" targetFramework="net45" />
<package id="NLog" version="4.3.4" targetFramework="net45" />
<package id="NLog" version="4.3.5" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
<package id="SimpleInjector" version="3.1.5" targetFramework="net45" />
<package id="SimpleInjector" version="3.2.0" targetFramework="net45" />
</packages>

View File

@ -46,6 +46,7 @@ namespace MediaBrowser.Controller.Entities
public string NameStartsWith { get; set; }
public string NameLessThan { get; set; }
public string NameContains { get; set; }
public string MinSortName { get; set; }
public string PresentationUniqueKey { get; set; }
public string Path { get; set; }

View File

@ -13,6 +13,8 @@ namespace MediaBrowser.Controller.MediaEncoding
/// </summary>
public interface IMediaEncoder : ITranscoderSupport
{
string EncoderLocationType { get; }
/// <summary>
/// Gets the encoder path.
/// </summary>
@ -60,12 +62,12 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <param name="maxWidth">The maximum width.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task ExtractVideoImagesOnInterval(string[] inputFiles,
MediaProtocol protocol,
Video3DFormat? threedFormat,
TimeSpan interval,
string targetDirectory,
string filenamePrefix,
Task ExtractVideoImagesOnInterval(string[] inputFiles,
MediaProtocol protocol,
Video3DFormat? threedFormat,
TimeSpan interval,
string targetDirectory,
string filenamePrefix,
int? maxWidth,
CancellationToken cancellationToken);
@ -131,6 +133,6 @@ namespace MediaBrowser.Controller.MediaEncoding
void Init();
Task UpdateEncoderPath(string path);
Task UpdateEncoderPath(string path, string pathType);
}
}

View File

@ -99,6 +99,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
_hasExternalEncoder = hasExternalEncoder;
}
public string EncoderLocationType
{
get
{
if (_hasExternalEncoder)
{
return "External";
}
if (string.IsNullOrWhiteSpace(FFMpegPath))
{
return null;
}
if (IsSystemInstalledPath(FFMpegPath))
{
return "System";
}
return "Custom";
}
}
private bool IsSystemInstalledPath(string path)
{
if (path.IndexOf("/", StringComparison.Ordinal) == -1 && path.IndexOf("\\", StringComparison.Ordinal) == -1)
{
return true;
}
return false;
}
public void Init()
{
ConfigureEncoderPaths();
@ -115,10 +148,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
var valueToSave = FFMpegPath;
// if using system variable, don't save this.
if (string.Equals(valueToSave, "ffmpeg", StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(valueToSave))
{
valueToSave = null;
// if using system variable, don't save this.
if (IsSystemInstalledPath(valueToSave))
{
valueToSave = null;
}
}
if (!string.Equals(valueToSave, appPath, StringComparison.Ordinal))
@ -128,19 +164,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
public async Task UpdateEncoderPath(string path)
public async Task UpdateEncoderPath(string path, string pathType)
{
if (string.IsNullOrWhiteSpace(path))
if (_hasExternalEncoder)
{
throw new ArgumentNullException("path");
return;
}
if (!File.Exists(path) && !Directory.Exists(path))
Tuple<string, string> newPaths;
if (string.Equals(pathType, "system", StringComparison.OrdinalIgnoreCase))
{
throw new ResourceNotFoundException();
path = "ffmpeg";
newPaths = TestForInstalledVersions();
}
else if (string.Equals(pathType, "custom", StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException("path");
}
if (!File.Exists(path) && !Directory.Exists(path))
{
throw new ResourceNotFoundException();
}
newPaths = GetEncoderPaths(path);
}
else
{
throw new ArgumentException("Unexpected pathType value");
}
var newPaths = GetEncoderPaths(path);
if (string.IsNullOrWhiteSpace(newPaths.Item1))
{
throw new ResourceNotFoundException("ffmpeg not found");
@ -252,7 +308,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
private Tuple<string,string> GetPathsFromDirectory(string path)
private Tuple<string, string> GetPathsFromDirectory(string path)
{
// Since we can't predict the file extension, first try directly within the folder
// If that doesn't pan out, then do a recursive search

View File

@ -152,7 +152,7 @@ namespace MediaBrowser.Model.System
/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
public bool SupportsAutoRunAtStartup { get; set; }
public bool HasExternalEncoder { get; set; }
public string EncoderLocationType { get; set; }
public Architecture SystemArchitecture { get; set; }

View File

@ -46,7 +46,7 @@
<HintPath>..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll</HintPath>
</Reference>
<Reference Include="Emby.XmlTv, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.0.53\lib\net45\Emby.XmlTv.dll</HintPath>
<HintPath>..\packages\Emby.XmlTv.1.0.0.54\lib\net45\Emby.XmlTv.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="INIFileParser, Version=2.3.0.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL">
@ -69,8 +69,8 @@
<Reference Include="ServiceStack.Api.Swagger">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath>
</Reference>
<Reference Include="SimpleInjector, Version=3.1.5.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.1.5\lib\net45\SimpleInjector.dll</HintPath>
<Reference Include="SimpleInjector, Version=3.2.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.2.0\lib\net45\SimpleInjector.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SocketHttpListener, Version=1.0.5955.1537, Culture=neutral, processorArchitecture=MSIL">

View File

@ -2663,6 +2663,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@SlugName", DbType.String).Value = query.SlugName;
}
if (!string.IsNullOrWhiteSpace(query.MinSortName))
{
whereClauses.Add("SortName>=@MinSortName");
cmd.Parameters.Add(cmd, "@MinSortName", DbType.String).Value = query.MinSortName;
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
whereClauses.Add("CleanName=@Name");
@ -3773,7 +3779,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
else
{
whereText += " And itemTypes not null";
//whereText += " And itemTypes not null";
whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
}
var outerQuery = new InternalItemsQuery(query.User)
@ -3855,7 +3862,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
: CommandBehavior.SequentialAccess;
//Logger.Debug("GetItemValues: " + cmd.CommandText);
Logger.Debug("GetItemValues: " + cmd.CommandText);
using (var reader = cmd.ExecuteReader(commandBehavior))
{

View File

@ -107,7 +107,6 @@ namespace MediaBrowser.Server.Implementations.TV
var currentUser = user;
return series
.AsParallel()
.Select(i => GetNextUp(i, currentUser))
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
.Where(i => i.Item1 != null && (!i.Item3 || !string.IsNullOrWhiteSpace(request.SeriesId)))
@ -124,6 +123,19 @@ namespace MediaBrowser.Server.Implementations.TV
/// <returns>Task{Episode}.</returns>
private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user)
{
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Descending,
IsPlayed = true,
Limit = 1,
IsVirtualItem = false,
ParentIndexNumberNotEquals = 0
}).FirstOrDefault();
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
@ -133,59 +145,11 @@ namespace MediaBrowser.Server.Implementations.TV
Limit = 1,
IsPlayed = false,
IsVirtualItem = false,
ParentIndexNumberNotEquals = 0
ParentIndexNumberNotEquals = 0,
MinSortName = lastWatchedEpisode == null ? null : lastWatchedEpisode.SortName
}).Cast<Episode>().FirstOrDefault();
// series is fully played
if (firstUnwatchedEpisode == null)
{
return new Tuple<Episode, DateTime, bool>(null, DateTime.MinValue, true);
}
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.DatePlayed },
SortOrder = SortOrder.Descending,
Limit = 1,
IsVirtualItem = false,
ParentIndexNumberNotEquals = 0
}).FirstOrDefault();
//// Get them in display order, then reverse
//var allEpisodes = series.GetEpisodes(user, false, false)
// .Where(i => !i.ParentIndexNumber.HasValue || i.ParentIndexNumber.Value != 0)
// .Reverse()
// .ToList();
//Episode lastWatched = null;
//var lastWatchedDate = DateTime.MinValue;
//Episode nextUp = null;
//// Go back starting with the most recent episodes
//foreach (var episode in allEpisodes)
//{
// var userData = _userDataManager.GetUserData(user, episode);
// if (userData.Played)
// {
// if (lastWatched != null || nextUp == null)
// {
// break;
// }
// lastWatched = episode;
// lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue;
// }
// else
// {
// nextUp = episode;
// }
//}
if (lastWatchedEpisode != null)
{
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" />
<package id="Emby.XmlTv" version="1.0.0.53" targetFramework="net45" />
<package id="Emby.XmlTv" version="1.0.0.54" targetFramework="net45" />
<package id="ini-parser" version="2.3.0" targetFramework="net45" />
<package id="Interfaces.IO" version="1.0.0.5" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.52" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net45" />
<package id="morelinq" version="1.4.0" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
<package id="SimpleInjector" version="3.1.5" targetFramework="net45" />
<package id="SimpleInjector" version="3.2.0" targetFramework="net45" />
<package id="SocketHttpListener" version="1.0.0.30" targetFramework="net45" />
</packages>

View File

@ -658,13 +658,13 @@ namespace MediaBrowser.Server.Startup.Common
encoderPath = info.EncoderPath;
probePath = info.ProbePath;
_hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase);
var hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase);
var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
JsonSerializer,
encoderPath,
probePath,
_hasExternalEncoder,
hasExternalEncoder,
ServerConfigurationManager,
FileSystemManager,
LiveTvManager,
@ -1100,7 +1100,6 @@ namespace MediaBrowser.Server.Startup.Common
}
}
private bool _hasExternalEncoder;
/// <summary>
/// Gets the system status.
/// </summary>
@ -1141,7 +1140,7 @@ namespace MediaBrowser.Server.Startup.Common
ServerName = FriendlyName,
LocalAddress = localAddress,
SupportsLibraryMonitor = SupportsLibraryMonitor,
HasExternalEncoder = _hasExternalEncoder,
EncoderLocationType = MediaEncoder.EncoderLocationType,
SystemArchitecture = NativeApp.Environment.SystemArchitecture
};
}

View File

@ -13,8 +13,8 @@
<copyright>Copyright © Emby 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.652" />
<dependency id="NLog" version="4.3.4" />
<dependency id="SimpleInjector" version="3.1.5" />
<dependency id="NLog" version="4.3.5" />
<dependency id="SimpleInjector" version="3.2.0" />
</dependencies>
</metadata>
<files>