update program queries

pull/702/head
Luke Pulverenti 8 years ago
parent daaae69df5
commit cb26cb9457

@ -106,7 +106,12 @@ namespace MediaBrowser.Api
IncludeItemTypes = request.GetIncludeItemTypes(), IncludeItemTypes = request.GetIncludeItemTypes(),
Recursive = true, Recursive = true,
EnableTotalRecordCount = false, EnableTotalRecordCount = false,
Fields = new List<ItemFields> { ItemFields.Genres, ItemFields.Tags } DtoOptions = new Controller.Dto.DtoOptions
{
Fields = new List<ItemFields> { ItemFields.Genres, ItemFields.Tags },
EnableImages = false,
EnableUserData = false
}
}; };
return query; return query;

@ -210,7 +210,7 @@ namespace MediaBrowser.Api
typeof(Game).Name typeof(Game).Name
}, },
SimilarTo = item, SimilarTo = item,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).ToList(); }).ToList();

@ -165,7 +165,7 @@ namespace MediaBrowser.Api.Movies
IsMovie = true, IsMovie = true,
SimilarTo = item, SimilarTo = item,
EnableGroupByMetadataKey = true, EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).ToList(); }).ToList();
@ -200,7 +200,7 @@ namespace MediaBrowser.Api.Movies
ParentId = parentIdGuid, ParentId = parentIdGuid,
Recursive = true, Recursive = true,
IsPlayed = true, IsPlayed = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}; };
var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList(); var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList();
@ -224,7 +224,7 @@ namespace MediaBrowser.Api.Movies
EnableGroupByMetadataKey = true, EnableGroupByMetadataKey = true,
ParentId = parentIdGuid, ParentId = parentIdGuid,
Recursive = true, Recursive = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).ToList(); }).ToList();
@ -306,7 +306,7 @@ namespace MediaBrowser.Api.Movies
IncludeItemTypes = itemTypes.ToArray(), IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true, IsMovie = true,
EnableGroupByMetadataKey = true, EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N")) }).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.Take(itemLimit) .Take(itemLimit)
@ -344,7 +344,7 @@ namespace MediaBrowser.Api.Movies
IncludeItemTypes = itemTypes.ToArray(), IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true, IsMovie = true,
EnableGroupByMetadataKey = true, EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N")) }).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.Take(itemLimit) .Take(itemLimit)
@ -381,7 +381,7 @@ namespace MediaBrowser.Api.Movies
IsMovie = true, IsMovie = true,
SimilarTo = item, SimilarTo = item,
EnableGroupByMetadataKey = true, EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).ToList(); }).ToList();

@ -82,7 +82,7 @@ namespace MediaBrowser.Api
{ {
IncludeItemTypes = includeTypes.Select(i => i.Name).ToArray(), IncludeItemTypes = includeTypes.Select(i => i.Name).ToArray(),
Recursive = true, Recursive = true,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}; };
// ExcludeArtistIds // ExcludeArtistIds

@ -312,7 +312,7 @@ namespace MediaBrowser.Api
typeof(Series).Name typeof(Series).Name
}, },
SimilarTo = item, SimilarTo = item,
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}).ToList(); }).ToList();
@ -346,7 +346,7 @@ namespace MediaBrowser.Api
Limit = request.Limit, Limit = request.Limit,
ParentId = parentIdGuid, ParentId = parentIdGuid,
Recursive = true, Recursive = true,
Fields = options.Fields DtoOptions = options
}).ToList(); }).ToList();

@ -239,7 +239,7 @@ namespace MediaBrowser.Api.UserLibrary
AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater, AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater,
EnableTotalRecordCount = request.EnableTotalRecordCount, EnableTotalRecordCount = request.EnableTotalRecordCount,
ExcludeItemIds = request.GetExcludeItemIds(), ExcludeItemIds = request.GetExcludeItemIds(),
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}; };
if (!string.IsNullOrWhiteSpace(request.Ids)) if (!string.IsNullOrWhiteSpace(request.Ids))

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using System.Linq; using System.Linq;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
@ -159,10 +160,12 @@ namespace MediaBrowser.Controller.Entities
public DateTime? MinDateCreated { get; set; } public DateTime? MinDateCreated { get; set; }
public DateTime? MinDateLastSaved { get; set; } public DateTime? MinDateLastSaved { get; set; }
public List<ItemFields> Fields { get; set; } public DtoOptions DtoOptions { get; set; }
public bool HasField(ItemFields name) public bool HasField(ItemFields name)
{ {
var fields = DtoOptions.Fields;
switch (name) switch (name)
{ {
case ItemFields.ProductionLocations: case ItemFields.ProductionLocations:
@ -185,7 +188,7 @@ namespace MediaBrowser.Controller.Entities
case ItemFields.Tags: case ItemFields.Tags:
case ItemFields.DateLastMediaAdded: case ItemFields.DateLastMediaAdded:
case ItemFields.CriticRatingSummary: case ItemFields.CriticRatingSummary:
return Fields.Count == 0 || Fields.Contains(name); return fields.Count == 0 || fields.Contains(name);
default: default:
return true; return true;
} }
@ -196,7 +199,7 @@ namespace MediaBrowser.Controller.Entities
GroupByPresentationUniqueKey = true; GroupByPresentationUniqueKey = true;
EnableTotalRecordCount = true; EnableTotalRecordCount = true;
Fields = new List<ItemFields>(); DtoOptions = new DtoOptions();
AlbumNames = new string[] { }; AlbumNames = new string[] { };
ArtistNames = new string[] { }; ArtistNames = new string[] { };
ExcludeArtistIds = new string[] { }; ExcludeArtistIds = new string[] { };

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
@ -9,13 +10,16 @@ namespace MediaBrowser.Controller.LiveTv
{ {
public MediaSourceInfo OriginalMediaSource { get; set; } public MediaSourceInfo OriginalMediaSource { get; set; }
public MediaSourceInfo OpenedMediaSource { get; set; } public MediaSourceInfo OpenedMediaSource { get; set; }
public DateTime DateOpened { get; set; } public int ConsumerCount {
public int ConsumerCount { get; set; } get { return SharedStreamIds.Count; }
}
public ITunerHost TunerHost { get; set; } public ITunerHost TunerHost { get; set; }
public string OriginalStreamId { get; set; } public string OriginalStreamId { get; set; }
public bool EnableStreamSharing { get; set; } public bool EnableStreamSharing { get; set; }
public string UniqueId = Guid.NewGuid().ToString("N"); public string UniqueId = Guid.NewGuid().ToString("N");
public List<string> SharedStreamIds = new List<string>();
public LiveStream(MediaSourceInfo mediaSource) public LiveStream(MediaSourceInfo mediaSource)
{ {
OriginalMediaSource = mediaSource; OriginalMediaSource = mediaSource;
@ -23,12 +27,9 @@ namespace MediaBrowser.Controller.LiveTv
EnableStreamSharing = true; EnableStreamSharing = true;
} }
public async Task Open(CancellationToken cancellationToken) public Task Open(CancellationToken cancellationToken)
{ {
await OpenInternal(cancellationToken).ConfigureAwait(false); return OpenInternal(cancellationToken);
DateOpened = DateTime.UtcNow;
OpenedMediaSource.DateLiveStreamOpened = DateOpened;
} }
protected virtual Task OpenInternal(CancellationToken cancellationToken) protected virtual Task OpenInternal(CancellationToken cancellationToken)

@ -54,8 +54,6 @@ namespace MediaBrowser.Model.Dto
public string TranscodingSubProtocol { get; set; } public string TranscodingSubProtocol { get; set; }
public string TranscodingContainer { get; set; } public string TranscodingContainer { get; set; }
public DateTime? DateLiveStreamOpened { get; set; }
public MediaSourceInfo() public MediaSourceInfo()
{ {
Formats = new List<string>(); Formats = new List<string>();

@ -219,7 +219,9 @@ namespace MediaBrowser.Server.Implementations.Collections
foreach (var itemId in itemIds) foreach (var itemId in itemIds)
{ {
var child = collection.LinkedChildren.FirstOrDefault(i => i.ItemId.HasValue && i.ItemId.Value == itemId); var childItem = _libraryManager.GetItemById(itemId);
var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == itemId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase)));
if (child == null) if (child == null)
{ {
@ -228,48 +230,16 @@ namespace MediaBrowser.Server.Implementations.Collections
list.Add(child); list.Add(child);
var childItem = _libraryManager.GetItemById(itemId);
if (childItem != null) if (childItem != null)
{ {
itemList.Add(childItem); itemList.Add(childItem);
} }
} }
var shortcutFiles = _fileSystem
.GetFilePaths(collection.Path)
.Where(i => _fileSystem.IsShortcut(i))
.ToList();
var shortcutFilesToDelete = list.Where(child => !string.IsNullOrWhiteSpace(child.Path) && child.Type == LinkedChildType.Shortcut)
.Select(child => shortcutFiles.FirstOrDefault(i => string.Equals(child.Path, _fileSystem.ResolveShortcut(i), StringComparison.OrdinalIgnoreCase)))
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToList();
foreach (var file in shortcutFilesToDelete)
{
_iLibraryMonitor.ReportFileSystemChangeBeginning(file);
}
try
{
foreach (var file in shortcutFilesToDelete)
{
_fileSystem.DeleteFile(file);
}
foreach (var child in list) foreach (var child in list)
{ {
collection.LinkedChildren.Remove(child); collection.LinkedChildren.Remove(child);
} }
}
finally
{
foreach (var file in shortcutFilesToDelete)
{
_iLibraryMonitor.ReportFileSystemChangeComplete(file, false);
}
}
collection.UpdateRatingToContent(); collection.UpdateRatingToContent();

@ -105,6 +105,7 @@ namespace MediaBrowser.Server.Implementations.Library
var includeItemTypes = (query.IncludeItemTypes ?? new string[] { }).ToList(); var includeItemTypes = (query.IncludeItemTypes ?? new string[] { }).ToList();
excludeItemTypes.Add(typeof(Year).Name); excludeItemTypes.Add(typeof(Year).Name);
excludeItemTypes.Add(typeof(Folder).Name);
if (query.IncludeGenres && (includeItemTypes.Count == 0 || includeItemTypes.Contains("Genre", StringComparer.OrdinalIgnoreCase))) if (query.IncludeGenres && (includeItemTypes.Count == 0 || includeItemTypes.Contains("Genre", StringComparer.OrdinalIgnoreCase)))
{ {

@ -882,7 +882,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
} }
private readonly SemaphoreSlim _liveStreamsSemaphore = new SemaphoreSlim(1, 1); private readonly SemaphoreSlim _liveStreamsSemaphore = new SemaphoreSlim(1, 1);
private readonly Dictionary<string, LiveStream> _liveStreams = new Dictionary<string, LiveStream>(); private readonly List<LiveStream> _liveStreams = new List<LiveStream>();
public async Task<MediaSourceInfo> GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken) public async Task<MediaSourceInfo> GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken)
{ {
@ -921,7 +921,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try try
{ {
return _liveStreams.Values return _liveStreams
.FirstOrDefault(i => string.Equals(i.UniqueId, uniqueId, StringComparison.OrdinalIgnoreCase)); .FirstOrDefault(i => string.Equals(i.UniqueId, uniqueId, StringComparison.OrdinalIgnoreCase));
} }
finally finally
@ -937,16 +937,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
await _liveStreamsSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); await _liveStreamsSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
var result = _liveStreams.Values.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); var result = _liveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase));
if (result != null && result.EnableStreamSharing) if (result != null && result.EnableStreamSharing)
{ {
result.ConsumerCount++; var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing);
result.SharedStreamIds.Add(openedMediaSource.Id);
_liveStreamsSemaphore.Release();
_logger.Info("Live stream {0} consumer count is now {1}", streamId, result.ConsumerCount); _logger.Info("Live stream {0} consumer count is now {1}", streamId, result.ConsumerCount);
var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing);
_liveStreamsSemaphore.Release();
return new Tuple<LiveStream, MediaSourceInfo, ITunerHost>(result, openedMediaSource, result.TunerHost); return new Tuple<LiveStream, MediaSourceInfo, ITunerHost>(result, openedMediaSource, result.TunerHost);
} }
@ -960,9 +960,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing); var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing);
_liveStreams[openedMediaSource.Id] = result; result.SharedStreamIds.Add(openedMediaSource.Id);
_liveStreams.Add(result);
result.ConsumerCount++;
result.TunerHost = hostInstance; result.TunerHost = hostInstance;
result.OriginalStreamId = streamId; result.OriginalStreamId = streamId;
@ -1047,16 +1047,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try try
{ {
LiveStream stream; var stream = _liveStreams.FirstOrDefault(i => i.SharedStreamIds.Contains(id));
if (_liveStreams.TryGetValue(id, out stream)) if (stream != null)
{ {
stream.ConsumerCount--; stream.SharedStreamIds.Remove(id);
_logger.Info("Live stream {0} consumer count is now {1}", id, stream.ConsumerCount); _logger.Info("Live stream {0} consumer count is now {1}", id, stream.ConsumerCount);
if (stream.ConsumerCount <= 0) if (stream.ConsumerCount <= 0)
{ {
_liveStreams.Remove(id); _liveStreams.Remove(stream);
_logger.Info("Closing live stream {0}", id); _logger.Info("Closing live stream {0}", id);

@ -871,7 +871,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
SortOrder = query.SortOrder ?? SortOrder.Ascending, SortOrder = query.SortOrder ?? SortOrder.Ascending,
EnableTotalRecordCount = query.EnableTotalRecordCount, EnableTotalRecordCount = query.EnableTotalRecordCount,
TopParentIds = new[] { topFolder.Id.ToString("N") }, TopParentIds = new[] { topFolder.Id.ToString("N") },
Fields = options.Fields DtoOptions = options
}; };
if (!string.IsNullOrWhiteSpace(query.SeriesTimerId)) if (!string.IsNullOrWhiteSpace(query.SeriesTimerId))
@ -940,7 +940,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
EnableTotalRecordCount = query.EnableTotalRecordCount, EnableTotalRecordCount = query.EnableTotalRecordCount,
SortBy = new[] { ItemSortBy.StartDate }, SortBy = new[] { ItemSortBy.StartDate },
TopParentIds = new[] { topFolder.Id.ToString("N") }, TopParentIds = new[] { topFolder.Id.ToString("N") },
Fields = options.Fields DtoOptions = options
}; };
if (query.Limit.HasValue) if (query.Limit.HasValue)
@ -1566,7 +1566,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
IncludeItemTypes = includeItemTypes.ToArray(), IncludeItemTypes = includeItemTypes.ToArray(),
ExcludeItemTypes = excludeItemTypes.ToArray(), ExcludeItemTypes = excludeItemTypes.ToArray(),
Genres = genres.ToArray(), Genres = genres.ToArray(),
Fields = dtoOptions.Fields DtoOptions = dtoOptions
}); });
} }

@ -1857,11 +1857,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
index++; index++;
if (query.DtoOptions.EnableImages)
{
if (!reader.IsDBNull(index)) if (!reader.IsDBNull(index))
{ {
DeserializeImages(reader.GetString(index), item); DeserializeImages(reader.GetString(index), item);
} }
index++; index++;
}
if (query.HasField(ItemFields.ProductionLocations)) if (query.HasField(ItemFields.ProductionLocations))
{ {
@ -2259,6 +2262,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
} }
if (!query.DtoOptions.EnableImages)
{
list.Remove("Images");
}
if (EnableJoinUserData(query)) if (EnableJoinUserData(query))
{ {
list.Add("UserDataDb.UserData.UserId"); list.Add("UserDataDb.UserData.UserId");

@ -277,10 +277,5 @@ namespace MediaBrowser.Server.Mono.Native
{ {
} }
public bool PortsRequireAuthorization(string applicationPath)
{
return false;
}
} }
} }

@ -966,19 +966,7 @@ namespace MediaBrowser.Server.Startup.Common
/// </summary> /// </summary>
protected override void FindParts() protected override void FindParts()
{ {
var isAuthorized = ServerConfigurationManager.Configuration.IsPortAuthorized; if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
if (isAuthorized)
{
try
{
isAuthorized = !NativeApp.PortsRequireAuthorization(ConfigurationManager.CommonApplicationPaths.ApplicationPath);
}
catch
{
}
}
if (!isAuthorized)
{ {
RegisterServerWithAdministratorAccess(); RegisterServerWithAdministratorAccess();
ServerConfigurationManager.Configuration.IsPortAuthorized = true; ServerConfigurationManager.Configuration.IsPortAuthorized = true;

@ -24,8 +24,6 @@ namespace MediaBrowser.Server.Startup.Common
/// <param name="tempDirectory">The temporary directory.</param> /// <param name="tempDirectory">The temporary directory.</param>
void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory); void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory);
bool PortsRequireAuthorization(string applicationPath);
/// <summary> /// <summary>
/// Gets the environment. /// Gets the environment.
/// </summary> /// </summary>

@ -204,16 +204,6 @@ namespace MediaBrowser.ServerApplication.Native
LoopUtil.Run(appName); LoopUtil.Run(appName);
} }
private bool Confirm()
{
if (MainStartup._splash == null)
{
return false;
}
return MessageBox.Show(MainStartup._splash, "Emby has detected that a rule has been added to Windows Firewall that may prevent your other devices from accessing Emby Server. Click OK to remove this rule, or cancel to proceed anyway.", "Windows Firewall", MessageBoxButtons.OKCancel) == DialogResult.OK;
}
public bool PortsRequireAuthorization(string applicationPath) public bool PortsRequireAuthorization(string applicationPath)
{ {
var appNameSrch = Path.GetFileName(applicationPath); var appNameSrch = Path.GetFileName(applicationPath);
@ -242,7 +232,6 @@ namespace MediaBrowser.ServerApplication.Native
if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1) if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)
{ {
_logger.Info("Found potential windows firewall rule blocking Emby Server: " + data); _logger.Info("Found potential windows firewall rule blocking Emby Server: " + data);
return Confirm();
} }
//var parts = data.Split('\n'); //var parts = data.Split('\n');

Loading…
Cancel
Save