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(),
Recursive = true,
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;

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

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

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

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

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

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

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

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

@ -219,7 +219,9 @@ namespace MediaBrowser.Server.Implementations.Collections
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)
{
@ -228,47 +230,15 @@ namespace MediaBrowser.Server.Implementations.Collections
list.Add(child);
var childItem = _libraryManager.GetItemById(itemId);
if (childItem != null)
{
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)
{
collection.LinkedChildren.Remove(child);
}
}
finally
foreach (var child in list)
{
foreach (var file in shortcutFilesToDelete)
{
_iLibraryMonitor.ReportFileSystemChangeComplete(file, false);
}
collection.LinkedChildren.Remove(child);
}
collection.UpdateRatingToContent();

@ -105,6 +105,7 @@ namespace MediaBrowser.Server.Implementations.Library
var includeItemTypes = (query.IncludeItemTypes ?? new string[] { }).ToList();
excludeItemTypes.Add(typeof(Year).Name);
excludeItemTypes.Add(typeof(Folder).Name);
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 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)
{
@ -921,7 +921,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try
{
return _liveStreams.Values
return _liveStreams
.FirstOrDefault(i => string.Equals(i.UniqueId, uniqueId, StringComparison.OrdinalIgnoreCase));
}
finally
@ -937,16 +937,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
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)
{
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);
var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing);
_liveStreamsSemaphore.Release();
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);
_liveStreams[openedMediaSource.Id] = result;
result.SharedStreamIds.Add(openedMediaSource.Id);
_liveStreams.Add(result);
result.ConsumerCount++;
result.TunerHost = hostInstance;
result.OriginalStreamId = streamId;
@ -1047,16 +1047,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try
{
LiveStream stream;
if (_liveStreams.TryGetValue(id, out stream))
var stream = _liveStreams.FirstOrDefault(i => i.SharedStreamIds.Contains(id));
if (stream != null)
{
stream.ConsumerCount--;
stream.SharedStreamIds.Remove(id);
_logger.Info("Live stream {0} consumer count is now {1}", id, stream.ConsumerCount);
if (stream.ConsumerCount <= 0)
{
_liveStreams.Remove(id);
_liveStreams.Remove(stream);
_logger.Info("Closing live stream {0}", id);

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

@ -1857,11 +1857,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
index++;
if (!reader.IsDBNull(index))
if (query.DtoOptions.EnableImages)
{
DeserializeImages(reader.GetString(index), item);
if (!reader.IsDBNull(index))
{
DeserializeImages(reader.GetString(index), item);
}
index++;
}
index++;
if (query.HasField(ItemFields.ProductionLocations))
{
@ -2259,6 +2262,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
if (!query.DtoOptions.EnableImages)
{
list.Remove("Images");
}
if (EnableJoinUserData(query))
{
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>
protected override void FindParts()
{
var isAuthorized = ServerConfigurationManager.Configuration.IsPortAuthorized;
if (isAuthorized)
{
try
{
isAuthorized = !NativeApp.PortsRequireAuthorization(ConfigurationManager.CommonApplicationPaths.ApplicationPath);
}
catch
{
}
}
if (!isAuthorized)
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
{
RegisterServerWithAdministratorAccess();
ServerConfigurationManager.Configuration.IsPortAuthorized = true;

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

@ -204,16 +204,6 @@ namespace MediaBrowser.ServerApplication.Native
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)
{
var appNameSrch = Path.GetFileName(applicationPath);
@ -242,7 +232,6 @@ namespace MediaBrowser.ServerApplication.Native
if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)
{
_logger.Info("Found potential windows firewall rule blocking Emby Server: " + data);
return Confirm();
}
//var parts = data.Split('\n');

Loading…
Cancel
Save