add query by PersonId
This commit is contained in:
parent
79d2f7efd7
commit
1fb24df504
|
@ -209,14 +209,14 @@ namespace MediaBrowser.Api.Playback.Dash
|
||||||
ApiEntryPoint.Instance.KillTranscodingJobs(j => j.Type == TranscodingJobType && string.Equals(j.DeviceId, deviceId, StringComparison.OrdinalIgnoreCase), p => !string.Equals(p, playlistPath, StringComparison.OrdinalIgnoreCase));
|
ApiEntryPoint.Instance.KillTranscodingJobs(j => j.Type == TranscodingJobType && string.Equals(j.DeviceId, deviceId, StringComparison.OrdinalIgnoreCase), p => !string.Equals(p, playlistPath, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
private long GetPositionTicks(StreamState state, int segmentIndex)
|
private long GetPositionTicks(StreamState state, int requestedIndex)
|
||||||
{
|
{
|
||||||
if (segmentIndex <= 1)
|
if (requestedIndex <= 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var startSeconds = segmentIndex * state.SegmentLength;
|
var startSeconds = requestedIndex * state.SegmentLength;
|
||||||
return TimeSpan.FromSeconds(startSeconds).Ticks;
|
return TimeSpan.FromSeconds(startSeconds).Ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,6 +291,13 @@ namespace MediaBrowser.Api.Playback.Dash
|
||||||
|
|
||||||
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
|
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
|
||||||
{
|
{
|
||||||
|
var job = ApiEntryPoint.Instance.GetTranscodingJob(playlist, TranscodingJobType);
|
||||||
|
|
||||||
|
if (job == null || job.HasExited)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var file = GetLastTranscodingFiles(playlist, segmentExtension, FileSystem, 1).FirstOrDefault();
|
var file = GetLastTranscodingFiles(playlist, segmentExtension, FileSystem, 1).FirstOrDefault();
|
||||||
|
|
||||||
if (file == null)
|
if (file == null)
|
||||||
|
@ -341,11 +348,11 @@ namespace MediaBrowser.Api.Playback.Dash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FindSegment(string playlist, string representationId, string segmentExtension, int index)
|
private string FindSegment(string playlist, string representationId, string segmentExtension, int requestedIndex)
|
||||||
{
|
{
|
||||||
var folder = Path.GetDirectoryName(playlist);
|
var folder = Path.GetDirectoryName(playlist);
|
||||||
|
|
||||||
if (index == -1)
|
if (requestedIndex == -1)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(folder, "0", "stream" + representationId + "-" + "init" + segmentExtension);
|
var path = Path.Combine(folder, "0", "stream" + representationId + "-" + "init" + segmentExtension);
|
||||||
return File.Exists(path) ? path : null;
|
return File.Exists(path) ? path : null;
|
||||||
|
@ -355,12 +362,16 @@ namespace MediaBrowser.Api.Playback.Dash
|
||||||
{
|
{
|
||||||
foreach (var subfolder in new DirectoryInfo(folder).EnumerateDirectories().ToList())
|
foreach (var subfolder in new DirectoryInfo(folder).EnumerateDirectories().ToList())
|
||||||
{
|
{
|
||||||
|
var subfolderName = Path.GetFileNameWithoutExtension(subfolder.FullName);
|
||||||
int startNumber;
|
int startNumber;
|
||||||
if (int.TryParse(Path.GetFileNameWithoutExtension(subfolder.FullName), NumberStyles.Any, UsCulture, out startNumber))
|
if (int.TryParse(subfolderName, NumberStyles.Any, UsCulture, out startNumber))
|
||||||
{
|
{
|
||||||
var segmentIndex = index - startNumber + 1;
|
var segmentIndex = requestedIndex - startNumber + 1;
|
||||||
var path = Path.Combine(folder, "0", "stream" + representationId + "-" + segmentIndex.ToString("00000", CultureInfo.InvariantCulture) + segmentExtension);
|
var path = Path.Combine(folder, subfolderName, "stream" + representationId + "-" + segmentIndex.ToString("00000", CultureInfo.InvariantCulture) + segmentExtension);
|
||||||
return File.Exists(path) ? path : null;
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,13 +100,13 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
var cancellationTokenSource = new CancellationTokenSource();
|
var cancellationTokenSource = new CancellationTokenSource();
|
||||||
var cancellationToken = cancellationTokenSource.Token;
|
var cancellationToken = cancellationTokenSource.Token;
|
||||||
|
|
||||||
var index = int.Parse(segmentId, NumberStyles.Integer, UsCulture);
|
var requestedIndex = int.Parse(segmentId, NumberStyles.Integer, UsCulture);
|
||||||
|
|
||||||
var state = await GetState(request, cancellationToken).ConfigureAwait(false);
|
var state = await GetState(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var playlistPath = Path.ChangeExtension(state.OutputFilePath, ".m3u8");
|
var playlistPath = Path.ChangeExtension(state.OutputFilePath, ".m3u8");
|
||||||
|
|
||||||
var segmentPath = GetSegmentPath(playlistPath, index);
|
var segmentPath = GetSegmentPath(playlistPath, requestedIndex);
|
||||||
var segmentLength = state.SegmentLength;
|
var segmentLength = state.SegmentLength;
|
||||||
|
|
||||||
var segmentExtension = GetSegmentFileExtension(state);
|
var segmentExtension = GetSegmentFileExtension(state);
|
||||||
|
@ -116,7 +116,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
if (File.Exists(segmentPath))
|
if (File.Exists(segmentPath))
|
||||||
{
|
{
|
||||||
job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
||||||
return await GetSegmentResult(playlistPath, segmentPath, index, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ApiEntryPoint.Instance.TranscodingStartLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
|
await ApiEntryPoint.Instance.TranscodingStartLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
|
||||||
|
@ -125,13 +125,13 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
if (File.Exists(segmentPath))
|
if (File.Exists(segmentPath))
|
||||||
{
|
{
|
||||||
job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
||||||
return await GetSegmentResult(playlistPath, segmentPath, index, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, segmentExtension);
|
var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, segmentExtension);
|
||||||
var segmentGapRequiringTranscodingChange = 24/state.SegmentLength;
|
var segmentGapRequiringTranscodingChange = 24/state.SegmentLength;
|
||||||
if (currentTranscodingIndex == null || index < currentTranscodingIndex.Value || (index - currentTranscodingIndex.Value) > segmentGapRequiringTranscodingChange)
|
if (currentTranscodingIndex == null || requestedIndex < currentTranscodingIndex.Value || (requestedIndex - currentTranscodingIndex.Value) > segmentGapRequiringTranscodingChange)
|
||||||
{
|
{
|
||||||
// If the playlist doesn't already exist, startup ffmpeg
|
// If the playlist doesn't already exist, startup ffmpeg
|
||||||
try
|
try
|
||||||
|
@ -143,8 +143,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
DeleteLastFile(playlistPath, segmentExtension, 0);
|
DeleteLastFile(playlistPath, segmentExtension, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var startSeconds = index * state.SegmentLength;
|
request.StartTimeTicks = GetSeekPositionTicks(state, requestedIndex);
|
||||||
request.StartTimeTicks = TimeSpan.FromSeconds(startSeconds).Ticks;
|
|
||||||
|
|
||||||
job = await StartFfMpeg(state, playlistPath, cancellationTokenSource).ConfigureAwait(false);
|
job = await StartFfMpeg(state, playlistPath, cancellationTokenSource).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -171,11 +170,26 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
Logger.Info("returning {0}", segmentPath);
|
Logger.Info("returning {0}", segmentPath);
|
||||||
job = job ?? ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
job = job ?? ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
||||||
return await GetSegmentResult(playlistPath, segmentPath, index, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long GetSeekPositionTicks(StreamState state, int requestedIndex)
|
||||||
|
{
|
||||||
|
var startSeconds = requestedIndex * state.SegmentLength;
|
||||||
|
var position = TimeSpan.FromSeconds(startSeconds).Ticks;
|
||||||
|
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
|
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
|
||||||
{
|
{
|
||||||
|
var job = ApiEntryPoint.Instance.GetTranscodingJob(playlist, TranscodingJobType);
|
||||||
|
|
||||||
|
if (job == null || job.HasExited)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var file = GetLastTranscodingFile(playlist, segmentExtension, FileSystem);
|
var file = GetLastTranscodingFile(playlist, segmentExtension, FileSystem);
|
||||||
|
|
||||||
if (file == null)
|
if (file == null)
|
||||||
|
|
|
@ -39,6 +39,9 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
[ApiMember(Name = "Person", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "Person", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string Person { get; set; }
|
public string Person { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "PersonIds", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
|
public string PersonIds { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If the Person filter is used, this can also be used to restrict to a specific person type
|
/// If the Person filter is used, this can also be used to restrict to a specific person type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -244,6 +247,11 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string[] GetPersonIds()
|
||||||
|
{
|
||||||
|
return (PersonIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
}
|
||||||
|
|
||||||
public VideoType[] GetVideoTypes()
|
public VideoType[] GetVideoTypes()
|
||||||
{
|
{
|
||||||
var val = VideoTypes;
|
var val = VideoTypes;
|
||||||
|
@ -477,6 +485,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
Studios = request.GetStudios(),
|
Studios = request.GetStudios(),
|
||||||
StudioIds = request.GetStudioIds(),
|
StudioIds = request.GetStudioIds(),
|
||||||
Person = request.Person,
|
Person = request.Person,
|
||||||
|
PersonIds = request.GetPersonIds(),
|
||||||
PersonTypes = request.GetPersonTypes(),
|
PersonTypes = request.GetPersonTypes(),
|
||||||
Years = request.GetYears(),
|
Years = request.GetYears(),
|
||||||
ImageTypes = request.GetImageTypes().ToArray(),
|
ImageTypes = request.GetImageTypes().ToArray(),
|
||||||
|
@ -972,6 +981,13 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply person filter
|
||||||
|
var personIds = request.GetPersonIds();
|
||||||
|
if (personIds.Length > 0 && !(personIds.Any(v => i.People.Select(p => p.Name).Contains(v, StringComparer.OrdinalIgnoreCase))))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply person filter
|
// Apply person filter
|
||||||
if (!string.IsNullOrEmpty(request.Person))
|
if (!string.IsNullOrEmpty(request.Person))
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public string NameLessThan { get; set; }
|
public string NameLessThan { get; set; }
|
||||||
|
|
||||||
public string Person { get; set; }
|
public string Person { get; set; }
|
||||||
|
public string[] PersonIds { get; set; }
|
||||||
public string AdjacentTo { get; set; }
|
public string AdjacentTo { get; set; }
|
||||||
public string[] PersonTypes { get; set; }
|
public string[] PersonTypes { get; set; }
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
VideoTypes = new VideoType[] { };
|
VideoTypes = new VideoType[] { };
|
||||||
Years = new int[] { };
|
Years = new int[] { };
|
||||||
PersonTypes = new string[] { };
|
PersonTypes = new string[] { };
|
||||||
|
PersonIds = new string[] { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
case CollectionType.Books:
|
case CollectionType.Books:
|
||||||
case CollectionType.Photos:
|
case CollectionType.Photos:
|
||||||
case CollectionType.HomeVideos:
|
case CollectionType.HomeVideos:
|
||||||
|
case CollectionType.MusicVideos:
|
||||||
return GetResult(queryParent.GetChildren(user, true), queryParent, query);
|
return GetResult(queryParent.GetChildren(user, true), queryParent, query);
|
||||||
|
|
||||||
case CollectionType.Folders:
|
case CollectionType.Folders:
|
||||||
|
@ -1056,6 +1057,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.PersonIds.Length > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (request.Studios.Length > 0)
|
if (request.Studios.Length > 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1632,7 +1638,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply person filter
|
// Apply person filter
|
||||||
if (!string.IsNullOrEmpty(query.Person))
|
if (query.PersonIds.Length > 0 && !(query.PersonIds.Any(v => item.People.Select(i => i.Name).Contains(v, StringComparer.OrdinalIgnoreCase))))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply person filter
|
||||||
|
if (!string.IsNullOrWhiteSpace(query.Person))
|
||||||
{
|
{
|
||||||
var personTypes = query.PersonTypes;
|
var personTypes = query.PersonTypes;
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// Limit results to items containing a specific person
|
/// Limit results to items containing a specific person
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The person.</value>
|
/// <value>The person.</value>
|
||||||
public string Person { get; set; }
|
public string[] PersonIds { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If the Person filter is used, this can also be used to restrict to a specific person type
|
/// If the Person filter is used, this can also be used to restrict to a specific person type
|
||||||
|
@ -307,6 +307,7 @@ namespace MediaBrowser.Model.Querying
|
||||||
PersonTypes = new string[] { };
|
PersonTypes = new string[] { };
|
||||||
Ids = new string[] { };
|
Ids = new string[] { };
|
||||||
ArtistIds = new string[] { };
|
ArtistIds = new string[] { };
|
||||||
|
PersonIds = new string[] { };
|
||||||
|
|
||||||
ImageTypes = new ImageType[] { };
|
ImageTypes = new ImageType[] { };
|
||||||
AirDays = new DayOfWeek[] { };
|
AirDays = new DayOfWeek[] { };
|
||||||
|
|
|
@ -1673,7 +1673,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
throw new ArgumentNullException("viewType");
|
throw new ArgumentNullException("viewType");
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = GetNewItemId("36_namedview_" + name + user.Id.ToString("N") + (parentId ?? string.Empty), typeof(UserView));
|
var id = GetNewItemId("37_namedview_" + name + user.Id.ToString("N") + (parentId ?? string.Empty), typeof(UserView));
|
||||||
|
|
||||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N"));
|
var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N"));
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var collectionFolder = folder as ICollectionFolder;
|
var collectionFolder = folder as ICollectionFolder;
|
||||||
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
|
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
|
||||||
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
|
||||||
|
if (string.IsNullOrWhiteSpace(folderViewType))
|
||||||
|
{
|
||||||
|
list.Add(folder);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -231,6 +231,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||||
CollectionType.Books,
|
CollectionType.Books,
|
||||||
CollectionType.Photos,
|
CollectionType.Photos,
|
||||||
CollectionType.HomeVideos,
|
CollectionType.HomeVideos,
|
||||||
|
CollectionType.MusicVideos,
|
||||||
string.Empty
|
string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user