diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-02-26 16:48:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-26 16:48:37 -0500 |
| commit | 2b549909754948d9bd914d9c836e982bc1f2be5c (patch) | |
| tree | a2f69870174e3cb5794ab724862f9bc00b0dc21b /Emby.Server.Implementations | |
| parent | 02481aa6249210eb040f06bb679936354a6b959e (diff) | |
| parent | 5d094874e5d94b4dabc8f5499fe6a879df5dfd23 (diff) | |
Merge pull request #2496 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations')
8 files changed, 15 insertions, 491 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 1f72ebd54..e65ebeb04 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -3388,10 +3388,10 @@ namespace Emby.Server.Implementations.Data var includeTypes = query.IncludeItemTypes.SelectMany(MapIncludeItemTypes).ToArray(); if (includeTypes.Length == 1) { - whereClauses.Add("type=@type" + paramSuffix); + whereClauses.Add("type=@type"); if (statement != null) { - statement.TryBind("@type" + paramSuffix, includeTypes[0]); + statement.TryBind("@type", includeTypes[0]); } } else if (includeTypes.Length > 1) @@ -4936,7 +4936,7 @@ namespace Emby.Server.Implementations.Data ParentId = query.ParentId, IsPlayed = query.IsPlayed }; - var whereClauses = GetWhereClauses(typeSubQuery, null, "itemTypes"); + var whereClauses = GetWhereClauses(typeSubQuery, null); whereClauses.Add("guid in (select ItemId from ItemValues where ItemValues.CleanValue=A.CleanName AND " + typeClause + ")"); @@ -5072,7 +5072,7 @@ namespace Emby.Server.Implementations.Data if (typeSubQuery != null) { - GetWhereClauses(typeSubQuery, null, "itemTypes"); + GetWhereClauses(typeSubQuery, null); } BindSimilarParams(query, statement); GetWhereClauses(innerQuery, statement); @@ -5110,7 +5110,7 @@ namespace Emby.Server.Implementations.Data if (typeSubQuery != null) { - GetWhereClauses(typeSubQuery, null, "itemTypes"); + GetWhereClauses(typeSubQuery, null); } BindSimilarParams(query, statement); GetWhereClauses(innerQuery, statement); diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 4ee3df7f5..8b6b388db 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.Dto } } - //if (!(item is LiveTvProgram)) + if (!(item is LiveTvProgram)) { dto.PlayAccess = item.GetPlayAccess(user); } diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 13efb7bf9..50c01110f 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -104,7 +104,6 @@ <Compile Include="HttpServer\StreamWriter.cs" /> <Compile Include="HttpServer\SwaggerService.cs" /> <Compile Include="Images\BaseDynamicImageProvider.cs" /> - <Compile Include="Intros\DefaultIntroProvider.cs" /> <Compile Include="IO\FileRefresher.cs" /> <Compile Include="IO\MbLinkShortcutHandler.cs" /> <Compile Include="IO\ThrottledStream.cs" /> @@ -238,7 +237,6 @@ <Compile Include="Sorting\AlbumComparer.cs" /> <Compile Include="Sorting\AlphanumComparator.cs" /> <Compile Include="Sorting\ArtistComparer.cs" /> - <Compile Include="Sorting\BudgetComparer.cs" /> <Compile Include="Sorting\CommunityRatingComparer.cs" /> <Compile Include="Sorting\CriticRatingComparer.cs" /> <Compile Include="Sorting\DateCreatedComparer.cs" /> @@ -257,7 +255,6 @@ <Compile Include="Sorting\PremiereDateComparer.cs" /> <Compile Include="Sorting\ProductionYearComparer.cs" /> <Compile Include="Sorting\RandomComparer.cs" /> - <Compile Include="Sorting\RevenueComparer.cs" /> <Compile Include="Sorting\RuntimeComparer.cs" /> <Compile Include="Sorting\SeriesSortNameComparer.cs" /> <Compile Include="Sorting\SortNameComparer.cs" /> diff --git a/Emby.Server.Implementations/Intros/DefaultIntroProvider.cs b/Emby.Server.Implementations/Intros/DefaultIntroProvider.cs deleted file mode 100644 index 4d19a0e9b..000000000 --- a/Emby.Server.Implementations/Intros/DefaultIntroProvider.cs +++ /dev/null @@ -1,394 +0,0 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Security; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Entities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Extensions; -using MediaBrowser.Model.Globalization; - -namespace Emby.Server.Implementations.Intros -{ - public class DefaultIntroProvider : IIntroProvider - { - private readonly ISecurityManager _security; - private readonly ILocalizationManager _localization; - private readonly IConfigurationManager _serverConfig; - private readonly ILibraryManager _libraryManager; - private readonly IFileSystem _fileSystem; - private readonly IMediaSourceManager _mediaSourceManager; - - public DefaultIntroProvider(ISecurityManager security, ILocalizationManager localization, IConfigurationManager serverConfig, ILibraryManager libraryManager, IFileSystem fileSystem, IMediaSourceManager mediaSourceManager) - { - _security = security; - _localization = localization; - _serverConfig = serverConfig; - _libraryManager = libraryManager; - _fileSystem = fileSystem; - _mediaSourceManager = mediaSourceManager; - } - - public async Task<IEnumerable<IntroInfo>> GetIntros(BaseItem item, User user) - { - var config = GetOptions(); - - if (item is Movie) - { - if (!config.EnableIntrosForMovies) - { - return new List<IntroInfo>(); - } - } - else if (item is Episode) - { - if (!config.EnableIntrosForEpisodes) - { - return new List<IntroInfo>(); - } - } - else - { - return new List<IntroInfo>(); - } - - var ratingLevel = string.IsNullOrWhiteSpace(item.OfficialRating) - ? null - : _localization.GetRatingLevel(item.OfficialRating); - - var candidates = new List<ItemWithTrailer>(); - - var trailerTypes = new List<TrailerType>(); - var sourceTypes = new List<SourceType>(); - - if (config.EnableIntrosFromMoviesInLibrary) - { - trailerTypes.Add(TrailerType.LocalTrailer); - sourceTypes.Add(SourceType.Library); - } - - if (IsSupporter) - { - if (config.EnableIntrosFromUpcomingTrailers) - { - trailerTypes.Add(TrailerType.ComingSoonToTheaters); - sourceTypes.Clear(); - } - if (config.EnableIntrosFromUpcomingDvdMovies) - { - trailerTypes.Add(TrailerType.ComingSoonToDvd); - sourceTypes.Clear(); - } - if (config.EnableIntrosFromUpcomingStreamingMovies) - { - trailerTypes.Add(TrailerType.ComingSoonToStreaming); - sourceTypes.Clear(); - } - if (config.EnableIntrosFromSimilarMovies) - { - trailerTypes.Add(TrailerType.Archive); - sourceTypes.Clear(); - } - } - - if (trailerTypes.Count > 0) - { - if (trailerTypes.Count >= 5) - { - trailerTypes.Clear(); - } - - // hack - can't filter by user library because local trailers get TopParentId =null in the db. - // for now we have to use a post-query filter afterwards to solve that - var trailerResult = _libraryManager.GetItemList(new InternalItemsQuery - { - IncludeItemTypes = new[] { typeof(Trailer).Name }, - TrailerTypes = trailerTypes.ToArray(), - SimilarTo = item, - //IsPlayed = config.EnableIntrosForWatchedContent ? (bool?)null : false, - MaxParentalRating = config.EnableIntrosParentalControl ? ratingLevel : null, - BlockUnratedItems = config.EnableIntrosParentalControl ? new[] { UnratedItem.Trailer } : new UnratedItem[] { }, - - // Account for duplicates by imdb id, since the database doesn't support this yet - Limit = config.TrailerLimit * 4, - SourceTypes = sourceTypes.ToArray() - }) - .Where(i => string.IsNullOrWhiteSpace(i.GetProviderId(MetadataProviders.Imdb)) || !string.Equals(i.GetProviderId(MetadataProviders.Imdb), item.GetProviderId(MetadataProviders.Imdb), StringComparison.OrdinalIgnoreCase)) - .Where(i => i.IsVisibleStandalone(user)) - .Where(i => config.EnableIntrosForWatchedContent || !i.IsPlayed(user)) - .Take(config.TrailerLimit); - - candidates.AddRange(trailerResult.Select(i => new ItemWithTrailer - { - Item = i, - Type = i.SourceType == SourceType.Channel ? ItemWithTrailerType.ChannelTrailer : ItemWithTrailerType.ItemWithTrailer, - LibraryManager = _libraryManager - })); - } - - return GetResult(item, candidates, config); - } - - private IEnumerable<IntroInfo> GetResult(BaseItem item, IEnumerable<ItemWithTrailer> candidates, CinemaModeConfiguration config) - { - var customIntros = !string.IsNullOrWhiteSpace(config.CustomIntroPath) ? - GetCustomIntros(config) : - new List<IntroInfo>(); - - var mediaInfoIntros = !string.IsNullOrWhiteSpace(config.MediaInfoIntroPath) ? - GetMediaInfoIntros(config, item) : - new List<IntroInfo>(); - - // Avoid implicitly captured closure - return candidates.Select(i => i.IntroInfo) - .Concat(customIntros.Take(1)) - .Concat(mediaInfoIntros); - } - - private CinemaModeConfiguration GetOptions() - { - return _serverConfig.GetConfiguration<CinemaModeConfiguration>("cinemamode"); - } - - private List<IntroInfo> GetCustomIntros(CinemaModeConfiguration options) - { - try - { - return GetCustomIntroFiles(options, true, false) - .OrderBy(i => Guid.NewGuid()) - .Select(i => new IntroInfo - { - Path = i - - }).ToList(); - } - catch (IOException) - { - return new List<IntroInfo>(); - } - } - - private IEnumerable<IntroInfo> GetMediaInfoIntros(CinemaModeConfiguration options, BaseItem item) - { - try - { - var hasMediaSources = item as IHasMediaSources; - - if (hasMediaSources == null) - { - return new List<IntroInfo>(); - } - - var mediaSource = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false) - .FirstOrDefault(); - - if (mediaSource == null) - { - return new List<IntroInfo>(); - } - - var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); - var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); - - var allIntros = GetCustomIntroFiles(options, false, true) - .OrderBy(i => Guid.NewGuid()) - .Select(i => new IntroInfo - { - Path = i - - }).ToList(); - - var returnResult = new List<IntroInfo>(); - - if (videoStream != null) - { - returnResult.AddRange(GetMediaInfoIntrosByVideoStream(allIntros, videoStream).Take(1)); - } - - if (audioStream != null) - { - returnResult.AddRange(GetMediaInfoIntrosByAudioStream(allIntros, audioStream).Take(1)); - } - - returnResult.AddRange(GetMediaInfoIntrosByTags(allIntros, item.Tags).Take(1)); - - return returnResult.DistinctBy(i => i.Path, StringComparer.OrdinalIgnoreCase); - } - catch (IOException) - { - return new List<IntroInfo>(); - } - } - - private IEnumerable<IntroInfo> GetMediaInfoIntrosByVideoStream(List<IntroInfo> allIntros, MediaStream stream) - { - var codec = stream.Codec; - - if (string.IsNullOrWhiteSpace(codec)) - { - return new List<IntroInfo>(); - } - - return allIntros - .Where(i => IsMatch(i.Path, codec)) - .OrderBy(i => Guid.NewGuid()); - } - - private IEnumerable<IntroInfo> GetMediaInfoIntrosByAudioStream(List<IntroInfo> allIntros, MediaStream stream) - { - var codec = stream.Codec; - - if (string.IsNullOrWhiteSpace(codec)) - { - return new List<IntroInfo>(); - } - - return allIntros - .Where(i => IsAudioMatch(i.Path, stream)) - .OrderBy(i => Guid.NewGuid()); - } - - private IEnumerable<IntroInfo> GetMediaInfoIntrosByTags(List<IntroInfo> allIntros, List<string> tags) - { - return allIntros - .Where(i => tags.Any(t => IsMatch(i.Path, t))) - .OrderBy(i => Guid.NewGuid()); - } - - private bool IsMatch(string file, string attribute) - { - var filename = Path.GetFileNameWithoutExtension(file) ?? string.Empty; - filename = Normalize(filename); - - if (string.IsNullOrWhiteSpace(filename)) - { - return false; - } - - attribute = Normalize(attribute); - if (string.IsNullOrWhiteSpace(attribute)) - { - return false; - } - - return string.Equals(filename, attribute, StringComparison.OrdinalIgnoreCase); - } - - private string Normalize(string value) - { - return value; - } - - private bool IsAudioMatch(string path, MediaStream stream) - { - if (!string.IsNullOrWhiteSpace(stream.Codec)) - { - if (IsMatch(path, stream.Codec)) - { - return true; - } - } - if (!string.IsNullOrWhiteSpace(stream.Profile)) - { - if (IsMatch(path, stream.Profile)) - { - return true; - } - } - - return false; - } - - private IEnumerable<string> GetCustomIntroFiles(CinemaModeConfiguration options, bool enableCustomIntros, bool enableMediaInfoIntros) - { - var list = new List<string>(); - - if (enableCustomIntros && !string.IsNullOrWhiteSpace(options.CustomIntroPath)) - { - list.AddRange(_fileSystem.GetFilePaths(options.CustomIntroPath, true) - .Where(_libraryManager.IsVideoFile)); - } - - if (enableMediaInfoIntros && !string.IsNullOrWhiteSpace(options.MediaInfoIntroPath)) - { - list.AddRange(_fileSystem.GetFilePaths(options.MediaInfoIntroPath, true) - .Where(_libraryManager.IsVideoFile)); - } - - return list.Distinct(StringComparer.OrdinalIgnoreCase); - } - - public IEnumerable<string> GetAllIntroFiles() - { - return GetCustomIntroFiles(GetOptions(), true, true); - } - - private bool IsSupporter - { - get { return _security.IsMBSupporter; } - } - - public string Name - { - get { return "Default"; } - } - - internal class ItemWithTrailer - { - internal BaseItem Item; - internal ItemWithTrailerType Type; - internal ILibraryManager LibraryManager; - - public IntroInfo IntroInfo - { - get - { - var id = Item.Id; - - if (Type == ItemWithTrailerType.ItemWithTrailer) - { - var hasTrailers = Item as IHasTrailers; - - if (hasTrailers != null) - { - id = hasTrailers.LocalTrailerIds.FirstOrDefault(); - } - } - return new IntroInfo - { - ItemId = id - }; - } - } - } - - internal enum ItemWithTrailerType - { - ChannelTrailer, - ItemWithTrailer - } - } - - public class CinemaModeConfigurationFactory : IConfigurationFactory - { - public IEnumerable<ConfigurationStore> GetConfigurations() - { - return new[] - { - new ConfigurationStore - { - ConfigurationType = typeof(CinemaModeConfiguration), - Key = "cinemamode" - } - }; - } - } - -} diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 8366c2d57..a939cec7b 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -162,7 +162,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts Id = channel.Path.GetMD5().ToString("N"), IsInfiniteStream = true, - SupportsDirectStream = false, IsRemote = true }; diff --git a/Emby.Server.Implementations/Sorting/BudgetComparer.cs b/Emby.Server.Implementations/Sorting/BudgetComparer.cs deleted file mode 100644 index f3aef69f1..000000000 --- a/Emby.Server.Implementations/Sorting/BudgetComparer.cs +++ /dev/null @@ -1,39 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Sorting; -using MediaBrowser.Model.Querying; - -namespace Emby.Server.Implementations.Sorting -{ - public class BudgetComparer : IBaseItemComparer - { - /// <summary> - /// Compares the specified x. - /// </summary> - /// <param name="x">The x.</param> - /// <param name="y">The y.</param> - /// <returns>System.Int32.</returns> - public int Compare(BaseItem x, BaseItem y) - { - return GetValue(x).CompareTo(GetValue(y)); - } - - private double GetValue(BaseItem x) - { - var hasBudget = x as IHasBudget; - if (hasBudget != null) - { - return hasBudget.Budget ?? 0; - } - return 0; - } - - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - public string Name - { - get { return ItemSortBy.Budget; } - } - } -} diff --git a/Emby.Server.Implementations/Sorting/RevenueComparer.cs b/Emby.Server.Implementations/Sorting/RevenueComparer.cs deleted file mode 100644 index 62e43eac1..000000000 --- a/Emby.Server.Implementations/Sorting/RevenueComparer.cs +++ /dev/null @@ -1,39 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Sorting; -using MediaBrowser.Model.Querying; - -namespace Emby.Server.Implementations.Sorting -{ - public class RevenueComparer : IBaseItemComparer - { - /// <summary> - /// Compares the specified x. - /// </summary> - /// <param name="x">The x.</param> - /// <param name="y">The y.</param> - /// <returns>System.Int32.</returns> - public int Compare(BaseItem x, BaseItem y) - { - return GetValue(x).CompareTo(GetValue(y)); - } - - private double GetValue(BaseItem x) - { - var hasBudget = x as IHasBudget; - if (hasBudget != null) - { - return hasBudget.Revenue ?? 0; - } - return 0; - } - - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - public string Name - { - get { return ItemSortBy.Revenue; } - } - } -} diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 0420900c5..a13dd0569 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -162,15 +162,15 @@ namespace Emby.Server.Implementations.Updates string packageType = null, Version applicationVersion = null) { - var data = new Dictionary<string, string> - { - { "key", _securityManager.SupporterKey }, - { "mac", _applicationHost.SystemId }, - { "systemid", _applicationHost.SystemId } - }; - if (withRegistration) { + var data = new Dictionary<string, string> + { + { "key", _securityManager.SupporterKey }, + { "mac", _applicationHost.SystemId }, + { "systemid", _applicationHost.SystemId } + }; + using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall", data, cancellationToken).ConfigureAwait(false)) { cancellationToken.ThrowIfCancellationRequested(); @@ -353,7 +353,7 @@ namespace Emby.Server.Implementations.Updates /// <returns>Task{PackageVersionInfo}.</returns> public async Task<PackageVersionInfo> GetPackage(string name, string guid, PackageVersionClass classification, Version version) { - var packages = await GetAvailablePackages(CancellationToken.None).ConfigureAwait(false); + var packages = await GetAvailablePackages(CancellationToken.None, false).ConfigureAwait(false); var package = packages.FirstOrDefault(p => string.Equals(p.guid, guid ?? "none", StringComparison.OrdinalIgnoreCase)) ?? packages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase)); @@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Updates /// <returns>Task{PackageVersionInfo}.</returns> public async Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release) { - var packages = await GetAvailablePackages(CancellationToken.None).ConfigureAwait(false); + var packages = await GetAvailablePackages(CancellationToken.None, false).ConfigureAwait(false); return GetLatestCompatibleVersion(packages, name, guid, currentServerVersion, classification); } |
