Merge pull request #1888 from MediaBrowser/dev

Dev
pull/702/head
Luke 8 years ago committed by GitHub
commit d62fe71135

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

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

@ -2,7 +2,7 @@
<packages> <packages>
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" /> <package id="CommonIO" version="1.0.0.9" targetFramework="net45" />
<package id="morelinq" version="1.4.0" 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="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> </packages>

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

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

@ -99,6 +99,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
_hasExternalEncoder = hasExternalEncoder; _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() public void Init()
{ {
ConfigureEncoderPaths(); ConfigureEncoderPaths();
@ -115,10 +148,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
var valueToSave = FFMpegPath; var valueToSave = FFMpegPath;
// if using system variable, don't save this. if (!string.IsNullOrWhiteSpace(valueToSave))
if (string.Equals(valueToSave, "ffmpeg", StringComparison.OrdinalIgnoreCase))
{ {
valueToSave = null; // if using system variable, don't save this.
if (IsSystemInstalledPath(valueToSave))
{
valueToSave = null;
}
} }
if (!string.Equals(valueToSave, appPath, StringComparison.Ordinal)) 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))
{
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 ResourceNotFoundException(); throw new ArgumentException("Unexpected pathType value");
} }
var newPaths = GetEncoderPaths(path);
if (string.IsNullOrWhiteSpace(newPaths.Item1)) if (string.IsNullOrWhiteSpace(newPaths.Item1))
{ {
throw new ResourceNotFoundException("ffmpeg not found"); 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 // 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 // If that doesn't pan out, then do a recursive search

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

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

@ -2663,6 +2663,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@SlugName", DbType.String).Value = query.SlugName; 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)) if (!string.IsNullOrWhiteSpace(query.Name))
{ {
whereClauses.Add("CleanName=@Name"); whereClauses.Add("CleanName=@Name");
@ -3773,7 +3779,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
else 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) var outerQuery = new InternalItemsQuery(query.User)
@ -3855,7 +3862,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult) ? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
: CommandBehavior.SequentialAccess; : CommandBehavior.SequentialAccess;
//Logger.Debug("GetItemValues: " + cmd.CommandText); Logger.Debug("GetItemValues: " + cmd.CommandText);
using (var reader = cmd.ExecuteReader(commandBehavior)) using (var reader = cmd.ExecuteReader(commandBehavior))
{ {

@ -107,7 +107,6 @@ namespace MediaBrowser.Server.Implementations.TV
var currentUser = user; var currentUser = user;
return series return series
.AsParallel()
.Select(i => GetNextUp(i, currentUser)) .Select(i => GetNextUp(i, currentUser))
// Include if an episode was found, and either the series is not unwatched or the specific series was requested // 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))) .Where(i => i.Item1 != null && (!i.Item3 || !string.IsNullOrWhiteSpace(request.SeriesId)))
@ -124,67 +123,32 @@ namespace MediaBrowser.Server.Implementations.TV
/// <returns>Task{Episode}.</returns> /// <returns>Task{Episode}.</returns>
private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user) private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user)
{ {
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
IncludeItemTypes = new[] { typeof(Episode).Name }, IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName }, SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Ascending, SortOrder = SortOrder.Descending,
IsPlayed = true,
Limit = 1, Limit = 1,
IsPlayed = false,
IsVirtualItem = false, IsVirtualItem = false,
ParentIndexNumberNotEquals = 0 ParentIndexNumberNotEquals = 0
}).Cast<Episode>().FirstOrDefault(); }).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) var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
IncludeItemTypes = new[] { typeof(Episode).Name }, IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.DatePlayed }, SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Descending, SortOrder = SortOrder.Ascending,
Limit = 1, Limit = 1,
IsPlayed = false,
IsVirtualItem = false, IsVirtualItem = false,
ParentIndexNumberNotEquals = 0 ParentIndexNumberNotEquals = 0,
MinSortName = lastWatchedEpisode == null ? null : lastWatchedEpisode.SortName
}).FirstOrDefault(); }).Cast<Episode>().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) if (lastWatchedEpisode != null)
{ {

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" /> <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="ini-parser" version="2.3.0" targetFramework="net45" />
<package id="Interfaces.IO" version="1.0.0.5" 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="MediaBrowser.Naming" version="1.0.0.52" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net45" /> <package id="Mono.Nat" version="1.2.24.0" targetFramework="net45" />
<package id="morelinq" version="1.4.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="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" /> <package id="SocketHttpListener" version="1.0.0.30" targetFramework="net45" />
</packages> </packages>

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

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

Loading…
Cancel
Save