From bbc08753878b7b8a37ed876385d2e6864349d00d Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 20 Oct 2019 16:08:40 +0200 Subject: [PATCH 01/53] Don't shuffle some types by default --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 30 +++++------ .../Channels/ChannelManager.cs | 10 ++-- .../Collections/CollectionImageProvider.cs | 1 - .../Data/SqliteItemRepository.cs | 28 ++++------- .../Library/LibraryManager.cs | 4 +- .../Library/MusicManager.cs | 3 +- .../Library/SearchEngine.cs | 2 +- .../Library/UserViewManager.cs | 2 +- .../LiveTv/EmbyTV/EmbyTV.cs | 8 +-- .../LiveTv/LiveTvManager.cs | 22 ++++---- .../Playlists/PlaylistImageProvider.cs | 5 +- .../Session/SessionManager.cs | 50 +++++++++---------- .../UserViews/DynamicImageProvider.cs | 5 +- MediaBrowser.Api/Movies/MoviesService.cs | 2 - MediaBrowser.Api/TvShowsService.cs | 2 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 2 +- .../Extensions/CollectionExtensions.cs | 37 ++++++++------ MediaBrowser.Controller/Entities/Folder.cs | 5 +- .../Entities/InternalItemsQuery.cs | 2 +- MediaBrowser.Controller/Entities/TV/Series.cs | 4 +- .../Entities/UserViewBuilder.cs | 8 +-- MediaBrowser.Controller/Playlists/Playlist.cs | 2 +- 22 files changed, 114 insertions(+), 120 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index d22fc2177..438ca39ea 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -425,10 +425,10 @@ namespace Emby.Dlna.ContentDirectory { var folder = (Folder)item; - var sortOrders = new List(); + var sortOrders = new List<(string, SortOrder)>(); if (!folder.IsPreSorted) { - sortOrders.Add(ItemSortBy.SortName); + sortOrders.Add((ItemSortBy.SortName, sort.SortOrder)); } var mediaTypes = new List(); @@ -464,7 +464,7 @@ namespace Emby.Dlna.ContentDirectory { Limit = limit, StartIndex = startIndex, - OrderBy = sortOrders.Select(i => new ValueTuple(i, sort.SortOrder)).ToArray(), + OrderBy = sortOrders, User = user, Recursive = true, IsMissing = false, @@ -872,10 +872,10 @@ namespace Emby.Dlna.ContentDirectory query.Parent = parent; query.SetUser(user); - query.OrderBy = new ValueTuple[] + query.OrderBy = new[] { - new ValueTuple (ItemSortBy.DatePlayed, SortOrder.Descending), - new ValueTuple (ItemSortBy.SortName, SortOrder.Ascending) + (ItemSortBy.DatePlayed, SortOrder.Descending), + (ItemSortBy.SortName, SortOrder.Ascending) }; query.IsResumable = true; @@ -1121,7 +1121,7 @@ namespace Emby.Dlna.ContentDirectory private QueryResult GetMusicLatest(BaseItem parent, User user, InternalItemsQuery query) { - query.OrderBy = new ValueTuple[] { }; + query.OrderBy = Array.Empty<(string, SortOrder)>(); var items = _userViewManager.GetLatestItems(new LatestItemsQuery { @@ -1138,7 +1138,7 @@ namespace Emby.Dlna.ContentDirectory private QueryResult GetNextUp(BaseItem parent, User user, InternalItemsQuery query) { - query.OrderBy = new ValueTuple[] { }; + query.OrderBy = Array.Empty<(string, SortOrder)>(); var result = _tvSeriesManager.GetNextUp(new NextUpQuery { @@ -1153,7 +1153,7 @@ namespace Emby.Dlna.ContentDirectory private QueryResult GetTvLatest(BaseItem parent, User user, InternalItemsQuery query) { - query.OrderBy = new ValueTuple[] { }; + query.OrderBy = Array.Empty<(string, SortOrder)>(); var items = _userViewManager.GetLatestItems(new LatestItemsQuery { @@ -1170,7 +1170,7 @@ namespace Emby.Dlna.ContentDirectory private QueryResult GetMovieLatest(BaseItem parent, User user, InternalItemsQuery query) { - query.OrderBy = new ValueTuple[] { }; + query.OrderBy = Array.Empty<(string, SortOrder)>(); var items = _userViewManager.GetLatestItems(new LatestItemsQuery { @@ -1274,13 +1274,13 @@ namespace Emby.Dlna.ContentDirectory private void SetSorting(InternalItemsQuery query, SortCriteria sort, bool isPreSorted) { - var sortOrders = new List(); - if (!isPreSorted) + if (isPreSorted) { - sortOrders.Add(ItemSortBy.SortName); + query.OrderBy = Array.Empty<(string, SortOrder)>(); + } + { + query.OrderBy = new[] { (ItemSortBy.SortName, sort.SortOrder) }; } - - query.OrderBy = sortOrders.Select(i => new ValueTuple(i, sort.SortOrder)).ToArray(); } private QueryResult ApplyPaging(QueryResult result, int? startIndex, int? limit) diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 8e5f5b561..54a027dac 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -510,7 +510,7 @@ namespace Emby.Server.Implementations.Channels return _libraryManager.GetItemIds(new InternalItemsQuery { IncludeItemTypes = new[] { typeof(Channel).Name }, - OrderBy = new ValueTuple[] { new ValueTuple(ItemSortBy.SortName, SortOrder.Ascending) } + OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) } }).Select(i => GetChannelFeatures(i.ToString("N", CultureInfo.InvariantCulture))).ToArray(); } @@ -618,16 +618,16 @@ namespace Emby.Server.Implementations.Channels { query.OrderBy = new[] { - new ValueTuple(ItemSortBy.PremiereDate, SortOrder.Descending), - new ValueTuple(ItemSortBy.ProductionYear, SortOrder.Descending), - new ValueTuple(ItemSortBy.DateCreated, SortOrder.Descending) + (ItemSortBy.PremiereDate, SortOrder.Descending), + (ItemSortBy.ProductionYear, SortOrder.Descending), + (ItemSortBy.DateCreated, SortOrder.Descending) }; } else { query.OrderBy = new[] { - new ValueTuple(ItemSortBy.DateCreated, SortOrder.Descending) + (ItemSortBy.DateCreated, SortOrder.Descending) }; } diff --git a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs index 0244c4a68..bbb3114ca 100644 --- a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs +++ b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs @@ -76,7 +76,6 @@ namespace Emby.Server.Implementations.Collections .Where(i => i != null) .GroupBy(x => x.Id) .Select(x => x.First()) - .OrderBy(i => Guid.NewGuid()) .ToList(); } diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 31a661c5d..b372ab55c 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Runtime.Serialization; using System.Text; using System.Text.Json; -using System.Text.Json.Serialization; using System.Threading; using Emby.Server.Implementations.Playlists; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Json; using MediaBrowser.Controller; using MediaBrowser.Controller.Channels; @@ -2832,8 +2831,8 @@ namespace Emby.Server.Implementations.Data BindSimilarParams(query, statement); BindSearchParams(query, statement); - // Running this again will bind the params - GetWhereClauses(query, statement); + // Running this again will bind the params + GetWhereClauses(query, statement); var hasEpisodeAttributes = HasEpisodeAttributes(query); var hasServiceName = HasServiceName(query); @@ -2882,14 +2881,14 @@ namespace Emby.Server.Implementations.Data private string GetOrderByText(InternalItemsQuery query) { + var orderBy = query.OrderBy; if (string.IsNullOrEmpty(query.SearchTerm)) { - int oldLen = query.OrderBy.Length; - - if (query.SimilarTo != null && oldLen == 0) + int oldLen = orderBy.Count; + if (oldLen == 0 && query.SimilarTo != null) { var arr = new (string, SortOrder)[oldLen + 2]; - query.OrderBy.CopyTo(arr, 0); + orderBy.CopyTo(arr, 0); arr[oldLen] = ("SimilarityScore", SortOrder.Descending); arr[oldLen + 1] = (ItemSortBy.Random, SortOrder.Ascending); query.OrderBy = arr; @@ -2897,16 +2896,15 @@ namespace Emby.Server.Implementations.Data } else { - query.OrderBy = new [] + query.OrderBy = new[] { ("SearchScore", SortOrder.Descending), (ItemSortBy.SortName, SortOrder.Ascending) }; } - var orderBy = query.OrderBy; - if (orderBy.Length == 0) + if (orderBy.Count == 0) { return string.Empty; } @@ -2914,14 +2912,8 @@ namespace Emby.Server.Implementations.Data return " ORDER BY " + string.Join(",", orderBy.Select(i => { var columnMap = MapOrderByField(i.Item1, query); - var columnAscending = i.Item2 == SortOrder.Ascending; - const bool enableOrderInversion = false; - if (columnMap.Item2 && enableOrderInversion) - { - columnAscending = !columnAscending; - } - var sortOrder = columnAscending ? "ASC" : "DESC"; + var sortOrder = i.Item2 == SortOrder.Ascending ? "ASC" : "DESC"; return columnMap.Item1 + " " + sortOrder; })); diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 87e951f25..9a2a6dc5f 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -829,7 +829,7 @@ namespace Emby.Server.Implementations.Library { Path = path, IsFolder = isFolder, - OrderBy = new[] { ItemSortBy.DateCreated }.Select(i => new ValueTuple(i, SortOrder.Descending)).ToArray(), + OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending) }, Limit = 1, DtoOptions = new DtoOptions(true) }; @@ -1257,7 +1257,7 @@ namespace Emby.Server.Implementations.Library public List GetItemList(InternalItemsQuery query, bool allowExternalContent) { - if (query.Recursive && !query.ParentId.Equals(Guid.Empty)) + if (query.Recursive && query.ParentId != Guid.Empty) { var parent = GetItemById(query.ParentId); if (parent != null) diff --git a/Emby.Server.Implementations/Library/MusicManager.cs b/Emby.Server.Implementations/Library/MusicManager.cs index 10602fea7..75cb67fcc 100644 --- a/Emby.Server.Implementations/Library/MusicManager.cs +++ b/Emby.Server.Implementations/Library/MusicManager.cs @@ -89,10 +89,9 @@ namespace Emby.Server.Implementations.Library Limit = 200, - OrderBy = new[] { new ValueTuple(ItemSortBy.Random, SortOrder.Ascending) }, + OrderBy = new[] { (ItemSortBy.Random, SortOrder.Ascending) }, DtoOptions = dtoOptions - }); } diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index 9c7f7dfcb..c10b77a24 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -162,7 +162,7 @@ namespace Emby.Server.Implementations.Library Limit = query.Limit, IncludeItemsByName = string.IsNullOrEmpty(query.ParentId), ParentId = string.IsNullOrEmpty(query.ParentId) ? Guid.Empty : new Guid(query.ParentId), - OrderBy = new[] { new ValueTuple(ItemSortBy.SortName, SortOrder.Ascending) }, + OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) }, Recursive = true, IsKids = query.IsKids, diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index 88e2a8fa6..1b0813280 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -340,7 +340,7 @@ namespace Emby.Server.Implementations.Library var query = new InternalItemsQuery(user) { IncludeItemTypes = includeItemTypes, - OrderBy = new[] { new ValueTuple(ItemSortBy.DateCreated, SortOrder.Descending) }, + OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending) }, IsFolder = includeItemTypes.Length == 0 ? false : (bool?)null, ExcludeItemTypes = excludeItemTypes, IsVirtualItem = false, diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index da0013f12..7b0cd4022 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1580,15 +1580,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return; } - var episodesToDelete = (librarySeries.GetItemList(new InternalItemsQuery + var episodesToDelete = librarySeries.GetItemList(new InternalItemsQuery { - OrderBy = new[] { new ValueTuple(ItemSortBy.DateCreated, SortOrder.Descending) }, + OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending) }, IsVirtualItem = false, IsFolder = false, Recursive = true, DtoOptions = new DtoOptions(true) - })) + }) .Where(i => i.IsFileProtocol && File.Exists(i.Path)) .Skip(seriesTimer.KeepUpTo - 1) .ToList(); @@ -2258,7 +2258,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV }, MinStartDate = startDateUtc.AddMinutes(-3), MaxStartDate = startDateUtc.AddMinutes(3), - OrderBy = new[] { new ValueTuple(ItemSortBy.StartDate, SortOrder.Ascending) } + OrderBy = new[] { (ItemSortBy.StartDate, SortOrder.Ascending) } }; if (!string.IsNullOrWhiteSpace(channelId)) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 89b92c999..c2350684b 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -209,16 +209,16 @@ namespace Emby.Server.Implementations.LiveTv var orderBy = internalQuery.OrderBy.ToList(); - orderBy.AddRange(query.SortBy.Select(i => new ValueTuple(i, query.SortOrder ?? SortOrder.Ascending))); + orderBy.AddRange(query.SortBy.Select(i => (i, query.SortOrder ?? SortOrder.Ascending))); if (query.EnableFavoriteSorting) { - orderBy.Insert(0, new ValueTuple(ItemSortBy.IsFavoriteOrLiked, SortOrder.Descending)); + orderBy.Insert(0, (ItemSortBy.IsFavoriteOrLiked, SortOrder.Descending)); } if (!internalQuery.OrderBy.Any(i => string.Equals(i.Item1, ItemSortBy.SortName, StringComparison.OrdinalIgnoreCase))) { - orderBy.Add(new ValueTuple(ItemSortBy.SortName, SortOrder.Ascending)); + orderBy.Add((ItemSortBy.SortName, SortOrder.Ascending)); } internalQuery.OrderBy = orderBy.ToArray(); @@ -772,22 +772,22 @@ namespace Emby.Server.Implementations.LiveTv var topFolder = GetInternalLiveTvFolder(cancellationToken); - if (query.OrderBy.Length == 0) + if (query.OrderBy.Count == 0) { if (query.IsAiring ?? false) { // Unless something else was specified, order by start date to take advantage of a specialized index - query.OrderBy = new ValueTuple[] + query.OrderBy = new[] { - new ValueTuple(ItemSortBy.StartDate, SortOrder.Ascending) + (ItemSortBy.StartDate, SortOrder.Ascending) }; } else { // Unless something else was specified, order by start date to take advantage of a specialized index - query.OrderBy = new ValueTuple[] + query.OrderBy = new[] { - new ValueTuple(ItemSortBy.StartDate, SortOrder.Ascending) + (ItemSortBy.StartDate, SortOrder.Ascending) }; } } @@ -871,7 +871,7 @@ namespace Emby.Server.Implementations.LiveTv IsSports = query.IsSports, IsKids = query.IsKids, EnableTotalRecordCount = query.EnableTotalRecordCount, - OrderBy = new[] { new ValueTuple(ItemSortBy.StartDate, SortOrder.Ascending) }, + OrderBy = new[] { (ItemSortBy.StartDate, SortOrder.Ascending) }, TopParentIds = new[] { topFolder.Id }, DtoOptions = options, GenreIds = query.GenreIds @@ -1393,7 +1393,7 @@ namespace Emby.Server.Implementations.LiveTv IsVirtualItem = false, Limit = limit, StartIndex = query.StartIndex, - OrderBy = new[] { new ValueTuple(ItemSortBy.DateCreated, SortOrder.Descending) }, + OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending) }, EnableTotalRecordCount = query.EnableTotalRecordCount, IncludeItemTypes = includeItemTypes.ToArray(), ExcludeItemTypes = excludeItemTypes.ToArray(), @@ -1891,7 +1891,7 @@ namespace Emby.Server.Implementations.LiveTv MaxStartDate = now, MinEndDate = now, Limit = channelIds.Length, - OrderBy = new[] { new ValueTuple(ItemSortBy.StartDate, SortOrder.Ascending) }, + OrderBy = new[] { (ItemSortBy.StartDate, SortOrder.Ascending) }, TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Id }, DtoOptions = options diff --git a/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs b/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs index cad66a80f..2dfe59088 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs @@ -62,7 +62,6 @@ namespace Emby.Server.Implementations.Playlists return null; }) .Where(i => i != null) - .OrderBy(i => Guid.NewGuid()) .GroupBy(x => x.Id) .Select(x => x.First()) .ToList(); @@ -84,7 +83,7 @@ namespace Emby.Server.Implementations.Playlists { Genres = new[] { item.Name }, IncludeItemTypes = new[] { typeof(MusicAlbum).Name, typeof(MusicVideo).Name, typeof(Audio).Name }, - OrderBy = new[] { new ValueTuple(ItemSortBy.Random, SortOrder.Ascending) }, + OrderBy = new[] { (ItemSortBy.Random, SortOrder.Ascending) }, Limit = 4, Recursive = true, ImageTypes = new[] { ImageType.Primary }, @@ -108,7 +107,7 @@ namespace Emby.Server.Implementations.Playlists { Genres = new[] { item.Name }, IncludeItemTypes = new[] { typeof(Series).Name, typeof(Movie).Name }, - OrderBy = new[] { new ValueTuple(ItemSortBy.Random, SortOrder.Ascending) }, + OrderBy = new[] { (ItemSortBy.Random, SortOrder.Ascending) }, Limit = 4, Recursive = true, ImageTypes = new[] { ImageType.Primary }, diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 61329160a..68cd3c0ba 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1061,7 +1061,7 @@ namespace Emby.Server.Implementations.Session var session = GetSessionToRemoteControl(sessionId); - var user = !session.UserId.Equals(Guid.Empty) ? _userManager.GetUserById(session.UserId) : null; + var user = session.UserId == Guid.Empty ? null : _userManager.GetUserById(session.UserId); List items; @@ -1086,7 +1086,7 @@ namespace Emby.Server.Implementations.Session if (command.PlayCommand == PlayCommand.PlayShuffle) { - items = items.OrderBy(i => Guid.NewGuid()).ToList(); + items.Shuffle(); command.PlayCommand = PlayCommand.PlayNow; } @@ -1100,28 +1100,27 @@ namespace Emby.Server.Implementations.Session } } - if (user != null && command.ItemIds.Length == 1 && user.Configuration.EnableNextEpisodeAutoPlay) + if (user != null + && command.ItemIds.Length == 1 + && user.Configuration.EnableNextEpisodeAutoPlay + && _libraryManager.GetItemById(command.ItemIds[0]) is Episode episode) { - var episode = _libraryManager.GetItemById(command.ItemIds[0]) as Episode; - if (episode != null) + var series = episode.Series; + if (series != null) { - var series = episode.Series; - if (series != null) - { - var episodes = series.GetEpisodes( - user, - new DtoOptions(false) - { - EnableImages = false - }) - .Where(i => !i.IsVirtualItem) - .SkipWhile(i => i.Id != episode.Id) - .ToList(); + var episodes = series.GetEpisodes( + user, + new DtoOptions(false) + { + EnableImages = false + }) + .Where(i => !i.IsVirtualItem) + .SkipWhile(i => i.Id != episode.Id) + .ToList(); - if (episodes.Count > 0) - { - command.ItemIds = episodes.Select(i => i.Id).ToArray(); - } + if (episodes.Count > 0) + { + command.ItemIds = episodes.Select(i => i.Id).ToArray(); } } } @@ -1146,7 +1145,7 @@ namespace Emby.Server.Implementations.Session if (item == null) { _logger.LogError("A non-existant item Id {0} was passed into TranslateItemForPlayback", id); - return new List(); + return Array.Empty(); } if (item is IItemByName byName) @@ -1164,7 +1163,7 @@ namespace Emby.Server.Implementations.Session } }, IsVirtualItem = false, - OrderBy = new ValueTuple[] { new ValueTuple(ItemSortBy.SortName, SortOrder.Ascending) } + OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) } }); } @@ -1185,12 +1184,11 @@ namespace Emby.Server.Implementations.Session } }, IsVirtualItem = false, - OrderBy = new ValueTuple[] { new ValueTuple(ItemSortBy.SortName, SortOrder.Ascending) } - + OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) } }); } - return new List { item }; + return new[] { item }; } private IEnumerable TranslateItemForInstantMix(Guid id, User user) diff --git a/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs b/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs index f48520443..78ac95f85 100644 --- a/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs +++ b/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs @@ -86,20 +86,17 @@ namespace Emby.Server.Implementations.UserViews { return items .Where(i => i.HasImage(ImageType.Primary) || i.HasImage(ImageType.Thumb)) - .OrderBy(i => Guid.NewGuid()) .ToList(); } return items .Where(i => i.HasImage(ImageType.Primary)) - .OrderBy(i => Guid.NewGuid()) .ToList(); } protected override bool Supports(BaseItem item) { - var view = item as UserView; - if (view != null) + if (item is UserView view) { return IsUsingCollectionStrip(view); } diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index c1c6ffc2e..8a3fdcbcb 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -191,12 +191,10 @@ namespace MediaBrowser.Api.Movies var mostRecentMovies = recentlyPlayedMovies.Take(6).ToList(); // Get recently played directors var recentDirectors = GetDirectors(mostRecentMovies) - .OrderBy(i => Guid.NewGuid()) .ToList(); // Get recently played actors var recentActors = GetActors(mostRecentMovies) - .OrderBy(i => Guid.NewGuid()) .ToList(); var similarToRecentlyPlayed = GetSimilarTo(user, recentlyPlayedMovies, itemLimit, dtoOptions, RecommendationType.SimilarToRecentlyPlayed).GetEnumerator(); diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 1340bd8ef..caff20084 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -482,7 +482,7 @@ namespace MediaBrowser.Api if (string.Equals(request.SortBy, ItemSortBy.Random, StringComparison.OrdinalIgnoreCase)) { - episodes = episodes.OrderBy(i => Guid.NewGuid()).ToList(); + episodes.Shuffle(); } var returnItems = episodes; diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index b4a302648..6e7351240 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -476,7 +476,7 @@ namespace MediaBrowser.Api.UserLibrary } // Apply default sorting if none requested - if (query.OrderBy.Length == 0) + if (query.OrderBy.Count == 0) { // Albums by artist if (query.ArtistIds.Length > 0 && query.IncludeItemTypes.Length == 1 && string.Equals(query.IncludeItemTypes[0], "MusicAlbum", StringComparison.OrdinalIgnoreCase)) diff --git a/MediaBrowser.Common/Extensions/CollectionExtensions.cs b/MediaBrowser.Common/Extensions/CollectionExtensions.cs index 215224398..a12b2833f 100644 --- a/MediaBrowser.Common/Extensions/CollectionExtensions.cs +++ b/MediaBrowser.Common/Extensions/CollectionExtensions.cs @@ -1,5 +1,6 @@ #pragma warning disable CS1591 +using System; using System.Collections.Generic; namespace MediaBrowser.Common.Extensions @@ -7,6 +8,26 @@ namespace MediaBrowser.Common.Extensions // The MS CollectionExtensions are only available in netcoreapp public static class CollectionExtensions { + private static readonly Random _rng = new Random(); + + /// + /// Shuffles the items in a list. + /// + /// The list that should get shuffled. + /// The type. + public static void Shuffle(this IList list) + { + int n = list.Count; + while (n > 1) + { + n--; + int k = _rng.Next(n + 1); + T value = list[k]; + list[k] = list[n]; + list[n] = value; + } + } + public static TValue GetValueOrDefault(this IReadOnlyDictionary dictionary, TKey key) { dictionary.TryGetValue(key, out var ret); @@ -28,21 +49,5 @@ namespace MediaBrowser.Common.Extensions destination[index + i] = source[i]; } } - - /// - /// Copies all the elements of the current collection to the specified list - /// starting at the specified destination array index. The index is specified as a 32-bit integer. - /// - /// The current collection that is the source of the elements. - /// The list that is the destination of the elements copied from the current collection. - /// A 32-bit integer that represents the index in destination at which copying begins. - /// - public static void CopyTo(this IReadOnlyCollection source, IList destination, int index = 0) - { - foreach (T item in source) - { - destination[index++] = item; - } - } } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index d61a07066..8e9d11012 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1163,7 +1163,10 @@ namespace MediaBrowser.Controller.Entities } //the true root should return our users root folder children - if (IsPhysicalRoot) return LibraryManager.GetUserRootFolder().GetChildren(user, includeLinkedChildren); + if (IsPhysicalRoot) + { + return LibraryManager.GetUserRootFolder().GetChildren(user, includeLinkedChildren); + } var result = new Dictionary(); diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 78f859069..bd96059e3 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Entities public bool EnableGroupByMetadataKey { get; set; } public bool? HasChapterImages { get; set; } - public ValueTuple[] OrderBy { get; set; } + public IReadOnlyList<(string, SortOrder)> OrderBy { get; set; } public DateTime? MinDateCreated { get; set; } public DateTime? MinDateLastSaved { get; set; } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index a50da9b0a..d43555102 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -226,14 +226,16 @@ namespace MediaBrowser.Controller.Entities.TV query.AncestorWithPresentationUniqueKey = null; query.SeriesPresentationUniqueKey = seriesKey; - if (query.OrderBy.Length == 0) + if (query.OrderBy.Count == 0) { query.OrderBy = new[] { ItemSortBy.SortName }.Select(i => new ValueTuple(i, SortOrder.Ascending)).ToArray(); } + if (query.IncludeItemTypes.Length == 0) { query.IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name }; } + query.IsVirtualItem = false; return LibraryManager.GetItemsResult(query); } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 454bdc4ae..435a1e8da 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -450,14 +450,16 @@ namespace MediaBrowser.Controller.Entities return SortAndPage(items, totalRecordLimit, query, libraryManager, true); } - public static QueryResult SortAndPage(IEnumerable items, + public static QueryResult SortAndPage( + IEnumerable items, int? totalRecordLimit, InternalItemsQuery query, - ILibraryManager libraryManager, bool enableSorting) + ILibraryManager libraryManager, + bool enableSorting) { if (enableSorting) { - if (query.OrderBy.Length > 0) + if (query.OrderBy.Count > 0) { items = libraryManager.Sort(items, query.User, query.OrderBy); } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index aff687f88..bef7eff06 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -181,7 +181,7 @@ namespace MediaBrowser.Controller.Playlists { Recursive = true, IsFolder = false, - OrderBy = new[] { ItemSortBy.SortName }.Select(i => new ValueTuple(i, SortOrder.Ascending)).ToArray(), + OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) }, MediaTypes = new[] { mediaType }, EnableTotalRecordCount = false, DtoOptions = options From 3221e837f9758e90b91f0f6760af1c3b67e04c2d Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 17 Nov 2019 23:05:39 +0100 Subject: [PATCH 02/53] * Add support for multi segment base urls * Make baseurl case-insensitive --- Emby.Dlna/Api/DlnaServerService.cs | 118 +++++--- .../ContentDirectory/ContentDirectory.cs | 5 +- .../Library/UserDataManager.cs | 6 +- .../Library/UserManager.cs | 4 - .../Tasks/DeleteTranscodeFileTask.cs | 9 +- MediaBrowser.Api/ApiEntryPoint.cs | 256 +++--------------- MediaBrowser.Api/BaseApiService.cs | 153 ++++++++--- MediaBrowser.Api/BrandingService.cs | 16 +- MediaBrowser.Api/ChannelService.cs | 10 +- MediaBrowser.Api/ConfigurationService.cs | 21 +- MediaBrowser.Api/Devices/DeviceService.cs | 12 +- MediaBrowser.Api/DisplayPreferencesService.cs | 10 +- MediaBrowser.Api/EnvironmentService.cs | 19 +- MediaBrowser.Api/FilterService.cs | 10 +- MediaBrowser.Api/Images/ImageByNameService.cs | 24 +- MediaBrowser.Api/Images/ImageService.cs | 33 ++- MediaBrowser.Api/Images/RemoteImageService.cs | 16 +- MediaBrowser.Api/ItemLookupService.cs | 13 +- MediaBrowser.Api/ItemRefreshService.cs | 12 +- MediaBrowser.Api/ItemUpdateService.cs | 21 +- MediaBrowser.Api/Library/LibraryService.cs | 52 ++-- .../Library/LibraryStructureService.cs | 21 +- MediaBrowser.Api/LiveTv/LiveTvService.cs | 18 +- MediaBrowser.Api/LocalizationService.cs | 9 +- MediaBrowser.Api/Movies/CollectionService.cs | 11 +- MediaBrowser.Api/Movies/MoviesService.cs | 23 +- MediaBrowser.Api/Movies/TrailersService.cs | 32 ++- MediaBrowser.Api/Music/AlbumsService.cs | 14 +- MediaBrowser.Api/Music/InstantMixService.cs | 13 +- MediaBrowser.Api/PackageService.cs | 13 +- .../Playback/BaseStreamingService.cs | 14 +- .../Playback/Hls/BaseHlsService.cs | 62 +++-- .../Playback/Hls/DynamicHlsService.cs | 10 +- .../Playback/Hls/HlsSegmentService.cs | 17 +- .../Playback/Hls/VideoHlsService.cs | 10 +- MediaBrowser.Api/Playback/MediaInfoService.cs | 16 +- .../Playback/Progressive/AudioService.cs | 34 ++- .../BaseProgressiveStreamingService.cs | 10 +- .../Playback/Progressive/VideoService.cs | 12 +- .../Playback/UniversalAudioService.cs | 68 +++-- MediaBrowser.Api/PlaylistService.cs | 13 +- MediaBrowser.Api/PluginService.cs | 27 +- MediaBrowser.Api/Properties/AssemblyInfo.cs | 2 + .../ScheduledTasks/ScheduledTaskService.cs | 39 ++- MediaBrowser.Api/SearchService.cs | 12 +- MediaBrowser.Api/Session/SessionsService.cs | 21 +- MediaBrowser.Api/StartupWizardService.cs | 45 ++- MediaBrowser.Api/Subtitles/SubtitleService.cs | 14 +- MediaBrowser.Api/SuggestionsService.cs | 12 +- MediaBrowser.Api/System/ActivityLogService.cs | 9 +- MediaBrowser.Api/System/SystemService.cs | 13 +- MediaBrowser.Api/TranscodingJob.cs | 160 +++++++++++ MediaBrowser.Api/TvShowsService.cs | 23 +- .../UserLibrary/ArtistsService.cs | 28 +- .../UserLibrary/BaseItemsByNameService.cs | 45 +-- MediaBrowser.Api/UserLibrary/GenresService.cs | 27 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 30 +- .../UserLibrary/MusicGenresService.cs | 28 +- .../UserLibrary/PersonsService.cs | 27 +- .../UserLibrary/PlaystateService.cs | 17 +- .../UserLibrary/StudiosService.cs | 28 +- .../UserLibrary/UserLibraryService.cs | 15 +- .../UserLibrary/UserViewsService.cs | 5 + MediaBrowser.Api/UserLibrary/YearsService.cs | 27 +- MediaBrowser.Api/UserService.cs | 13 +- MediaBrowser.Api/VideosService.cs | 24 +- .../Library/IUserDataManager.cs | 4 +- .../Library/IUserManager.cs | 9 +- .../Configuration/ServerConfiguration.cs | 8 +- .../Savers/BaseNfoSaver.cs | 3 +- MediaBrowser.sln | 7 + tests/Jellyfin.Api.Tests/GetPathValueTests.cs | 45 +++ .../Jellyfin.Api.Tests.csproj | 20 ++ 73 files changed, 1285 insertions(+), 742 deletions(-) create mode 100644 MediaBrowser.Api/TranscodingJob.cs create mode 100644 tests/Jellyfin.Api.Tests/GetPathValueTests.cs create mode 100644 tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 1f137e620..f64c89389 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using Emby.Dlna.Main; @@ -195,7 +193,7 @@ namespace Emby.Dlna.Api private ControlResponse PostAsync(Stream requestStream, IUpnpService service) { - var id = GetPathValue(2); + var id = GetPathValue(2).ToString(); return service.ProcessControlRequest(new ControlRequest { @@ -206,49 +204,103 @@ namespace Emby.Dlna.Api }); } - protected string GetPathValue(int index) + // Copied from MediaBrowser.Api/BaseApiService.cs + // TODO: Remove code duplication + /// + /// Gets the path segment at the specified index. + /// + /// The index of the path segment. + /// The path segment at the specified index. + /// Path doesn't contain enough segments. + /// Path doesn't start with the base url. + protected internal ReadOnlySpan GetPathValue(int index) { - var pathInfo = Parse(Request.PathInfo); - var first = pathInfo[0]; - - string baseUrl = _configurationManager.Configuration.BaseUrl; - - // backwards compatibility - if (baseUrl.Length == 0 - && (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) - || string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase))) + static void ThrowIndexOutOfRangeException() { - index++; + throw new IndexOutOfRangeException("Path doesn't contain enough segments."); } - else if (string.Equals(first, baseUrl.Remove(0, 1))) + + static void ThrowInvalidDataException() { - index++; - var second = pathInfo[1]; - if (string.Equals(second, "mediabrowser", StringComparison.OrdinalIgnoreCase) - || string.Equals(second, "emby", StringComparison.OrdinalIgnoreCase)) + throw new InvalidDataException("Path doesn't start with the base url."); + } + + ReadOnlySpan path = Request.PathInfo; + + // Remove the protocol part from the url + int pos = path.LastIndexOf("://"); + if (pos != -1) + { + path = path.Slice(pos + 3); + } + + // Remove the query string + pos = path.LastIndexOf('?'); + if (pos != -1) + { + path = path.Slice(0, pos); + } + + // Remove the domain + pos = path.IndexOf('/'); + if (pos != -1) + { + path = path.Slice(pos); + } + + // Remove base url + string baseUrl = _configurationManager.Configuration.BaseUrl; + int baseUrlLen = baseUrl.Length; + if (baseUrlLen != 0) + { + if (path.StartsWith(baseUrl, StringComparison.OrdinalIgnoreCase)) { - index++; + path = path.Slice(baseUrlLen); + } + else + { + // The path doesn't start with the base url, + // how did we get here? + ThrowInvalidDataException(); } } - return pathInfo[index]; - } + // Remove leading / + path = path.Slice(1); - private List Parse(string pathUri) - { - var actionParts = pathUri.Split(new[] { "://" }, StringSplitOptions.None); - - var pathInfo = actionParts[actionParts.Length - 1]; - - var optionsPos = pathInfo.LastIndexOf('?'); - if (optionsPos != -1) + // Backwards compatibility + const string Emby = "emby/"; + if (path.StartsWith(Emby, StringComparison.OrdinalIgnoreCase)) { - pathInfo = pathInfo.Substring(0, optionsPos); + path = path.Slice(Emby.Length); } - var args = pathInfo.Split('/'); + const string MediaBrowser = "mediabrowser/"; + if (path.StartsWith(MediaBrowser, StringComparison.OrdinalIgnoreCase)) + { + path = path.Slice(MediaBrowser.Length); + } - return args.Skip(1).ToList(); + // Skip segments until we are at the right index + for (int i = 0; i < index; i++) + { + pos = path.IndexOf('/'); + if (pos == -1) + { + ThrowIndexOutOfRangeException(); + } + + path = path.Slice(pos + 1); + } + + // Remove the rest + pos = path.IndexOf('/'); + if (pos != -1) + { + path = path.Slice(0, pos); + } + + return path; } public object Get(GetIcon request) diff --git a/Emby.Dlna/ContentDirectory/ContentDirectory.cs b/Emby.Dlna/ContentDirectory/ContentDirectory.cs index 5175898ab..78d69b338 100644 --- a/Emby.Dlna/ContentDirectory/ContentDirectory.cs +++ b/Emby.Dlna/ContentDirectory/ContentDirectory.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Emby.Dlna.Service; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; @@ -104,7 +103,7 @@ namespace Emby.Dlna.ContentDirectory { if (!string.IsNullOrEmpty(profile.UserId)) { - var user = _userManager.GetUserById(profile.UserId); + var user = _userManager.GetUserById(Guid.Parse(profile.UserId)); if (user != null) { @@ -116,7 +115,7 @@ namespace Emby.Dlna.ContentDirectory if (!string.IsNullOrEmpty(userId)) { - var user = _userManager.GetUserById(userId); + var user = _userManager.GetUserById(Guid.Parse(userId)); if (user != null) { diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index 36adc0b9c..e6d2b7ae0 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -55,6 +55,7 @@ namespace Emby.Server.Implementations.Library { throw new ArgumentNullException(nameof(userData)); } + if (item == null) { throw new ArgumentNullException(nameof(item)); @@ -160,11 +161,6 @@ namespace Emby.Server.Implementations.Library return GetUserData(user, item.Id, item.GetUserDataKeys()); } - public UserItemData GetUserData(string userId, BaseItem item) - { - return GetUserData(new Guid(userId), item); - } - public UserItemData GetUserData(Guid userId, BaseItem item) { return GetUserData(userId, item.Id, item.GetUserDataKeys()); diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 2b22129f3..e1b031e45 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -194,10 +194,6 @@ namespace Emby.Server.Implementations.Library return user; } - /// - public User GetUserById(string id) - => GetUserById(new Guid(id)); - public User GetUserByName(string name) { if (string.IsNullOrWhiteSpace(name)) diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs index 91d990137..f197734d4 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs @@ -31,13 +31,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks } /// - /// Creates the triggers that define when the task will run + /// Creates the triggers that define when the task will run. /// /// IEnumerable{BaseTaskTrigger}. public IEnumerable GetDefaultTriggers() => new List(); /// - /// Returns the task to be executed + /// Returns the task to be executed. /// /// The cancellation token. /// The progress. @@ -47,14 +47,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks var minDateModified = DateTime.UtcNow.AddDays(-1); progress.Report(50); - DeleteTempFilesFromDirectory(cancellationToken, _configurationManager.GetTranscodingTempPath(), minDateModified, progress); + DeleteTempFilesFromDirectory(cancellationToken, _configurationManager.GetTranscodePath(), minDateModified, progress); return Task.CompletedTask; } - /// - /// Deletes the transcoded temp files from directory with a last write time less than a given date + /// Deletes the transcoded temp files from directory with a last write time less than a given date. /// /// The task cancellation token. /// The directory. diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 0542807af..1a3657c92 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -10,11 +10,9 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Diagnostics; -using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.IO; using MediaBrowser.Model.Session; using Microsoft.Extensions.Logging; @@ -22,26 +20,24 @@ using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { /// - /// Class ServerEntryPoint + /// Class ServerEntryPoint. /// public class ApiEntryPoint : IServerEntryPoint { /// - /// The instance + /// The instance. /// public static ApiEntryPoint Instance; /// - /// Gets or sets the logger. + /// The logger. /// - /// The logger. - internal ILogger Logger { get; private set; } - internal IHttpResultFactory ResultFactory { get; private set; } + private ILogger _logger; /// - /// Gets the configuration manager. + /// The configuration manager. /// - internal IServerConfigurationManager ConfigurationManager { get; } + private IServerConfigurationManager _serverConfigurationManager; private readonly ISessionManager _sessionManager; private readonly IFileSystem _fileSystem; @@ -70,18 +66,16 @@ namespace MediaBrowser.Api ISessionManager sessionManager, IServerConfigurationManager config, IFileSystem fileSystem, - IMediaSourceManager mediaSourceManager, - IHttpResultFactory resultFactory) + IMediaSourceManager mediaSourceManager) { - Logger = logger; + _logger = logger; _sessionManager = sessionManager; - ConfigurationManager = config; + _serverConfigurationManager = config; _fileSystem = fileSystem; _mediaSourceManager = mediaSourceManager; - ResultFactory = resultFactory; - _sessionManager.PlaybackProgress += _sessionManager_PlaybackProgress; - _sessionManager.PlaybackStart += _sessionManager_PlaybackStart; + _sessionManager.PlaybackProgress += OnPlaybackProgress; + _sessionManager.PlaybackStart += OnPlaybackStart; Instance = this; } @@ -115,7 +109,7 @@ namespace MediaBrowser.Api } } - private void _sessionManager_PlaybackStart(object sender, PlaybackProgressEventArgs e) + private void OnPlaybackStart(object sender, PlaybackProgressEventArgs e) { if (!string.IsNullOrWhiteSpace(e.PlaySessionId)) { @@ -123,7 +117,7 @@ namespace MediaBrowser.Api } } - void _sessionManager_PlaybackProgress(object sender, PlaybackProgressEventArgs e) + private void OnPlaybackProgress(object sender, PlaybackProgressEventArgs e) { if (!string.IsNullOrWhiteSpace(e.PlaySessionId)) { @@ -140,17 +134,9 @@ namespace MediaBrowser.Api { DeleteEncodedMediaCache(); } - catch (FileNotFoundException) - { - // Don't clutter the log - } - catch (IOException) - { - // Don't clutter the log - } catch (Exception ex) { - Logger.LogError(ex, "Error deleting encoded media cache"); + _logger.LogError(ex, "Error deleting encoded media cache"); } return Task.CompletedTask; @@ -161,8 +147,7 @@ namespace MediaBrowser.Api /// private void DeleteEncodedMediaCache() { - var path = ConfigurationManager.GetTranscodePath(); - + var path = _serverConfigurationManager.GetTranscodePath(); if (!Directory.Exists(path)) { return; @@ -174,9 +159,7 @@ namespace MediaBrowser.Api } } - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { Dispose(true); @@ -219,8 +202,8 @@ namespace MediaBrowser.Api _activeTranscodingJobs.Clear(); _transcodingLocks.Clear(); - _sessionManager.PlaybackProgress -= _sessionManager_PlaybackProgress; - _sessionManager.PlaybackStart -= _sessionManager_PlaybackStart; + _sessionManager.PlaybackProgress -= OnPlaybackProgress; + _sessionManager.PlaybackStart -= OnPlaybackStart; _disposed = true; } @@ -252,7 +235,7 @@ namespace MediaBrowser.Api { lock (_activeTranscodingJobs) { - var job = new TranscodingJob(Logger) + var job = new TranscodingJob(_logger) { Type = type, Path = path, @@ -406,12 +389,13 @@ namespace MediaBrowser.Api public void OnTranscodeEndRequest(TranscodingJob job) { job.ActiveRequestCount--; - Logger.LogDebug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); + _logger.LogDebug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); if (job.ActiveRequestCount <= 0) { PingTimer(job, false); } } + internal void PingTranscodingJob(string playSessionId, bool? isUserPaused) { if (string.IsNullOrEmpty(playSessionId)) @@ -419,7 +403,7 @@ namespace MediaBrowser.Api throw new ArgumentNullException(nameof(playSessionId)); } - Logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); + _logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); List jobs; @@ -434,9 +418,10 @@ namespace MediaBrowser.Api { if (isUserPaused.HasValue) { - Logger.LogDebug("Setting job.IsUserPaused to {0}. jobId: {1}", isUserPaused, job.Id); + _logger.LogDebug("Setting job.IsUserPaused to {0}. jobId: {1}", isUserPaused, job.Id); job.IsUserPaused = isUserPaused.Value; } + PingTimer(job, true); } } @@ -489,7 +474,7 @@ namespace MediaBrowser.Api } } - Logger.LogInformation("Transcoding kill timer stopped for JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); + _logger.LogInformation("Transcoding kill timer stopped for JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); await KillTranscodingJob(job, true, path => true); } @@ -558,7 +543,7 @@ namespace MediaBrowser.Api { job.DisposeKillTimer(); - Logger.LogDebug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); + _logger.LogDebug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); lock (_activeTranscodingJobs) { @@ -590,14 +575,14 @@ namespace MediaBrowser.Api { try { - Logger.LogInformation("Stopping ffmpeg process with q command for {Path}", job.Path); + _logger.LogInformation("Stopping ffmpeg process with q command for {Path}", job.Path); process.StandardInput.WriteLine("q"); // Need to wait because killing is asynchronous if (!process.WaitForExit(5000)) { - Logger.LogInformation("Killing ffmpeg process for {Path}", job.Path); + _logger.LogInformation("Killing ffmpeg process for {Path}", job.Path); process.Kill(); } } @@ -620,7 +605,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.LogError(ex, "Error closing live stream for {Path}", job.Path); + _logger.LogError(ex, "Error closing live stream for {Path}", job.Path); } } } @@ -632,7 +617,7 @@ namespace MediaBrowser.Api return; } - Logger.LogInformation("Deleting partial stream file(s) {Path}", path); + _logger.LogInformation("Deleting partial stream file(s) {Path}", path); await Task.Delay(delayMs).ConfigureAwait(false); @@ -646,20 +631,16 @@ namespace MediaBrowser.Api { DeleteHlsPartialStreamFiles(path); } - } - catch (FileNotFoundException) - { - } catch (IOException ex) { - Logger.LogError(ex, "Error deleting partial stream file(s) {Path}", path); + _logger.LogError(ex, "Error deleting partial stream file(s) {Path}", path); await DeletePartialStreamFiles(path, jobType, retryCount + 1, 500).ConfigureAwait(false); } catch (Exception ex) { - Logger.LogError(ex, "Error deleting partial stream file(s) {Path}", path); + _logger.LogError(ex, "Error deleting partial stream file(s) {Path}", path); } } @@ -669,7 +650,10 @@ namespace MediaBrowser.Api /// The output file path. private void DeleteProgressivePartialStreamFiles(string outputFilePath) { - _fileSystem.DeleteFile(outputFilePath); + if (File.Exists(outputFilePath)) + { + _fileSystem.DeleteFile(outputFilePath); + } } /// @@ -684,178 +668,24 @@ namespace MediaBrowser.Api var filesToDelete = _fileSystem.GetFilePaths(directory) .Where(f => f.IndexOf(name, StringComparison.OrdinalIgnoreCase) != -1); - Exception e = null; - + List exs = null; foreach (var file in filesToDelete) { try { - Logger.LogDebug("Deleting HLS file {0}", file); + _logger.LogDebug("Deleting HLS file {0}", file); _fileSystem.DeleteFile(file); - } - catch (FileNotFoundException) - { - } catch (IOException ex) { - e = ex; - Logger.LogError(ex, "Error deleting HLS file {Path}", file); + (exs ??= new List(4)).Add(ex); + _logger.LogError(ex, "Error deleting HLS file {Path}", file); } } - if (e != null) + if (exs != null) { - throw e; - } - } - } - - /// - /// Class TranscodingJob - /// - public class TranscodingJob - { - /// - /// Gets or sets the play session identifier. - /// - /// The play session identifier. - public string PlaySessionId { get; set; } - /// - /// Gets or sets the live stream identifier. - /// - /// The live stream identifier. - public string LiveStreamId { get; set; } - - public bool IsLiveOutput { get; set; } - - /// - /// Gets or sets the path. - /// - /// The path. - public MediaSourceInfo MediaSource { get; set; } - public string Path { get; set; } - /// - /// Gets or sets the type. - /// - /// The type. - public TranscodingJobType Type { get; set; } - /// - /// Gets or sets the process. - /// - /// The process. - public Process Process { get; set; } - public ILogger Logger { get; private set; } - /// - /// Gets or sets the active request count. - /// - /// The active request count. - public int ActiveRequestCount { get; set; } - /// - /// Gets or sets the kill timer. - /// - /// The kill timer. - private Timer KillTimer { get; set; } - - public string DeviceId { get; set; } - - public CancellationTokenSource CancellationTokenSource { get; set; } - - public object ProcessLock = new object(); - - public bool HasExited { get; set; } - public bool IsUserPaused { get; set; } - - public string Id { get; set; } - - public float? Framerate { get; set; } - public double? CompletionPercentage { get; set; } - - public long? BytesDownloaded { get; set; } - public long? BytesTranscoded { get; set; } - public int? BitRate { get; set; } - - public long? TranscodingPositionTicks { get; set; } - public long? DownloadPositionTicks { get; set; } - - public TranscodingThrottler TranscodingThrottler { get; set; } - - private readonly object _timerLock = new object(); - - public DateTime LastPingDate { get; set; } - public int PingTimeout { get; set; } - - public TranscodingJob(ILogger logger) - { - Logger = logger; - } - - public void StopKillTimer() - { - lock (_timerLock) - { - if (KillTimer != null) - { - KillTimer.Change(Timeout.Infinite, Timeout.Infinite); - } - } - } - - public void DisposeKillTimer() - { - lock (_timerLock) - { - if (KillTimer != null) - { - KillTimer.Dispose(); - KillTimer = null; - } - } - } - - public void StartKillTimer(Action callback) - { - StartKillTimer(callback, PingTimeout); - } - - public void StartKillTimer(Action callback, int intervalMs) - { - if (HasExited) - { - return; - } - - lock (_timerLock) - { - if (KillTimer == null) - { - Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); - KillTimer = new Timer(new TimerCallback(callback), this, intervalMs, Timeout.Infinite); - } - else - { - Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); - KillTimer.Change(intervalMs, Timeout.Infinite); - } - } - } - - public void ChangeKillTimerIfStarted() - { - if (HasExited) - { - return; - } - - lock (_timerLock) - { - if (KillTimer != null) - { - var intervalMs = PingTimeout; - - Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); - KillTimer.Change(intervalMs, Timeout.Infinite); - } + throw new AggregateException("Error deleting HLS files", exs); } } } diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 5f1f6c5b1..41ee314df 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -1,5 +1,7 @@ using System; +using System.IO; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -16,19 +18,35 @@ namespace MediaBrowser.Api /// /// Class BaseApiService /// - public class BaseApiService : IService, IRequiresRequest + public abstract class BaseApiService : IService, IRequiresRequest { - /// - /// Gets or sets the logger. - /// - /// The logger. - public ILogger Logger => ApiEntryPoint.Instance.Logger; + public BaseApiService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory) + { + Logger = logger; + ServerConfigurationManager = serverConfigurationManager; + ResultFactory = httpResultFactory; + } /// - /// Gets or sets the HTTP result factory. + /// Gets the logger. + /// + /// The logger. + protected ILogger Logger { get; } + + /// + /// Gets or sets the server configuration manager. + /// + /// The server configuration manager. + protected IServerConfigurationManager ServerConfigurationManager { get; } + + /// + /// Gets the HTTP result factory. /// /// The HTTP result factory. - public IHttpResultFactory ResultFactory => ApiEntryPoint.Instance.ResultFactory; + protected IHttpResultFactory ResultFactory { get; } /// /// Gets or sets the request context. @@ -36,10 +54,7 @@ namespace MediaBrowser.Api /// The request context. public IRequest Request { get; set; } - public string GetHeader(string name) - { - return Request.Headers[name]; - } + public string GetHeader(string name) => Request.Headers[name]; public static string[] SplitValue(string value, char delim) { @@ -292,51 +307,101 @@ namespace MediaBrowser.Api return result; } - protected string GetPathValue(int index) + /// + /// Gets the path segment at the specified index. + /// + /// The index of the path segment. + /// The path segment at the specified index. + /// Path doesn't contain enough segments. + /// Path doesn't start with the base url. + protected internal ReadOnlySpan GetPathValue(int index) { - var pathInfo = Parse(Request.PathInfo); - var first = pathInfo[0]; - - string baseUrl = ApiEntryPoint.Instance.ConfigurationManager.Configuration.BaseUrl; - - // backwards compatibility - if (baseUrl.Length == 0) + static void ThrowIndexOutOfRangeException() { - if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) - || string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase)) - { - index++; - } + throw new IndexOutOfRangeException("Path doesn't contain enough segments."); } - else if (string.Equals(first, baseUrl.Remove(0, 1))) + + static void ThrowInvalidDataException() { - index++; - var second = pathInfo[1]; - if (string.Equals(second, "mediabrowser", StringComparison.OrdinalIgnoreCase) - || string.Equals(second, "emby", StringComparison.OrdinalIgnoreCase)) + throw new InvalidDataException("Path doesn't start with the base url."); + } + + ReadOnlySpan path = Request.PathInfo; + + // Remove the protocol part from the url + int pos = path.LastIndexOf("://"); + if (pos != -1) + { + path = path.Slice(pos + 3); + } + + // Remove the query string + pos = path.LastIndexOf('?'); + if (pos != -1) + { + path = path.Slice(0, pos); + } + + // Remove the domain + pos = path.IndexOf('/'); + if (pos != -1) + { + path = path.Slice(pos); + } + + // Remove base url + string baseUrl = ServerConfigurationManager.Configuration.BaseUrl; + int baseUrlLen = baseUrl.Length; + if (baseUrlLen != 0) + { + if (path.StartsWith(baseUrl, StringComparison.OrdinalIgnoreCase)) { - index++; + path = path.Slice(baseUrlLen); + } + else + { + // The path doesn't start with the base url, + // how did we get here? + ThrowInvalidDataException(); } } - return pathInfo[index]; - } + // Remove leading / + path = path.Slice(1); - private static string[] Parse(string pathUri) - { - var actionParts = pathUri.Split(new[] { "://" }, StringSplitOptions.None); - - var pathInfo = actionParts[actionParts.Length - 1]; - - var optionsPos = pathInfo.LastIndexOf('?'); - if (optionsPos != -1) + // Backwards compatibility + const string Emby = "emby/"; + if (path.StartsWith(Emby, StringComparison.OrdinalIgnoreCase)) { - pathInfo = pathInfo.Substring(0, optionsPos); + path = path.Slice(Emby.Length); } - var args = pathInfo.Split('/'); + const string MediaBrowser = "mediabrowser/"; + if (path.StartsWith(MediaBrowser, StringComparison.OrdinalIgnoreCase)) + { + path = path.Slice(MediaBrowser.Length); + } - return args.Skip(1).ToArray(); + // Skip segments until we are at the right index + for (int i = 0; i < index; i++) + { + pos = path.IndexOf('/'); + if (pos == -1) + { + ThrowIndexOutOfRangeException(); + } + + path = path.Slice(pos + 1); + } + + // Remove the rest + pos = path.IndexOf('/'); + if (pos != -1) + { + path = path.Slice(0, pos); + } + + return path; } /// diff --git a/MediaBrowser.Api/BrandingService.cs b/MediaBrowser.Api/BrandingService.cs index f5845f4e0..f4724e774 100644 --- a/MediaBrowser.Api/BrandingService.cs +++ b/MediaBrowser.Api/BrandingService.cs @@ -1,6 +1,9 @@ using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Net; using MediaBrowser.Model.Branding; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -17,21 +20,22 @@ namespace MediaBrowser.Api public class BrandingService : BaseApiService { - private readonly IConfigurationManager _config; - - public BrandingService(IConfigurationManager config) + public BrandingService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory) + : base(logger, serverConfigurationManager, httpResultFactory) { - _config = config; } public object Get(GetBrandingOptions request) { - return _config.GetConfiguration("branding"); + return ServerConfigurationManager.GetConfiguration("branding"); } public object Get(GetBrandingCss request) { - var result = _config.GetConfiguration("branding"); + var result = ServerConfigurationManager.GetConfiguration("branding"); // When null this throws a 405 error under Mono OSX, so default to empty string return ResultFactory.GetResult(Request, result.CustomCss ?? string.Empty, "text/css"); diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index d28bfaff5..92c32f2ad 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Api.UserLibrary; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -13,6 +14,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -188,7 +190,13 @@ namespace MediaBrowser.Api private readonly IChannelManager _channelManager; private IUserManager _userManager; - public ChannelService(IChannelManager channelManager, IUserManager userManager) + public ChannelService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IChannelManager channelManager, + IUserManager userManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _channelManager = channelManager; _userManager = userManager; diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index 718f537bc..316be04a0 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -1,14 +1,12 @@ using System.IO; using System.Threading.Tasks; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -78,18 +76,19 @@ namespace MediaBrowser.Api /// private readonly IServerConfigurationManager _configurationManager; - private readonly IFileSystem _fileSystem; - private readonly IProviderManager _providerManager; - private readonly ILibraryManager _libraryManager; private readonly IMediaEncoder _mediaEncoder; - public ConfigurationService(IJsonSerializer jsonSerializer, IServerConfigurationManager configurationManager, IFileSystem fileSystem, IProviderManager providerManager, ILibraryManager libraryManager, IMediaEncoder mediaEncoder) + public ConfigurationService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IJsonSerializer jsonSerializer, + IServerConfigurationManager configurationManager, + IMediaEncoder mediaEncoder) + : base(logger, serverConfigurationManager, httpResultFactory) { _jsonSerializer = jsonSerializer; _configurationManager = configurationManager; - _fileSystem = fileSystem; - _providerManager = providerManager; - _libraryManager = libraryManager; _mediaEncoder = mediaEncoder; } @@ -131,7 +130,7 @@ namespace MediaBrowser.Api public async Task Post(UpdateNamedConfiguration request) { - var key = GetPathValue(2); + var key = GetPathValue(2).ToString(); var configurationType = _configurationManager.GetConfigurationType(key); var configuration = await _jsonSerializer.DeserializeFromStreamAsync(request.RequestStream, configurationType).ConfigureAwait(false); diff --git a/MediaBrowser.Api/Devices/DeviceService.cs b/MediaBrowser.Api/Devices/DeviceService.cs index 697a84f5c..8b63decd2 100644 --- a/MediaBrowser.Api/Devices/DeviceService.cs +++ b/MediaBrowser.Api/Devices/DeviceService.cs @@ -1,6 +1,6 @@ -using System; using System.IO; using System.Threading.Tasks; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; @@ -8,6 +8,7 @@ using MediaBrowser.Controller.Session; using MediaBrowser.Model.Devices; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Devices { @@ -81,7 +82,14 @@ namespace MediaBrowser.Api.Devices private readonly IAuthenticationRepository _authRepo; private readonly ISessionManager _sessionManager; - public DeviceService(IDeviceManager deviceManager, IAuthenticationRepository authRepo, ISessionManager sessionManager) + public DeviceService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IDeviceManager deviceManager, + IAuthenticationRepository authRepo, + ISessionManager sessionManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _deviceManager = deviceManager; _authRepo = authRepo; diff --git a/MediaBrowser.Api/DisplayPreferencesService.cs b/MediaBrowser.Api/DisplayPreferencesService.cs index d56023fe2..62c4ff43f 100644 --- a/MediaBrowser.Api/DisplayPreferencesService.cs +++ b/MediaBrowser.Api/DisplayPreferencesService.cs @@ -1,9 +1,11 @@ using System.Threading; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -61,7 +63,13 @@ namespace MediaBrowser.Api /// /// The json serializer. /// The display preferences manager. - public DisplayPreferencesService(IJsonSerializer jsonSerializer, IDisplayPreferencesRepository displayPreferencesManager) + public DisplayPreferencesService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IJsonSerializer jsonSerializer, + IDisplayPreferencesRepository displayPreferencesManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _jsonSerializer = jsonSerializer; _displayPreferencesManager = displayPreferencesManager; diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index f4813e713..e231e8042 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Net; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -107,8 +109,8 @@ namespace MediaBrowser.Api [Authenticated(Roles = "Admin", AllowBeforeStartupWizard = true)] public class EnvironmentService : BaseApiService { - const char UncSeparator = '\\'; - const string UncSeparatorString = "\\"; + private const char UncSeparator = '\\'; + private const string UncSeparatorString = "\\"; /// /// The _network manager @@ -120,13 +122,14 @@ namespace MediaBrowser.Api /// Initializes a new instance of the class. /// /// The network manager. - public EnvironmentService(INetworkManager networkManager, IFileSystem fileSystem) + public EnvironmentService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + INetworkManager networkManager, + IFileSystem fileSystem) + : base(logger, serverConfigurationManager, httpResultFactory) { - if (networkManager == null) - { - throw new ArgumentNullException(nameof(networkManager)); - } - _networkManager = networkManager; _fileSystem = fileSystem; } diff --git a/MediaBrowser.Api/FilterService.cs b/MediaBrowser.Api/FilterService.cs index 201efe737..25f23bcd1 100644 --- a/MediaBrowser.Api/FilterService.cs +++ b/MediaBrowser.Api/FilterService.cs @@ -1,12 +1,14 @@ using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -84,7 +86,13 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IUserManager _userManager; - public FilterService(ILibraryManager libraryManager, IUserManager userManager) + public FilterService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ILibraryManager libraryManager, + IUserManager userManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _libraryManager = libraryManager; _userManager = userManager; diff --git a/MediaBrowser.Api/Images/ImageByNameService.cs b/MediaBrowser.Api/Images/ImageByNameService.cs index 922bd8ed6..45b7d0c10 100644 --- a/MediaBrowser.Api/Images/ImageByNameService.cs +++ b/MediaBrowser.Api/Images/ImageByNameService.cs @@ -5,11 +5,13 @@ using System.Linq; using System.Threading.Tasks; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Dto; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Images { @@ -101,17 +103,19 @@ namespace MediaBrowser.Api.Images private readonly IServerApplicationPaths _appPaths; private readonly IFileSystem _fileSystem; - private readonly IHttpResultFactory _resultFactory; /// /// Initializes a new instance of the class. /// - /// The app paths. - public ImageByNameService(IServerApplicationPaths appPaths, IFileSystem fileSystem, IHttpResultFactory resultFactory) + public ImageByNameService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory resultFactory, + IFileSystem fileSystem) + : base(logger, serverConfigurationManager, resultFactory) { - _appPaths = appPaths; + _appPaths = serverConfigurationManager.ApplicationPaths; _fileSystem = fileSystem; - _resultFactory = resultFactory; } public object Get(GetMediaInfoImages request) @@ -187,7 +191,7 @@ namespace MediaBrowser.Api.Images var path = paths.FirstOrDefault(File.Exists) ?? paths.FirstOrDefault(); - return _resultFactory.GetStaticFileResult(Request, path); + return ResultFactory.GetStaticFileResult(Request, path); } /// @@ -207,7 +211,7 @@ namespace MediaBrowser.Api.Images if (!string.IsNullOrEmpty(path)) { - return _resultFactory.GetStaticFileResult(Request, path); + return ResultFactory.GetStaticFileResult(Request, path); } } @@ -224,7 +228,7 @@ namespace MediaBrowser.Api.Images if (!string.IsNullOrEmpty(path)) { - return _resultFactory.GetStaticFileResult(Request, path); + return ResultFactory.GetStaticFileResult(Request, path); } } @@ -247,7 +251,7 @@ namespace MediaBrowser.Api.Images if (!string.IsNullOrEmpty(path)) { - return _resultFactory.GetStaticFileResult(Request, path); + return ResultFactory.GetStaticFileResult(Request, path); } } @@ -263,7 +267,7 @@ namespace MediaBrowser.Api.Images if (!string.IsNullOrEmpty(path)) { - return _resultFactory.GetStaticFileResult(Request, path); + return ResultFactory.GetStaticFileResult(Request, path); } } diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 6d3037b24..f1b88de64 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -6,12 +6,12 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; @@ -231,7 +231,6 @@ namespace MediaBrowser.Api.Images private readonly IProviderManager _providerManager; - private readonly IItemRepository _itemRepo; private readonly IImageProcessor _imageProcessor; private readonly IFileSystem _fileSystem; private readonly IAuthorizationContext _authContext; @@ -239,12 +238,21 @@ namespace MediaBrowser.Api.Images /// /// Initializes a new instance of the class. /// - public ImageService(IUserManager userManager, ILibraryManager libraryManager, IProviderManager providerManager, IItemRepository itemRepo, IImageProcessor imageProcessor, IFileSystem fileSystem, IAuthorizationContext authContext) + public ImageService( + Logger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IProviderManager providerManager, + IImageProcessor imageProcessor, + IFileSystem fileSystem, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _libraryManager = libraryManager; _providerManager = providerManager; - _itemRepo = itemRepo; _imageProcessor = imageProcessor; _fileSystem = fileSystem; _authContext = authContext; @@ -402,7 +410,7 @@ namespace MediaBrowser.Api.Images public object Get(GetItemByNameImage request) { - var type = GetPathValue(0); + var type = GetPathValue(0).ToString(); var item = GetItemByName(request.Name, type, _libraryManager, new DtoOptions(false)); @@ -411,7 +419,7 @@ namespace MediaBrowser.Api.Images public object Head(GetItemByNameImage request) { - var type = GetPathValue(0); + var type = GetPathValue(0).ToString(); var item = GetItemByName(request.Name, type, _libraryManager, new DtoOptions(false)); @@ -424,12 +432,13 @@ namespace MediaBrowser.Api.Images /// The request. public Task Post(PostUserImage request) { - var userId = GetPathValue(1); - AssertCanUpdateUser(_authContext, _userManager, new Guid(userId), true); + var id = Guid.Parse(GetPathValue(1)); - request.Type = (ImageType)Enum.Parse(typeof(ImageType), GetPathValue(3), true); + AssertCanUpdateUser(_authContext, _userManager, id, true); - var item = _userManager.GetUserById(userId); + request.Type = Enum.Parse(GetPathValue(3).ToString(), true); + + var item = _userManager.GetUserById(id); return PostImage(item, request.RequestStream, request.Type, Request.ContentType); } @@ -440,9 +449,9 @@ namespace MediaBrowser.Api.Images /// The request. public Task Post(PostItemImage request) { - var id = GetPathValue(1); + var id = Guid.Parse(GetPathValue(1)); - request.Type = (ImageType)Enum.Parse(typeof(ImageType), GetPathValue(3), true); + request.Type = Enum.Parse(GetPathValue(3).ToString(), true); var item = _libraryManager.GetItemById(id); diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 24d4751c5..5a37d3730 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller; -using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; @@ -16,6 +16,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Images { @@ -108,13 +109,20 @@ namespace MediaBrowser.Api.Images private readonly IHttpClient _httpClient; private readonly IFileSystem _fileSystem; - private readonly IDtoService _dtoService; private readonly ILibraryManager _libraryManager; - public RemoteImageService(IProviderManager providerManager, IDtoService dtoService, IServerApplicationPaths appPaths, IHttpClient httpClient, IFileSystem fileSystem, ILibraryManager libraryManager) + public RemoteImageService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IProviderManager providerManager, + IServerApplicationPaths appPaths, + IHttpClient httpClient, + IFileSystem fileSystem, + ILibraryManager libraryManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _providerManager = providerManager; - _dtoService = dtoService; _appPaths = appPaths; _httpClient = httpClient; _fileSystem = fileSystem; diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 084b20bc1..ea5a99892 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; @@ -121,10 +122,18 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IJsonSerializer _json; - public ItemLookupService(IProviderManager providerManager, IServerApplicationPaths appPaths, IFileSystem fileSystem, ILibraryManager libraryManager, IJsonSerializer json) + public ItemLookupService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IProviderManager providerManager, + IFileSystem fileSystem, + ILibraryManager libraryManager, + IJsonSerializer json) + : base(logger, serverConfigurationManager, httpResultFactory) { _providerManager = providerManager; - _appPaths = appPaths; + _appPaths = serverConfigurationManager.ApplicationPaths; _fileSystem = fileSystem; _libraryManager = libraryManager; _json = json; diff --git a/MediaBrowser.Api/ItemRefreshService.cs b/MediaBrowser.Api/ItemRefreshService.cs index a1d69cd2b..5e86f04a8 100644 --- a/MediaBrowser.Api/ItemRefreshService.cs +++ b/MediaBrowser.Api/ItemRefreshService.cs @@ -1,3 +1,4 @@ +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Providers; @@ -38,14 +39,19 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IProviderManager _providerManager; private readonly IFileSystem _fileSystem; - private readonly ILogger _logger; - public ItemRefreshService(ILibraryManager libraryManager, IProviderManager providerManager, IFileSystem fileSystem, ILogger logger) + public ItemRefreshService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ILibraryManager libraryManager, + IProviderManager providerManager, + IFileSystem fileSystem) + : base(logger, serverConfigurationManager, httpResultFactory) { _libraryManager = libraryManager; _providerManager = providerManager; _fileSystem = fileSystem; - _logger = logger; } /// diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 5d524b185..1847f7fde 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -16,6 +16,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -49,19 +50,25 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IProviderManager _providerManager; private readonly ILocalizationManager _localizationManager; - private readonly IServerConfigurationManager _config; private readonly IFileSystem _fileSystem; - public ItemUpdateService(IFileSystem fileSystem, ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager, IServerConfigurationManager config) + public ItemUpdateService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IFileSystem fileSystem, + ILibraryManager libraryManager, + IProviderManager providerManager, + ILocalizationManager localizationManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _libraryManager = libraryManager; _providerManager = providerManager; _localizationManager = localizationManager; - _config = config; _fileSystem = fileSystem; } - public async Task Get(GetMetadataEditorInfo request) + public object Get(GetMetadataEditorInfo request) { var item = _libraryManager.GetItemById(request.ItemId); @@ -101,7 +108,7 @@ namespace MediaBrowser.Api var item = _libraryManager.GetItemById(request.ItemId); var path = item.ContainingFolderPath; - var types = _config.Configuration.ContentTypes + var types = ServerConfigurationManager.Configuration.ContentTypes .Where(i => !string.IsNullOrWhiteSpace(i.Name)) .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase)) .ToList(); @@ -115,8 +122,8 @@ namespace MediaBrowser.Api }); } - _config.Configuration.ContentTypes = types.ToArray(); - _config.SaveConfiguration(); + ServerConfigurationManager.Configuration.ContentTypes = types.ToArray(); + ServerConfigurationManager.SaveConfiguration(); } private List GetContentTypeOptions(bool isForItem) diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index cee96f7ab..0cc5e112f 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -25,7 +25,6 @@ using MediaBrowser.Model.Activity; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.Querying; @@ -315,46 +314,40 @@ namespace MediaBrowser.Api.Library /// public class LibraryService : BaseApiService { - /// - /// The _item repo - /// - private readonly IItemRepository _itemRepo; - + private readonly IProviderManager _providerManager; private readonly ILibraryManager _libraryManager; private readonly IUserManager _userManager; - private readonly IUserDataManager _userDataManager; - private readonly IDtoService _dtoService; private readonly IAuthorizationContext _authContext; private readonly IActivityManager _activityManager; private readonly ILocalizationManager _localization; - private readonly ILiveTvManager _liveTv; - private readonly ITVSeriesManager _tvManager; private readonly ILibraryMonitor _libraryMonitor; - private readonly IFileSystem _fileSystem; - private readonly IServerConfigurationManager _config; - private readonly IProviderManager _providerManager; /// /// Initializes a new instance of the class. /// - public LibraryService(IProviderManager providerManager, IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, - IDtoService dtoService, IUserDataManager userDataManager, IAuthorizationContext authContext, IActivityManager activityManager, ILocalizationManager localization, ILiveTvManager liveTv, ITVSeriesManager tvManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem, IServerConfigurationManager config) + public LibraryService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IProviderManager providerManager, + ILibraryManager libraryManager, + IUserManager userManager, + IDtoService dtoService, + IAuthorizationContext authContext, + IActivityManager activityManager, + ILocalizationManager localization, + ILibraryMonitor libraryMonitor) + : base(logger, serverConfigurationManager, httpResultFactory) { - _itemRepo = itemRepo; + _providerManager = providerManager; _libraryManager = libraryManager; _userManager = userManager; _dtoService = dtoService; - _userDataManager = userDataManager; _authContext = authContext; _activityManager = activityManager; _localization = localization; - _liveTv = liveTv; - _tvManager = tvManager; _libraryMonitor = libraryMonitor; - _fileSystem = fileSystem; - _config = config; - _providerManager = providerManager; } private string[] GetRepresentativeItemTypes(string contentType) @@ -390,7 +383,7 @@ namespace MediaBrowser.Api.Library return false; } - var metadataOptions = _config.Configuration.MetadataOptions + var metadataOptions = ServerConfigurationManager.Configuration.MetadataOptions .Where(i => itemTypes.Contains(i.ItemType ?? string.Empty, StringComparer.OrdinalIgnoreCase)) .ToArray(); @@ -446,7 +439,7 @@ namespace MediaBrowser.Api.Library return false; } - var metadataOptions = _config.Configuration.MetadataOptions + var metadataOptions = ServerConfigurationManager.Configuration.MetadataOptions .Where(i => string.Equals(i.ItemType, type, StringComparison.OrdinalIgnoreCase)) .ToArray(); @@ -510,7 +503,7 @@ namespace MediaBrowser.Api.Library return false; } - var metadataOptions = _config.Configuration.MetadataOptions + var metadataOptions = ServerConfigurationManager.Configuration.MetadataOptions .Where(i => string.Equals(i.ItemType, type, StringComparison.OrdinalIgnoreCase)) .ToArray(); @@ -630,7 +623,14 @@ namespace MediaBrowser.Api.Library if (item is Movie || (program != null && program.IsMovie) || item is Trailer) { - return new MoviesService(_userManager, _libraryManager, _dtoService, _config, _authContext) + return new MoviesService( + Logger, + ServerConfigurationManager, + ResultFactory, + _userManager, + _libraryManager, + _dtoService, + _authContext) { Request = Request, diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index 7266bf9f9..c071b42f7 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -7,13 +7,14 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Progress; using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Library { @@ -179,25 +180,23 @@ namespace MediaBrowser.Api.Library /// The _library manager /// private readonly ILibraryManager _libraryManager; - private readonly ILibraryMonitor _libraryMonitor; - private readonly IFileSystem _fileSystem; /// /// Initializes a new instance of the class. /// - public LibraryStructureService(IServerApplicationPaths appPaths, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem) + public LibraryStructureService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ILibraryManager libraryManager, + ILibraryMonitor libraryMonitor) + : base(logger, serverConfigurationManager, httpResultFactory) { - if (appPaths == null) - { - throw new ArgumentNullException(nameof(appPaths)); - } - - _appPaths = appPaths; + _appPaths = serverConfigurationManager.ApplicationPaths; _libraryManager = libraryManager; _libraryMonitor = libraryMonitor; - _fileSystem = fileSystem; } /// diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 2b9a64e97..4b4496139 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -18,13 +18,13 @@ using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; using Microsoft.Net.Http.Headers; namespace MediaBrowser.Api.LiveTv @@ -692,35 +692,33 @@ namespace MediaBrowser.Api.LiveTv { private readonly ILiveTvManager _liveTvManager; private readonly IUserManager _userManager; - private readonly IServerConfigurationManager _config; private readonly IHttpClient _httpClient; private readonly ILibraryManager _libraryManager; private readonly IDtoService _dtoService; private readonly IAuthorizationContext _authContext; private readonly ISessionContext _sessionContext; - private readonly ICryptoProvider _cryptographyProvider; private readonly IStreamHelper _streamHelper; private readonly IMediaSourceManager _mediaSourceManager; public LiveTvService( - ICryptoProvider crypto, + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IMediaSourceManager mediaSourceManager, IStreamHelper streamHelper, ILiveTvManager liveTvManager, IUserManager userManager, - IServerConfigurationManager config, IHttpClient httpClient, ILibraryManager libraryManager, IDtoService dtoService, IAuthorizationContext authContext, ISessionContext sessionContext) + : base(logger, serverConfigurationManager, httpResultFactory) { - _cryptographyProvider = crypto; _mediaSourceManager = mediaSourceManager; _streamHelper = streamHelper; _liveTvManager = liveTvManager; _userManager = userManager; - _config = config; _httpClient = httpClient; _libraryManager = libraryManager; _dtoService = dtoService; @@ -911,17 +909,17 @@ namespace MediaBrowser.Api.LiveTv config.TunerHosts = config.TunerHosts.Where(i => !string.Equals(request.Id, i.Id, StringComparison.OrdinalIgnoreCase)).ToArray(); - _config.SaveConfiguration("livetv", config); + ServerConfigurationManager.SaveConfiguration("livetv", config); } private LiveTvOptions GetConfiguration() { - return _config.GetConfiguration("livetv"); + return ServerConfigurationManager.GetConfiguration("livetv"); } private void UpdateConfiguration(LiveTvOptions options) { - _config.SaveConfiguration("livetv", options); + ServerConfigurationManager.SaveConfiguration("livetv", options); } public async Task Get(GetLineups request) diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs index 3b2e18852..6a69d2656 100644 --- a/MediaBrowser.Api/LocalizationService.cs +++ b/MediaBrowser.Api/LocalizationService.cs @@ -1,7 +1,9 @@ +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -52,7 +54,12 @@ namespace MediaBrowser.Api /// Initializes a new instance of the class. /// /// The localization. - public LocalizationService(ILocalizationManager localization) + public LocalizationService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ILocalizationManager localization) + : base(logger, serverConfigurationManager, httpResultFactory) { _localization = localization; } diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index b52f8a547..95a37dfc5 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -1,9 +1,11 @@ using System; using MediaBrowser.Controller.Collections; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Collections; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Movies { @@ -50,7 +52,14 @@ namespace MediaBrowser.Api.Movies private readonly IDtoService _dtoService; private readonly IAuthorizationContext _authContext; - public CollectionService(ICollectionManager collectionManager, IDtoService dtoService, IAuthorizationContext authContext) + public CollectionService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ICollectionManager collectionManager, + IDtoService dtoService, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _collectionManager = collectionManager; _dtoService = dtoService; diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index c1c6ffc2e..7abedd8ef 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -14,6 +14,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Movies { @@ -75,18 +76,24 @@ namespace MediaBrowser.Api.Movies private readonly ILibraryManager _libraryManager; private readonly IDtoService _dtoService; - private readonly IServerConfigurationManager _config; private readonly IAuthorizationContext _authContext; /// /// Initializes a new instance of the class. /// - public MoviesService(IUserManager userManager, ILibraryManager libraryManager, IDtoService dtoService, IServerConfigurationManager config, IAuthorizationContext authContext) + public MoviesService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IDtoService dtoService, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _libraryManager = libraryManager; _dtoService = dtoService; - _config = config; _authContext = authContext; } @@ -110,7 +117,7 @@ namespace MediaBrowser.Api.Movies _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); var itemTypes = new List { typeof(Movie).Name }; - if (_config.Configuration.EnableExternalContentInSuggestions) + if (ServerConfigurationManager.Configuration.EnableExternalContentInSuggestions) { itemTypes.Add(typeof(Trailer).Name); itemTypes.Add(typeof(LiveTvProgram).Name); @@ -167,7 +174,7 @@ namespace MediaBrowser.Api.Movies var recentlyPlayedMovies = _libraryManager.GetItemList(query); var itemTypes = new List { typeof(Movie).Name }; - if (_config.Configuration.EnableExternalContentInSuggestions) + if (ServerConfigurationManager.Configuration.EnableExternalContentInSuggestions) { itemTypes.Add(typeof(Trailer).Name); itemTypes.Add(typeof(LiveTvProgram).Name); @@ -249,7 +256,7 @@ namespace MediaBrowser.Api.Movies private IEnumerable GetWithDirector(User user, IEnumerable names, int itemLimit, DtoOptions dtoOptions, RecommendationType type) { var itemTypes = new List { typeof(Movie).Name }; - if (_config.Configuration.EnableExternalContentInSuggestions) + if (ServerConfigurationManager.Configuration.EnableExternalContentInSuggestions) { itemTypes.Add(typeof(Trailer).Name); itemTypes.Add(typeof(LiveTvProgram).Name); @@ -291,7 +298,7 @@ namespace MediaBrowser.Api.Movies private IEnumerable GetWithActor(User user, IEnumerable names, int itemLimit, DtoOptions dtoOptions, RecommendationType type) { var itemTypes = new List { typeof(Movie).Name }; - if (_config.Configuration.EnableExternalContentInSuggestions) + if (ServerConfigurationManager.Configuration.EnableExternalContentInSuggestions) { itemTypes.Add(typeof(Trailer).Name); itemTypes.Add(typeof(LiveTvProgram).Name); @@ -332,7 +339,7 @@ namespace MediaBrowser.Api.Movies private IEnumerable GetSimilarTo(User user, List baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type) { var itemTypes = new List { typeof(Movie).Name }; - if (_config.Configuration.EnableExternalContentInSuggestions) + if (ServerConfigurationManager.Configuration.EnableExternalContentInSuggestions) { itemTypes.Add(typeof(Trailer).Name); itemTypes.Add(typeof(LiveTvProgram).Name); diff --git a/MediaBrowser.Api/Movies/TrailersService.cs b/MediaBrowser.Api/Movies/TrailersService.cs index 6e4443dbe..8adf9c621 100644 --- a/MediaBrowser.Api/Movies/TrailersService.cs +++ b/MediaBrowser.Api/Movies/TrailersService.cs @@ -1,5 +1,5 @@ using MediaBrowser.Api.UserLibrary; -using MediaBrowser.Controller.Collections; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; @@ -8,6 +8,7 @@ using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Movies { @@ -27,28 +28,31 @@ namespace MediaBrowser.Api.Movies /// private readonly IUserManager _userManager; - /// - /// The _user data repository - /// - private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// private readonly ILibraryManager _libraryManager; private readonly IDtoService _dtoService; - private readonly ICollectionManager _collectionManager; private readonly ILocalizationManager _localizationManager; private readonly IJsonSerializer _json; private readonly IAuthorizationContext _authContext; - public TrailersService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IDtoService dtoService, ICollectionManager collectionManager, ILocalizationManager localizationManager, IJsonSerializer json, IAuthorizationContext authContext) + public TrailersService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IDtoService dtoService, + ILocalizationManager localizationManager, + IJsonSerializer json, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; - _userDataRepository = userDataRepository; _libraryManager = libraryManager; _dtoService = dtoService; - _collectionManager = collectionManager; _localizationManager = localizationManager; _json = json; _authContext = authContext; @@ -61,7 +65,15 @@ namespace MediaBrowser.Api.Movies getItems.IncludeItemTypes = "Trailer"; - return new ItemsService(_userManager, _libraryManager, _localizationManager, _dtoService, _authContext) + return new ItemsService( + Logger, + ServerConfigurationManager, + ResultFactory, + _userManager, + _libraryManager, + _localizationManager, + _dtoService, + _authContext) { Request = Request, diff --git a/MediaBrowser.Api/Music/AlbumsService.cs b/MediaBrowser.Api/Music/AlbumsService.cs index 2cd3a1003..fd6c0b7da 100644 --- a/MediaBrowser.Api/Music/AlbumsService.cs +++ b/MediaBrowser.Api/Music/AlbumsService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -8,6 +9,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Music { @@ -41,7 +43,17 @@ namespace MediaBrowser.Api.Music private readonly IDtoService _dtoService; private readonly IAuthorizationContext _authContext; - public AlbumsService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService, IAuthorizationContext authContext) + public AlbumsService( + Logger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + IUserDataManager userDataRepository, + ILibraryManager libraryManager, + IItemRepository itemRepo, + IDtoService dtoService, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _userDataRepository = userDataRepository; diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index 875f0a8de..cacec8d64 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -8,6 +9,7 @@ using MediaBrowser.Controller.Playlists; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Music { @@ -62,7 +64,16 @@ namespace MediaBrowser.Api.Music private readonly IMusicManager _musicManager; private readonly IAuthorizationContext _authContext; - public InstantMixService(IUserManager userManager, IDtoService dtoService, IMusicManager musicManager, ILibraryManager libraryManager, IAuthorizationContext authContext) + public InstantMixService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + IDtoService dtoService, + IMusicManager musicManager, + ILibraryManager libraryManager, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _dtoService = dtoService; diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index 1e5a93210..b0333eb9c 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -2,14 +2,14 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Updates; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; using MediaBrowser.Model.Updates; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -118,12 +118,15 @@ namespace MediaBrowser.Api public class PackageService : BaseApiService { private readonly IInstallationManager _installationManager; - private readonly IApplicationHost _appHost; - public PackageService(IInstallationManager installationManager, IApplicationHost appHost) + public PackageService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IInstallationManager installationManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _installationManager = installationManager; - _appHost = appHost; } /// diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 4bd729aac..1e9cd3313 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -33,12 +33,6 @@ namespace MediaBrowser.Api.Playback { protected virtual bool EnableOutputInSubFolder => false; - /// - /// Gets or sets the application paths. - /// - /// The application paths. - protected IServerConfigurationManager ServerConfigurationManager { get; private set; } - /// /// Gets or sets the user manager. /// @@ -89,7 +83,9 @@ namespace MediaBrowser.Api.Playback /// Initializes a new instance of the class. /// protected BaseStreamingService( - IServerConfigurationManager serverConfig, + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -101,8 +97,8 @@ namespace MediaBrowser.Api.Playback IMediaSourceManager mediaSourceManager, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) + : base(logger, serverConfigurationManager, httpResultFactory) { - ServerConfigurationManager = serverConfig; UserManager = userManager; LibraryManager = libraryManager; IsoManager = isoManager; @@ -588,7 +584,7 @@ namespace MediaBrowser.Api.Playback } /// - /// Parses query parameters as StreamOptions + /// Parses query parameters as StreamOptions. /// /// The stream request. private void ParseStreamOptions(StreamRequest request) diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 27eb67ee6..8fdc6fa49 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -12,7 +12,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Extensions; using MediaBrowser.Model.IO; using MediaBrowser.Model.Net; using MediaBrowser.Model.Serialization; @@ -25,6 +24,39 @@ namespace MediaBrowser.Api.Playback.Hls /// public abstract class BaseHlsService : BaseStreamingService { + public BaseHlsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IIsoManager isoManager, + IMediaEncoder mediaEncoder, + IFileSystem fileSystem, + IDlnaManager dlnaManager, + ISubtitleEncoder subtitleEncoder, + IDeviceManager deviceManager, + IMediaSourceManager mediaSourceManager, + IJsonSerializer jsonSerializer, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + isoManager, + mediaEncoder, + fileSystem, + dlnaManager, + subtitleEncoder, + deviceManager, + mediaSourceManager, + jsonSerializer, + authorizationContext) + { + } + /// /// Gets the audio arguments. /// @@ -313,33 +345,5 @@ namespace MediaBrowser.Api.Playback.Hls { return 0; } - - public BaseHlsService( - IServerConfigurationManager serverConfig, - IUserManager userManager, - ILibraryManager libraryManager, - IIsoManager isoManager, - IMediaEncoder mediaEncoder, - IFileSystem fileSystem, - IDlnaManager dlnaManager, - ISubtitleEncoder subtitleEncoder, - IDeviceManager deviceManager, - IMediaSourceManager mediaSourceManager, - IJsonSerializer jsonSerializer, - IAuthorizationContext authorizationContext) - : base(serverConfig, - userManager, - libraryManager, - isoManager, - mediaEncoder, - fileSystem, - dlnaManager, - subtitleEncoder, - deviceManager, - mediaSourceManager, - jsonSerializer, - authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 9ecb5fe8c..f09c7e9f2 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -94,9 +94,10 @@ namespace MediaBrowser.Api.Playback.Hls [Authenticated] public class DynamicHlsService : BaseHlsService { - public DynamicHlsService( - IServerConfigurationManager serverConfig, + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -109,7 +110,10 @@ namespace MediaBrowser.Api.Playback.Hls IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, INetworkManager networkManager) - : base(serverConfig, + : base( + logger, + serverConfigurationManager, + httpResultFactory, userManager, libraryManager, isoManager, diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs index ca5a73ff1..bb12ab1f0 100644 --- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs +++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs @@ -8,6 +8,7 @@ using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Hls { @@ -83,19 +84,22 @@ namespace MediaBrowser.Api.Playback.Hls public class HlsSegmentService : BaseApiService { - private readonly IServerConfigurationManager _config; private readonly IFileSystem _fileSystem; - public HlsSegmentService(IServerConfigurationManager config, IFileSystem fileSystem) + public HlsSegmentService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IFileSystem fileSystem) + : base(logger, serverConfigurationManager, httpResultFactory) { - _config = config; _fileSystem = fileSystem; } public Task Get(GetHlsPlaylistLegacy request) { var file = request.PlaylistId + Path.GetExtension(Request.PathInfo); - file = Path.Combine(_config.GetTranscodePath(), file); + file = Path.Combine(ServerConfigurationManager.GetTranscodePath(), file); return GetFileResult(file, file); } @@ -113,7 +117,8 @@ namespace MediaBrowser.Api.Playback.Hls public Task Get(GetHlsVideoSegmentLegacy request) { var file = request.SegmentId + Path.GetExtension(Request.PathInfo); - var transcodeFolderPath = _config.GetTranscodePath(); + var transcodeFolderPath = ServerConfigurationManager.GetTranscodePath(); + file = Path.Combine(transcodeFolderPath, file); var normalizedPlaylistId = request.PlaylistId; @@ -133,7 +138,7 @@ namespace MediaBrowser.Api.Playback.Hls { // TODO: Deprecate with new iOS app var file = request.SegmentId + Path.GetExtension(Request.PathInfo); - file = Path.Combine(_config.GetTranscodePath(), file); + file = Path.Combine(ServerConfigurationManager.GetTranscodePath(), file); return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite); } diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 4a5f4025b..6d12a1ccd 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -12,6 +12,7 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Hls { @@ -137,7 +138,9 @@ namespace MediaBrowser.Api.Playback.Hls } public VideoHlsService( - IServerConfigurationManager serverConfig, + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -149,7 +152,10 @@ namespace MediaBrowser.Api.Playback.Hls IMediaSourceManager mediaSourceManager, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) - : base(serverConfig, + : base( + logger, + serverConfigurationManager, + httpResultFactory, userManager, libraryManager, isoManager, diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index da8f99a3d..c3032416b 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -69,36 +69,34 @@ namespace MediaBrowser.Api.Playback private readonly IMediaSourceManager _mediaSourceManager; private readonly IDeviceManager _deviceManager; private readonly ILibraryManager _libraryManager; - private readonly IServerConfigurationManager _config; private readonly INetworkManager _networkManager; private readonly IMediaEncoder _mediaEncoder; private readonly IUserManager _userManager; private readonly IJsonSerializer _json; private readonly IAuthorizationContext _authContext; - private readonly ILogger _logger; public MediaInfoService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IMediaSourceManager mediaSourceManager, IDeviceManager deviceManager, ILibraryManager libraryManager, - IServerConfigurationManager config, INetworkManager networkManager, IMediaEncoder mediaEncoder, IUserManager userManager, IJsonSerializer json, - IAuthorizationContext authContext, - ILoggerFactory loggerFactory) + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _mediaSourceManager = mediaSourceManager; _deviceManager = deviceManager; _libraryManager = libraryManager; - _config = config; _networkManager = networkManager; _mediaEncoder = mediaEncoder; _userManager = userManager; _json = json; _authContext = authContext; - _logger = loggerFactory.CreateLogger(nameof(MediaInfoService)); } public object Get(GetBitrateTestBytes request) @@ -275,7 +273,7 @@ namespace MediaBrowser.Api.Playback catch (Exception ex) { mediaSources = new List(); - _logger.LogError(ex, "Could not find media sources for item id {id}", id); + Logger.LogError(ex, "Could not find media sources for item id {id}", id); // TODO PlaybackException ?? //result.ErrorCode = ex.ErrorCode; } @@ -533,7 +531,7 @@ namespace MediaBrowser.Api.Playback if (remoteClientMaxBitrate <= 0) { - remoteClientMaxBitrate = _config.Configuration.RemoteClientBitrateLimit; + remoteClientMaxBitrate = ServerConfigurationManager.Configuration.RemoteClientBitrateLimit; } if (remoteClientMaxBitrate > 0) diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index dfe4b2b8e..11527007b 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Progressive { @@ -32,8 +33,10 @@ namespace MediaBrowser.Api.Playback.Progressive public class AudioService : BaseProgressiveStreamingService { public AudioService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IHttpClient httpClient, - IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -45,19 +48,22 @@ namespace MediaBrowser.Api.Playback.Progressive IMediaSourceManager mediaSourceManager, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) - : base(httpClient, - serverConfig, - userManager, - libraryManager, - isoManager, - mediaEncoder, - fileSystem, - dlnaManager, - subtitleEncoder, - deviceManager, - mediaSourceManager, - jsonSerializer, - authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + httpClient, + userManager, + libraryManager, + isoManager, + mediaEncoder, + fileSystem, + dlnaManager, + subtitleEncoder, + deviceManager, + mediaSourceManager, + jsonSerializer, + authorizationContext) { } diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 97c1a7a49..4ada90d09 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -15,6 +15,7 @@ using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; using Microsoft.Net.Http.Headers; namespace MediaBrowser.Api.Playback.Progressive @@ -27,8 +28,10 @@ namespace MediaBrowser.Api.Playback.Progressive protected IHttpClient HttpClient { get; private set; } public BaseProgressiveStreamingService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IHttpClient httpClient, - IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -40,7 +43,10 @@ namespace MediaBrowser.Api.Playback.Progressive IMediaSourceManager mediaSourceManager, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) - : base(serverConfig, + : base( + logger, + serverConfigurationManager, + httpResultFactory, userManager, libraryManager, isoManager, diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index cfc8a283d..fc5603d27 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -10,6 +10,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Progressive { @@ -69,8 +70,10 @@ namespace MediaBrowser.Api.Playback.Progressive public class VideoService : BaseProgressiveStreamingService { public VideoService( + Logger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IHttpClient httpClient, - IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -82,8 +85,11 @@ namespace MediaBrowser.Api.Playback.Progressive IMediaSourceManager mediaSourceManager, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) - : base(httpClient, - serverConfig, + : base( + logger, + serverConfigurationManager, + httpResultFactory, + httpClient, userManager, libraryManager, isoManager, diff --git a/MediaBrowser.Api/Playback/UniversalAudioService.cs b/MediaBrowser.Api/Playback/UniversalAudioService.cs index b3d8bfe59..b1450e2cc 100644 --- a/MediaBrowser.Api/Playback/UniversalAudioService.cs +++ b/MediaBrowser.Api/Playback/UniversalAudioService.cs @@ -76,8 +76,10 @@ namespace MediaBrowser.Api.Playback public class UniversalAudioService : BaseApiService { public UniversalAudioService( - IHttpClient httpClient, + ILogger logger, IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IHttpClient httpClient, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, @@ -87,15 +89,12 @@ namespace MediaBrowser.Api.Playback IDeviceManager deviceManager, ISubtitleEncoder subtitleEncoder, IMediaSourceManager mediaSourceManager, - IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, - IImageProcessor imageProcessor, - INetworkManager networkManager, - ILoggerFactory loggerFactory) + INetworkManager networkManager) + : base(logger, serverConfigurationManager, httpResultFactory) { HttpClient = httpClient; - ServerConfigurationManager = serverConfigurationManager; UserManager = userManager; LibraryManager = libraryManager; IsoManager = isoManager; @@ -105,17 +104,12 @@ namespace MediaBrowser.Api.Playback DeviceManager = deviceManager; SubtitleEncoder = subtitleEncoder; MediaSourceManager = mediaSourceManager; - ZipClient = zipClient; JsonSerializer = jsonSerializer; AuthorizationContext = authorizationContext; - ImageProcessor = imageProcessor; NetworkManager = networkManager; - _loggerFactory = loggerFactory; - _logger = loggerFactory.CreateLogger(nameof(UniversalAudioService)); } protected IHttpClient HttpClient { get; private set; } - protected IServerConfigurationManager ServerConfigurationManager { get; private set; } protected IUserManager UserManager { get; private set; } protected ILibraryManager LibraryManager { get; private set; } protected IIsoManager IsoManager { get; private set; } @@ -125,13 +119,9 @@ namespace MediaBrowser.Api.Playback protected IDeviceManager DeviceManager { get; private set; } protected ISubtitleEncoder SubtitleEncoder { get; private set; } protected IMediaSourceManager MediaSourceManager { get; private set; } - protected IZipClient ZipClient { get; private set; } protected IJsonSerializer JsonSerializer { get; private set; } protected IAuthorizationContext AuthorizationContext { get; private set; } - protected IImageProcessor ImageProcessor { get; private set; } protected INetworkManager NetworkManager { get; private set; } - private ILoggerFactory _loggerFactory; - private ILogger _logger; public Task Get(GetUniversalAudioStream request) { @@ -242,7 +232,18 @@ namespace MediaBrowser.Api.Playback AuthorizationContext.GetAuthorizationInfo(Request).DeviceId = request.DeviceId; - var mediaInfoService = new MediaInfoService(MediaSourceManager, DeviceManager, LibraryManager, ServerConfigurationManager, NetworkManager, MediaEncoder, UserManager, JsonSerializer, AuthorizationContext, _loggerFactory) + var mediaInfoService = new MediaInfoService( + Logger, + ServerConfigurationManager, + ResultFactory, + MediaSourceManager, + DeviceManager, + LibraryManager, + NetworkManager, + MediaEncoder, + UserManager, + JsonSerializer, + AuthorizationContext) { Request = Request }; @@ -276,19 +277,22 @@ namespace MediaBrowser.Api.Playback if (!isStatic && string.Equals(mediaSource.TranscodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase)) { - var service = new DynamicHlsService(ServerConfigurationManager, - UserManager, - LibraryManager, - IsoManager, - MediaEncoder, - FileSystem, - DlnaManager, - SubtitleEncoder, - DeviceManager, - MediaSourceManager, - JsonSerializer, - AuthorizationContext, - NetworkManager) + var service = new DynamicHlsService( + Logger, + ServerConfigurationManager, + ResultFactory, + UserManager, + LibraryManager, + IsoManager, + MediaEncoder, + FileSystem, + DlnaManager, + SubtitleEncoder, + DeviceManager, + MediaSourceManager, + JsonSerializer, + AuthorizationContext, + NetworkManager) { Request = Request }; @@ -322,8 +326,11 @@ namespace MediaBrowser.Api.Playback } else { - var service = new AudioService(HttpClient, + var service = new AudioService( + Logger, ServerConfigurationManager, + ResultFactory, + HttpClient, UserManager, LibraryManager, IsoManager, @@ -360,6 +367,7 @@ namespace MediaBrowser.Api.Playback { return await service.Head(newRequest).ConfigureAwait(false); } + return await service.Get(newRequest).ConfigureAwait(false); } } diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index 483bf98fb..953b00e35 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; @@ -9,6 +10,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Playlists; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -128,7 +130,16 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IAuthorizationContext _authContext; - public PlaylistService(IDtoService dtoService, IPlaylistManager playlistManager, IUserManager userManager, ILibraryManager libraryManager, IAuthorizationContext authContext) + public PlaylistService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IDtoService dtoService, + IPlaylistManager playlistManager, + IUserManager userManager, + ILibraryManager libraryManager, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _dtoService = dtoService; _playlistManager = playlistManager; diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index af61887b2..16d3268b9 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -3,14 +3,14 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using MediaBrowser.Common; -using MediaBrowser.Common.Net; using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Updates; -using MediaBrowser.Controller.Devices; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -150,25 +150,18 @@ namespace MediaBrowser.Api /// private readonly IApplicationHost _appHost; private readonly IInstallationManager _installationManager; - private readonly INetworkManager _network; - private readonly IDeviceManager _deviceManager; - public PluginService(IJsonSerializer jsonSerializer, + public PluginService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IJsonSerializer jsonSerializer, IApplicationHost appHost, - IInstallationManager installationManager, - INetworkManager network, - IDeviceManager deviceManager) - : base() + IInstallationManager installationManager) + : base(logger, serverConfigurationManager, httpResultFactory) { - if (jsonSerializer == null) - { - throw new ArgumentNullException(nameof(jsonSerializer)); - } - _appHost = appHost; _installationManager = installationManager; - _network = network; - _deviceManager = deviceManager; _jsonSerializer = jsonSerializer; } @@ -248,7 +241,7 @@ namespace MediaBrowser.Api { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs - var id = new Guid(GetPathValue(1)); + var id = Guid.Parse(GetPathValue(1)); var plugin = _appHost.Plugins.First(p => p.Id == id) as IHasPluginConfiguration; diff --git a/MediaBrowser.Api/Properties/AssemblyInfo.cs b/MediaBrowser.Api/Properties/AssemblyInfo.cs index 35bcbea5c..078af3e30 100644 --- a/MediaBrowser.Api/Properties/AssemblyInfo.cs +++ b/MediaBrowser.Api/Properties/AssemblyInfo.cs @@ -1,5 +1,6 @@ using System.Reflection; using System.Resources; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -14,6 +15,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en")] +[assembly: InternalsVisibleTo("Jellyfin.Api.Tests")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index b7e94b73f..2bd387229 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -6,6 +6,7 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.ScheduledTasks { @@ -85,27 +86,23 @@ namespace MediaBrowser.Api.ScheduledTasks public class ScheduledTaskService : BaseApiService { /// - /// Gets or sets the task manager. + /// The task manager. /// - /// The task manager. - private ITaskManager TaskManager { get; set; } - - private readonly IServerConfigurationManager _config; + private readonly ITaskManager _taskManager; /// /// Initializes a new instance of the class. /// /// The task manager. /// taskManager - public ScheduledTaskService(ITaskManager taskManager, IServerConfigurationManager config) + public ScheduledTaskService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ITaskManager taskManager) + : base(logger, serverConfigurationManager, httpResultFactory) { - if (taskManager == null) - { - throw new ArgumentNullException(nameof(taskManager)); - } - - TaskManager = taskManager; - _config = config; + _taskManager = taskManager; } /// @@ -115,7 +112,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// IEnumerable{TaskInfo}. public object Get(GetScheduledTasks request) { - IEnumerable result = TaskManager.ScheduledTasks + IEnumerable result = _taskManager.ScheduledTasks .OrderBy(i => i.Name); if (request.IsHidden.HasValue) @@ -171,7 +168,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// Task not found public object Get(GetScheduledTask request) { - var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); + var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); if (task == null) { @@ -190,14 +187,14 @@ namespace MediaBrowser.Api.ScheduledTasks /// Task not found public void Post(StartScheduledTask request) { - var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); + var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); if (task == null) { throw new ResourceNotFoundException("Task not found"); } - TaskManager.Execute(task, new TaskOptions()); + _taskManager.Execute(task, new TaskOptions()); } /// @@ -207,14 +204,14 @@ namespace MediaBrowser.Api.ScheduledTasks /// Task not found public void Delete(StopScheduledTask request) { - var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); + var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id)); if (task == null) { throw new ResourceNotFoundException("Task not found"); } - TaskManager.Cancel(task); + _taskManager.Cancel(task); } /// @@ -226,9 +223,9 @@ namespace MediaBrowser.Api.ScheduledTasks { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs - var id = GetPathValue(1); + var id = GetPathValue(1).ToString(); - var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.Ordinal)); + var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.Ordinal)); if (task == null) { diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs index 6c67d4fb1..0a3dc19dc 100644 --- a/MediaBrowser.Api/SearchService.cs +++ b/MediaBrowser.Api/SearchService.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; @@ -12,6 +13,7 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Search; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -122,7 +124,15 @@ namespace MediaBrowser.Api /// The library manager. /// The dto service. /// The image processor. - public SearchService(ISearchEngine searchEngine, ILibraryManager libraryManager, IDtoService dtoService, IImageProcessor imageProcessor) + public SearchService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ISearchEngine searchEngine, + ILibraryManager libraryManager, + IDtoService dtoService, + IImageProcessor imageProcessor) + : base(logger, serverConfigurationManager, httpResultFactory) { _searchEngine = searchEngine; _libraryManager = libraryManager; diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 6caf3b480..700861c55 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; @@ -12,6 +13,7 @@ using MediaBrowser.Controller.Session; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Services; using MediaBrowser.Model.Session; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Session { @@ -269,12 +271,12 @@ namespace MediaBrowser.Api.Session } /// - /// Class SessionsService + /// Class SessionsService. /// public class SessionsService : BaseApiService { /// - /// The _session manager + /// The _session manager. /// private readonly ISessionManager _sessionManager; @@ -283,9 +285,20 @@ namespace MediaBrowser.Api.Session private readonly IAuthenticationRepository _authRepo; private readonly IDeviceManager _deviceManager; private readonly ISessionContext _sessionContext; - private IServerApplicationHost _appHost; + private readonly IServerApplicationHost _appHost; - public SessionsService(ISessionManager sessionManager, IServerApplicationHost appHost, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo, IDeviceManager deviceManager, ISessionContext sessionContext) + public SessionsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ISessionManager sessionManager, + IServerApplicationHost appHost, + IUserManager userManager, + IAuthorizationContext authContext, + IAuthenticationRepository authRepo, + IDeviceManager deviceManager, + ISessionContext sessionContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _sessionManager = sessionManager; _userManager = userManager; diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 3a9eb7a55..714157fd7 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -1,12 +1,10 @@ using System.Linq; using System.Threading.Tasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -45,35 +43,32 @@ namespace MediaBrowser.Api [Authenticated(AllowBeforeStartupWizard = true, Roles = "Admin")] public class StartupWizardService : BaseApiService { - private readonly IServerConfigurationManager _config; - private readonly IServerApplicationHost _appHost; private readonly IUserManager _userManager; - private readonly IMediaEncoder _mediaEncoder; - private readonly IHttpClient _httpClient; - public StartupWizardService(IServerConfigurationManager config, IHttpClient httpClient, IServerApplicationHost appHost, IUserManager userManager, IMediaEncoder mediaEncoder) + public StartupWizardService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager) + : base(logger, serverConfigurationManager, httpResultFactory) { - _config = config; - _appHost = appHost; _userManager = userManager; - _mediaEncoder = mediaEncoder; - _httpClient = httpClient; } public void Post(ReportStartupWizardComplete request) { - _config.Configuration.IsStartupWizardCompleted = true; - _config.SetOptimalValues(); - _config.SaveConfiguration(); + ServerConfigurationManager.Configuration.IsStartupWizardCompleted = true; + ServerConfigurationManager.SetOptimalValues(); + ServerConfigurationManager.SaveConfiguration(); } public object Get(GetStartupConfiguration request) { var result = new StartupConfiguration { - UICulture = _config.Configuration.UICulture, - MetadataCountryCode = _config.Configuration.MetadataCountryCode, - PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage + UICulture = ServerConfigurationManager.Configuration.UICulture, + MetadataCountryCode = ServerConfigurationManager.Configuration.MetadataCountryCode, + PreferredMetadataLanguage = ServerConfigurationManager.Configuration.PreferredMetadataLanguage }; return result; @@ -81,17 +76,17 @@ namespace MediaBrowser.Api public void Post(UpdateStartupConfiguration request) { - _config.Configuration.UICulture = request.UICulture; - _config.Configuration.MetadataCountryCode = request.MetadataCountryCode; - _config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; - _config.SaveConfiguration(); + ServerConfigurationManager.Configuration.UICulture = request.UICulture; + ServerConfigurationManager.Configuration.MetadataCountryCode = request.MetadataCountryCode; + ServerConfigurationManager.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; + ServerConfigurationManager.SaveConfiguration(); } public void Post(UpdateRemoteAccessConfiguration request) { - _config.Configuration.EnableRemoteAccess = request.EnableRemoteAccess; - _config.Configuration.EnableUPnP = request.EnableAutomaticPortMapping; - _config.SaveConfiguration(); + ServerConfigurationManager.Configuration.EnableRemoteAccess = request.EnableRemoteAccess; + ServerConfigurationManager.Configuration.EnableUPnP = request.EnableAutomaticPortMapping; + ServerConfigurationManager.SaveConfiguration(); } public object Get(GetStartupUser request) diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 1878f51d0..c4a7ae78e 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; @@ -130,7 +131,18 @@ namespace MediaBrowser.Api.Subtitles private readonly IFileSystem _fileSystem; private readonly IAuthorizationContext _authContext; - public SubtitleService(ILibraryManager libraryManager, ISubtitleManager subtitleManager, ISubtitleEncoder subtitleEncoder, IMediaSourceManager mediaSourceManager, IProviderManager providerManager, IFileSystem fileSystem, IAuthorizationContext authContext) + public SubtitleService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ILibraryManager libraryManager, + ISubtitleManager subtitleManager, + ISubtitleEncoder subtitleEncoder, + IMediaSourceManager mediaSourceManager, + IProviderManager providerManager, + IFileSystem fileSystem, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _libraryManager = libraryManager; _subtitleManager = subtitleManager; diff --git a/MediaBrowser.Api/SuggestionsService.cs b/MediaBrowser.Api/SuggestionsService.cs index 4e857eafc..91f85db6f 100644 --- a/MediaBrowser.Api/SuggestionsService.cs +++ b/MediaBrowser.Api/SuggestionsService.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -8,6 +9,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -39,7 +41,15 @@ namespace MediaBrowser.Api private readonly IUserManager _userManager; private readonly ILibraryManager _libraryManager; - public SuggestionsService(IDtoService dtoService, IAuthorizationContext authContext, IUserManager userManager, ILibraryManager libraryManager) + public SuggestionsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IDtoService dtoService, + IAuthorizationContext authContext, + IUserManager userManager, + ILibraryManager libraryManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _dtoService = dtoService; _authContext = authContext; diff --git a/MediaBrowser.Api/System/ActivityLogService.cs b/MediaBrowser.Api/System/ActivityLogService.cs index 4d6ce1014..f95fa7ca0 100644 --- a/MediaBrowser.Api/System/ActivityLogService.cs +++ b/MediaBrowser.Api/System/ActivityLogService.cs @@ -1,9 +1,11 @@ using System; using System.Globalization; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Activity; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.System { @@ -35,7 +37,12 @@ namespace MediaBrowser.Api.System { private readonly IActivityManager _activityManager; - public ActivityLogService(IActivityManager activityManager) + public ActivityLogService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IActivityManager activityManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _activityManager = activityManager; } diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index 56184e18b..3a56ba701 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Net; @@ -103,13 +104,19 @@ namespace MediaBrowser.Api.System /// Initializes a new instance of the class. /// /// The app host. - /// The application paths. /// The file system. /// jsonSerializer - public SystemService(IServerApplicationHost appHost, IApplicationPaths appPaths, IFileSystem fileSystem, INetworkManager network) + public SystemService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IServerApplicationHost appHost, + IFileSystem fileSystem, + INetworkManager network) + : base(logger, serverConfigurationManager, httpResultFactory) { + _appPaths = serverConfigurationManager.ApplicationPaths; _appHost = appHost; - _appPaths = appPaths; _fileSystem = fileSystem; _network = network; } diff --git a/MediaBrowser.Api/TranscodingJob.cs b/MediaBrowser.Api/TranscodingJob.cs new file mode 100644 index 000000000..6d944d19e --- /dev/null +++ b/MediaBrowser.Api/TranscodingJob.cs @@ -0,0 +1,160 @@ +using System; +using System.Diagnostics; +using System.Threading; +using MediaBrowser.Api.Playback; +using MediaBrowser.Controller.MediaEncoding; +using MediaBrowser.Model.Dto; +using Microsoft.Extensions.Logging; + +namespace MediaBrowser.Api +{ + /// + /// Class TranscodingJob. + /// + public class TranscodingJob + { + /// + /// Gets or sets the play session identifier. + /// + /// The play session identifier. + public string PlaySessionId { get; set; } + + /// + /// Gets or sets the live stream identifier. + /// + /// The live stream identifier. + public string LiveStreamId { get; set; } + + public bool IsLiveOutput { get; set; } + + /// + /// Gets or sets the path. + /// + /// The path. + public MediaSourceInfo MediaSource { get; set; } + public string Path { get; set; } + /// + /// Gets or sets the type. + /// + /// The type. + public TranscodingJobType Type { get; set; } + /// + /// Gets or sets the process. + /// + /// The process. + public Process Process { get; set; } + public ILogger Logger { get; private set; } + /// + /// Gets or sets the active request count. + /// + /// The active request count. + public int ActiveRequestCount { get; set; } + /// + /// Gets or sets the kill timer. + /// + /// The kill timer. + private Timer KillTimer { get; set; } + + public string DeviceId { get; set; } + + public CancellationTokenSource CancellationTokenSource { get; set; } + + public object ProcessLock = new object(); + + public bool HasExited { get; set; } + public bool IsUserPaused { get; set; } + + public string Id { get; set; } + + public float? Framerate { get; set; } + public double? CompletionPercentage { get; set; } + + public long? BytesDownloaded { get; set; } + public long? BytesTranscoded { get; set; } + public int? BitRate { get; set; } + + public long? TranscodingPositionTicks { get; set; } + public long? DownloadPositionTicks { get; set; } + + public TranscodingThrottler TranscodingThrottler { get; set; } + + private readonly object _timerLock = new object(); + + public DateTime LastPingDate { get; set; } + public int PingTimeout { get; set; } + + public TranscodingJob(ILogger logger) + { + Logger = logger; + } + + public void StopKillTimer() + { + lock (_timerLock) + { + if (KillTimer != null) + { + KillTimer.Change(Timeout.Infinite, Timeout.Infinite); + } + } + } + + public void DisposeKillTimer() + { + lock (_timerLock) + { + if (KillTimer != null) + { + KillTimer.Dispose(); + KillTimer = null; + } + } + } + + public void StartKillTimer(Action callback) + { + StartKillTimer(callback, PingTimeout); + } + + public void StartKillTimer(Action callback, int intervalMs) + { + if (HasExited) + { + return; + } + + lock (_timerLock) + { + if (KillTimer == null) + { + Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + KillTimer = new Timer(new TimerCallback(callback), this, intervalMs, Timeout.Infinite); + } + else + { + Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + KillTimer.Change(intervalMs, Timeout.Infinite); + } + } + } + + public void ChangeKillTimerIfStarted() + { + if (HasExited) + { + return; + } + + lock (_timerLock) + { + if (KillTimer != null) + { + var intervalMs = PingTimeout; + + Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + KillTimer.Change(intervalMs, Timeout.Infinite); + } + } + } + } +} diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 1340bd8ef..ac2eca733 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -3,17 +3,18 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using MediaBrowser.Model.Querying; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -252,16 +253,11 @@ namespace MediaBrowser.Api /// private readonly IUserManager _userManager; - /// - /// The _user data repository - /// - private readonly IUserDataManager _userDataManager; /// /// The _library manager /// private readonly ILibraryManager _libraryManager; - private readonly IItemRepository _itemRepo; private readonly IDtoService _dtoService; private readonly ITVSeriesManager _tvSeriesManager; private readonly IAuthorizationContext _authContext; @@ -272,12 +268,19 @@ namespace MediaBrowser.Api /// The user manager. /// The user data repository. /// The library manager. - public TvShowsService(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService, ITVSeriesManager tvSeriesManager, IAuthorizationContext authContext) + public TvShowsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IDtoService dtoService, + ITVSeriesManager tvSeriesManager, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; - _userDataManager = userDataManager; _libraryManager = libraryManager; - _itemRepo = itemRepo; _dtoService = dtoService; _tvSeriesManager = tvSeriesManager; _authContext = authContext; diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index a30f8adfe..adb0a440f 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -49,6 +50,27 @@ namespace MediaBrowser.Api.UserLibrary [Authenticated] public class ArtistsService : BaseItemsByNameService { + public ArtistsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + userDataRepository, + dtoService, + authorizationContext) + { + } + /// /// Gets the specified request. /// @@ -122,9 +144,5 @@ namespace MediaBrowser.Api.UserLibrary { throw new NotImplementedException(); } - - public ArtistsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) : base(userManager, libraryManager, userDataRepository, itemRepository, dtoService, authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index e3c9ae58e..9fa222d32 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -19,37 +20,47 @@ namespace MediaBrowser.Api.UserLibrary public abstract class BaseItemsByNameService : BaseApiService where TItemType : BaseItem, IItemByName { - /// - /// The _user manager - /// - protected readonly IUserManager UserManager; - /// - /// The library manager - /// - protected readonly ILibraryManager LibraryManager; - protected readonly IUserDataManager UserDataRepository; - protected readonly IItemRepository ItemRepository; - protected IDtoService DtoService { get; private set; } - protected IAuthorizationContext AuthorizationContext { get; private set; } - /// /// Initializes a new instance of the class. /// /// The user manager. /// The library manager. /// The user data repository. - /// The item repository. /// The dto service. - protected BaseItemsByNameService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) + protected BaseItemsByNameService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base(logger, serverConfigurationManager, httpResultFactory) { UserManager = userManager; LibraryManager = libraryManager; UserDataRepository = userDataRepository; - ItemRepository = itemRepository; DtoService = dtoService; AuthorizationContext = authorizationContext; } + /// + /// Gets the _user manager. + /// + protected IUserManager UserManager { get; } + + /// + /// Gets the library manager + /// + protected ILibraryManager LibraryManager { get; } + + protected IUserDataManager UserDataRepository { get; } + + protected IDtoService DtoService { get; } + + protected IAuthorizationContext AuthorizationContext { get; } + protected BaseItem GetParentItem(GetItemsByName request) { BaseItem parentItem; diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.cs index 0c04d02dd..13bb88ca8 100644 --- a/MediaBrowser.Api/UserLibrary/GenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GenresService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -9,6 +10,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -47,6 +49,27 @@ namespace MediaBrowser.Api.UserLibrary [Authenticated] public class GenresService : BaseItemsByNameService { + public GenresService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + userDataRepository, + dtoService, + authorizationContext) + { + } + /// /// Gets the specified request. /// @@ -114,9 +137,5 @@ namespace MediaBrowser.Api.UserLibrary { throw new NotImplementedException(); } - - public GenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) : base(userManager, libraryManager, userDataRepository, itemRepository, dtoService, authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index b4a302648..1511420d3 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -58,25 +58,17 @@ namespace MediaBrowser.Api.UserLibrary /// The library manager. /// The localization. /// The dto service. - public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILocalizationManager localization, IDtoService dtoService, IAuthorizationContext authContext) + public ItemsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + ILocalizationManager localization, + IDtoService dtoService, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { - if (userManager == null) - { - throw new ArgumentNullException(nameof(userManager)); - } - if (libraryManager == null) - { - throw new ArgumentNullException(nameof(libraryManager)); - } - if (localization == null) - { - throw new ArgumentNullException(nameof(localization)); - } - if (dtoService == null) - { - throw new ArgumentNullException(nameof(dtoService)); - } - _userManager = userManager; _libraryManager = libraryManager; _localization = localization; diff --git a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs index 94f5262b0..e9caca14a 100644 --- a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs +++ b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -38,6 +39,27 @@ namespace MediaBrowser.Api.UserLibrary [Authenticated] public class MusicGenresService : BaseItemsByNameService { + public MusicGenresService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + userDataRepository, + dtoService, + authorizationContext) + { + } + /// /// Gets the specified request. /// @@ -98,9 +120,5 @@ namespace MediaBrowser.Api.UserLibrary { throw new NotImplementedException(); } - - public MusicGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) : base(userManager, libraryManager, userDataRepository, itemRepository, dtoService, authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs index 2024e9e63..853eada25 100644 --- a/MediaBrowser.Api/UserLibrary/PersonsService.cs +++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -9,6 +10,7 @@ using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -47,6 +49,27 @@ namespace MediaBrowser.Api.UserLibrary [Authenticated] public class PersonsService : BaseItemsByNameService { + public PersonsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + userDataRepository, + dtoService, + authorizationContext) + { + } + /// /// Gets the specified request. /// @@ -120,9 +143,5 @@ namespace MediaBrowser.Api.UserLibrary Items = items.Take(query.Limit ?? int.MaxValue).Select(i => (i as BaseItem, new ItemCounts())).ToArray() }; } - - public PersonsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) : base(userManager, libraryManager, userDataRepository, itemRepository, dtoService, authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/UserLibrary/PlaystateService.cs b/MediaBrowser.Api/UserLibrary/PlaystateService.cs index b40a92a7c..9d1cf5d9e 100644 --- a/MediaBrowser.Api/UserLibrary/PlaystateService.cs +++ b/MediaBrowser.Api/UserLibrary/PlaystateService.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.Threading.Tasks; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; @@ -233,7 +234,17 @@ namespace MediaBrowser.Api.UserLibrary private readonly ISessionContext _sessionContext; private readonly IAuthorizationContext _authContext; - public PlaystateService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, ISessionManager sessionManager, ISessionContext sessionContext, IAuthorizationContext authContext) + public PlaystateService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + IUserDataManager userDataRepository, + ILibraryManager libraryManager, + ISessionManager sessionManager, + ISessionContext sessionContext, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _userDataRepository = userDataRepository; @@ -256,7 +267,7 @@ namespace MediaBrowser.Api.UserLibrary private UserItemDataDto MarkPlayed(MarkPlayedItem request) { - var user = _userManager.GetUserById(request.UserId); + var user = _userManager.GetUserById(Guid.Parse(request.UserId)); DateTime? datePlayed = null; @@ -406,7 +417,7 @@ namespace MediaBrowser.Api.UserLibrary private UserItemDataDto MarkUnplayed(MarkUnplayedItem request) { - var user = _userManager.GetUserById(request.UserId); + var user = _userManager.GetUserById(Guid.Parse(request.UserId)); var session = GetSession(_sessionContext); diff --git a/MediaBrowser.Api/UserLibrary/StudiosService.cs b/MediaBrowser.Api/UserLibrary/StudiosService.cs index 890acc931..683ce5d09 100644 --- a/MediaBrowser.Api/UserLibrary/StudiosService.cs +++ b/MediaBrowser.Api/UserLibrary/StudiosService.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -46,6 +47,27 @@ namespace MediaBrowser.Api.UserLibrary [Authenticated] public class StudiosService : BaseItemsByNameService { + public StudiosService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + userDataRepository, + dtoService, + authorizationContext) + { + } + /// /// Gets the specified request. /// @@ -106,9 +128,5 @@ namespace MediaBrowser.Api.UserLibrary { throw new NotImplementedException(); } - - public StudiosService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) : base(userManager, libraryManager, userDataRepository, itemRepository, dtoService, authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index da0bf6dcb..2ec08f578 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -14,6 +15,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -270,7 +272,18 @@ namespace MediaBrowser.Api.UserLibrary private readonly IFileSystem _fileSystem; private readonly IAuthorizationContext _authContext; - public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IDtoService dtoService, IUserViewManager userViewManager, IFileSystem fileSystem, IAuthorizationContext authContext) + public UserLibraryService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IUserViewManager userViewManager, + IFileSystem fileSystem, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _libraryManager = libraryManager; diff --git a/MediaBrowser.Api/UserLibrary/UserViewsService.cs b/MediaBrowser.Api/UserLibrary/UserViewsService.cs index d62049ce9..0fffb0622 100644 --- a/MediaBrowser.Api/UserLibrary/UserViewsService.cs +++ b/MediaBrowser.Api/UserLibrary/UserViewsService.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -51,11 +52,15 @@ namespace MediaBrowser.Api.UserLibrary private readonly ILibraryManager _libraryManager; public UserViewsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IUserManager userManager, IUserViewManager userViewManager, IDtoService dtoService, IAuthorizationContext authContext, ILibraryManager libraryManager) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _userViewManager = userViewManager; diff --git a/MediaBrowser.Api/UserLibrary/YearsService.cs b/MediaBrowser.Api/UserLibrary/YearsService.cs index 0ee0fd219..07b9aff1b 100644 --- a/MediaBrowser.Api/UserLibrary/YearsService.cs +++ b/MediaBrowser.Api/UserLibrary/YearsService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -8,6 +9,7 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -46,6 +48,27 @@ namespace MediaBrowser.Api.UserLibrary [Authenticated] public class YearsService : BaseItemsByNameService { + public YearsService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + IUserManager userManager, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IDtoService dtoService, + IAuthorizationContext authorizationContext) + : base( + logger, + serverConfigurationManager, + httpResultFactory, + userManager, + libraryManager, + userDataRepository, + dtoService, + authorizationContext) + { + } + /// /// Gets the specified request. /// @@ -105,9 +128,5 @@ namespace MediaBrowser.Api.UserLibrary .Distinct() .Select(year => LibraryManager.GetYear(year)); } - - public YearsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService, IAuthorizationContext authorizationContext) : base(userManager, libraryManager, userDataRepository, itemRepository, dtoService, authorizationContext) - { - } } } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 2c0a0b443..e1b01b012 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -244,22 +244,23 @@ namespace MediaBrowser.Api /// private readonly IUserManager _userManager; private readonly ISessionManager _sessionMananger; - private readonly IServerConfigurationManager _config; private readonly INetworkManager _networkManager; private readonly IDeviceManager _deviceManager; private readonly IAuthorizationContext _authContext; public UserService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, IUserManager userManager, ISessionManager sessionMananger, - IServerConfigurationManager config, INetworkManager networkManager, IDeviceManager deviceManager, IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _userManager = userManager; _sessionMananger = sessionMananger; - _config = config; _networkManager = networkManager; _deviceManager = deviceManager; _authContext = authContext; @@ -268,7 +269,7 @@ namespace MediaBrowser.Api public object Get(GetPublicUsers request) { // If the startup wizard hasn't been completed then just return all users - if (!_config.Configuration.IsStartupWizardCompleted) + if (!ServerConfigurationManager.Configuration.IsStartupWizardCompleted) { return Get(new GetUsers { @@ -497,9 +498,9 @@ namespace MediaBrowser.Api /// The request. public async Task Post(UpdateUser request) { - var id = GetPathValue(1); + var id = Guid.Parse(GetPathValue(1)); - AssertCanUpdateUser(_authContext, _userManager, new Guid(id), false); + AssertCanUpdateUser(_authContext, _userManager, id, false); var dtoUser = request; diff --git a/MediaBrowser.Api/VideosService.cs b/MediaBrowser.Api/VideosService.cs index 474036f5c..46b6d5a94 100644 --- a/MediaBrowser.Api/VideosService.cs +++ b/MediaBrowser.Api/VideosService.cs @@ -7,11 +7,10 @@ using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -51,19 +50,21 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IUserManager _userManager; private readonly IDtoService _dtoService; - private readonly IFileSystem _fileSystem; - private readonly IItemRepository _itemRepo; - private readonly IServerConfigurationManager _config; private readonly IAuthorizationContext _authContext; - public VideosService(ILibraryManager libraryManager, IUserManager userManager, IDtoService dtoService, IItemRepository itemRepo, IFileSystem fileSystem, IServerConfigurationManager config, IAuthorizationContext authContext) + public VideosService( + ILogger logger, + IServerConfigurationManager serverConfigurationManager, + IHttpResultFactory httpResultFactory, + ILibraryManager libraryManager, + IUserManager userManager, + IDtoService dtoService, + IAuthorizationContext authContext) + : base(logger, serverConfigurationManager, httpResultFactory) { _libraryManager = libraryManager; _userManager = userManager; _dtoService = dtoService; - _itemRepo = itemRepo; - _fileSystem = fileSystem; - _config = config; _authContext = authContext; } @@ -84,9 +85,8 @@ namespace MediaBrowser.Api var dtoOptions = GetDtoOptions(_authContext, request); - var video = item as Video; BaseItemDto[] items; - if (video != null) + if (item is Video video) { items = video.GetAdditionalParts() .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video)) @@ -94,7 +94,7 @@ namespace MediaBrowser.Api } else { - items = new BaseItemDto[] { }; + items = Array.Empty(); } var result = new QueryResult diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs index ce4e3f530..eb735d31a 100644 --- a/MediaBrowser.Controller/Library/IUserDataManager.cs +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Library { /// - /// Interface IUserDataManager + /// Interface IUserDataManager. /// public interface IUserDataManager { @@ -26,13 +26,11 @@ namespace MediaBrowser.Controller.Library /// The user data. /// The reason. /// The cancellation token. - /// Task. void SaveUserData(Guid userId, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); void SaveUserData(User userId, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); UserItemData GetUserData(User user, BaseItem item); - UserItemData GetUserData(string userId, BaseItem item); UserItemData GetUserData(Guid userId, BaseItem item); /// diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index eea2e3a71..8d92c9f6f 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -49,20 +49,13 @@ namespace MediaBrowser.Controller.Library event EventHandler> UserLockedOut; /// - /// Gets a User by Id. + /// Gets a user by Id. /// /// The id. /// The user with the specified Id, or null if the user doesn't exist. /// id is an empty Guid. User GetUserById(Guid id); - /// - /// Gets the user by identifier. - /// - /// The identifier. - /// User. - User GetUserById(string id); - /// /// Gets the name of the user by. /// diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index b8abe49e3..9de6fef61 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -172,16 +172,18 @@ namespace MediaBrowser.Model.Configuration if (string.IsNullOrWhiteSpace(value)) { // If baseUrl is empty, set an empty prefix string - value = string.Empty; + _baseUrl = string.Empty; + return; } - else if (!value.StartsWith("/")) + + if (value[0] != '/') { // If baseUrl was not configured with a leading slash, append one for consistency value = "/" + value; } // Normalize the end of the string - if (value.EndsWith("/")) + if (value[value.Length - 1] == '/') { // If baseUrl was configured with a trailing slash, remove it for consistency value = value.Remove(value.Length - 1); diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index d84bc2abb..981c3a53a 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -16,7 +16,6 @@ using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Extensions; using MediaBrowser.Model.IO; using MediaBrowser.XbmcMetadata.Configuration; using Microsoft.Extensions.Logging; @@ -856,7 +855,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return; } - var user = userManager.GetUserById(userId); + var user = userManager.GetUserById(Guid.Parse(userId)); if (user == null) { diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 27c8c1668..dea4bf68f 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.MediaEncoding.Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Naming.Tests", "tests\Jellyfin.Naming.Tests\Jellyfin.Naming.Tests.csproj", "{3998657B-1CCC-49DD-A19F-275DC8495F57}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Api.Tests", "tests\Jellyfin.Api.Tests\Jellyfin.Api.Tests.csproj", "{A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -165,6 +167,10 @@ Global {3998657B-1CCC-49DD-A19F-275DC8495F57}.Debug|Any CPU.Build.0 = Debug|Any CPU {3998657B-1CCC-49DD-A19F-275DC8495F57}.Release|Any CPU.ActiveCfg = Release|Any CPU {3998657B-1CCC-49DD-A19F-275DC8495F57}.Release|Any CPU.Build.0 = Release|Any CPU + {A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -194,5 +200,6 @@ Global {DF194677-DFD3-42AF-9F75-D44D5A416478} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6} {28464062-0939-4AA7-9F7B-24DDDA61A7C0} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6} {3998657B-1CCC-49DD-A19F-275DC8495F57} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6} + {A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6} EndGlobalSection EndGlobal diff --git a/tests/Jellyfin.Api.Tests/GetPathValueTests.cs b/tests/Jellyfin.Api.Tests/GetPathValueTests.cs new file mode 100644 index 000000000..b01d1af1f --- /dev/null +++ b/tests/Jellyfin.Api.Tests/GetPathValueTests.cs @@ -0,0 +1,45 @@ +using MediaBrowser.Api; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Net; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using Xunit; + +namespace Jellyfin.Api.Tests +{ + public class GetPathValueTests + { + [Theory] + [InlineData("https://localhost:8096/ScheduledTasks/1234/Triggers", "", 1, "1234")] + [InlineData("https://localhost:8096/emby/ScheduledTasks/1234/Triggers", "", 1, "1234")] + [InlineData("https://localhost:8096/mediabrowser/ScheduledTasks/1234/Triggers", "", 1, "1234")] + [InlineData("https://localhost:8096/jellyfin/2/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")] + [InlineData("https://localhost:8096/jellyfin/2/emby/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")] + [InlineData("https://localhost:8096/jellyfin/2/mediabrowser/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")] + [InlineData("https://localhost:8096/JELLYFIN/2/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")] + [InlineData("https://localhost:8096/JELLYFIN/2/Emby/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")] + [InlineData("https://localhost:8096/JELLYFIN/2/MediaBrowser/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")] + public void GetPathValueTest(string path, string baseUrl, int index, string value) + { + var reqMock = Mock.Of(x => x.PathInfo == path); + var conf = new ServerConfiguration() + { + BaseUrl = baseUrl + }; + + var confManagerMock = Mock.Of(x => x.Configuration == conf); + + var service = new BrandingService( + new NullLogger(), + confManagerMock, + Mock.Of()) + { + Request = reqMock + }; + + Assert.Equal(value, service.GetPathValue(index).ToString()); + } + } +} diff --git a/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj new file mode 100644 index 000000000..1671b8d79 --- /dev/null +++ b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp3.0 + false + + + + + + + + + + + + + + + From 42ffddc26932bcf2da762bf4fe1ec4bdc42e8166 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 1 Nov 2019 18:38:54 +0100 Subject: [PATCH 03/53] Fix more warnings --- .../Activity/ActivityLogEntryPoint.cs | 15 +++ .../Activity/ActivityManager.cs | 2 + .../Activity/ActivityRepository.cs | 2 + .../AppBase/BaseConfigurationManager.cs | 21 ++- .../Archiving/ZipClient.cs | 8 +- .../Branding/BrandingConfigurationFactory.cs | 2 + .../Browser/BrowserLauncher.cs | 3 +- .../ChannelDynamicMediaSourceProvider.cs | 8 ++ .../Channels/ChannelImageProvider.cs | 2 + .../Channels/ChannelManager.cs | 2 + .../Channels/ChannelPostScanTask.cs | 2 + .../Channels/RefreshChannelsScheduledTask.cs | 2 + .../Collections/CollectionImageProvider.cs | 2 + .../Collections/CollectionManager.cs | 2 + .../ServerConfigurationManager.cs | 30 ++++- .../Cryptography/CryptographyProvider.cs | 13 ++ .../Data/BaseSqliteRepository.cs | 6 + .../Data/CleanDatabaseScheduledTask.cs | 2 + .../Data/ManagedConnection.cs | 2 + .../SqliteDisplayPreferencesRepository.cs | 2 + .../Data/SqliteExtensions.cs | 2 + .../Data/SqliteUserDataRepository.cs | 2 + .../Data/SqliteUserRepository.cs | 2 + .../Data/TypeMapper.cs | 11 +- .../Devices/DeviceId.cs | 2 + .../Devices/DeviceManager.cs | 2 + .../Diagnostics/CommonProcess.cs | 2 + .../Diagnostics/ProcessFactory.cs | 2 + Emby.Server.Implementations/Dto/DtoService.cs | 2 + .../EntryPoints/AutomaticRestartEntryPoint.cs | 2 + .../EntryPoints/ExternalPortForwarding.cs | 2 + .../EntryPoints/LibraryChangedNotifier.cs | 2 + .../EntryPoints/RecordingNotifier.cs | 2 + .../EntryPoints/RefreshUsersMetadata.cs | 45 ++++--- .../EntryPoints/ServerEventNotifier.cs | 103 ++++++++------ .../EntryPoints/StartupWizard.cs | 21 +-- .../EntryPoints/UdpServerEntryPoint.cs | 35 ++--- .../EntryPoints/UserDataChangeNotifier.cs | 2 + .../HttpClientManager/HttpClientManager.cs | 1 + .../HttpServer/FileWriter.cs | 2 + .../HttpServer/HttpListenerHost.cs | 2 + .../HttpServer/HttpResultFactory.cs | 8 +- .../HttpServer/IHttpListener.cs | 2 + .../HttpServer/RangeRequestWriter.cs | 2 + .../HttpServer/ResponseFilter.cs | 12 +- .../HttpServer/Security/AuthService.cs | 2 + .../Security/AuthorizationContext.cs | 2 + .../HttpServer/Security/SessionContext.cs | 2 + .../HttpServer/StreamWriter.cs | 57 ++++---- .../HttpServer/WebSocketConnection.cs | 126 +++++++++--------- .../IO/ExtendedFileSystemInfo.cs | 2 + .../IO/FileRefresher.cs | 2 + .../IO/LibraryMonitor.cs | 10 +- .../IO/ManagedFileSystem.cs | 2 + .../IO/MbLinkShortcutHandler.cs | 2 + .../IO/StreamHelper.cs | 2 + .../Images/BaseDynamicImageProvider.cs | 2 + .../Library/CoreResolutionIgnoreRule.cs | 4 + .../Library/DefaultAuthenticationProvider.cs | 10 +- .../Library/DefaultPasswordResetProvider.cs | 13 +- .../Library/ExclusiveLiveStream.cs | 2 + .../Library/InvalidAuthProvider.cs | 11 ++ .../Library/LibraryManager.cs | 2 + .../Library/LiveStreamHelper.cs | 2 + .../Library/MediaSourceManager.cs | 2 + .../Library/MediaStreamSelector.cs | 2 + .../Library/MusicManager.cs | 2 + .../Library/PathExtensions.cs | 4 + .../Library/Resolvers/Audio/AudioResolver.cs | 4 +- .../Resolvers/Audio/MusicAlbumResolver.cs | 35 +++-- .../Resolvers/Audio/MusicArtistResolver.cs | 15 ++- .../Library/Resolvers/BaseVideoResolver.cs | 4 +- .../Library/Resolvers/Books/BookResolver.cs | 15 +-- .../Library/Resolvers/FolderResolver.cs | 4 +- .../Library/Resolvers/ItemResolver.cs | 2 +- .../Resolvers/Movies/BoxSetResolver.cs | 5 +- .../Library/Resolvers/Movies/MovieResolver.cs | 10 +- .../Library/Resolvers/PhotoAlbumResolver.cs | 10 ++ .../Library/Resolvers/PhotoResolver.cs | 2 + .../Library/Resolvers/PlaylistResolver.cs | 3 +- .../Resolvers/SpecialFolderResolver.cs | 2 + .../Library/Resolvers/TV/EpisodeResolver.cs | 7 +- .../Library/Resolvers/TV/SeriesResolver.cs | 10 +- .../Library/Resolvers/VideoResolver.cs | 2 + .../Library/SearchEngine.cs | 4 +- .../Library/UserDataManager.cs | 4 +- .../Library/UserManager.cs | 28 ++-- .../Library/UserViewManager.cs | 2 + .../Library/Validators/ArtistsPostScanTask.cs | 6 +- .../Library/Validators/ArtistsValidator.cs | 6 +- .../Library/Validators/GenresPostScanTask.cs | 3 + .../Library/Validators/GenresValidator.cs | 15 ++- .../Validators/MusicGenresPostScanTask.cs | 4 +- .../Validators/MusicGenresValidator.cs | 15 ++- .../Library/Validators/PeopleValidator.cs | 1 + .../Library/Validators/StudiosPostScanTask.cs | 6 +- .../Library/Validators/StudiosValidator.cs | 16 ++- 97 files changed, 624 insertions(+), 279 deletions(-) diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index efaaa116c..b622a3167 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; @@ -39,6 +41,19 @@ namespace Emby.Server.Implementations.Activity private readonly IServerApplicationHost _appHost; private readonly IDeviceManager _deviceManager; + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public ActivityLogEntryPoint( ILogger logger, ISessionManager sessionManager, diff --git a/Emby.Server.Implementations/Activity/ActivityManager.cs b/Emby.Server.Implementations/Activity/ActivityManager.cs index 0c513ea12..a30e93912 100644 --- a/Emby.Server.Implementations/Activity/ActivityManager.cs +++ b/Emby.Server.Implementations/Activity/ActivityManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Linq; using MediaBrowser.Controller.Library; diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index ffaeaa541..7be72319e 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 67bb25b07..f5ca8e144 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -84,6 +84,7 @@ namespace Emby.Server.Implementations.AppBase /// /// The logger. protected ILogger Logger { get; private set; } + /// /// Gets the XML serializer. /// @@ -131,6 +132,10 @@ namespace Emby.Server.Implementations.AppBase } } + /// + /// Adds parts. + /// + /// The configuration factories. public virtual void AddParts(IEnumerable factories) { _configurationFactories = factories.ToArray(); @@ -223,7 +228,7 @@ namespace Emby.Server.Implementations.AppBase /// Replaces the cache path. /// /// The new configuration. - /// + /// The new cache path doesn't exist. private void ValidateCachePath(BaseApplicationConfiguration newConfig) { var newPath = newConfig.CachePath; @@ -234,7 +239,7 @@ namespace Emby.Server.Implementations.AppBase // Validate if (!Directory.Exists(newPath)) { - throw new FileNotFoundException( + throw new DirectoryNotFoundException( string.Format( CultureInfo.InvariantCulture, "{0} does not exist.", @@ -245,6 +250,10 @@ namespace Emby.Server.Implementations.AppBase } } + /// + /// Ensures that we have write access to the path. + /// + /// The path. protected void EnsureWriteAccess(string path) { var file = Path.Combine(path, Guid.NewGuid().ToString()); @@ -257,6 +266,7 @@ namespace Emby.Server.Implementations.AppBase return Path.Combine(CommonApplicationPaths.ConfigurationDirectoryPath, key.ToLowerInvariant() + ".xml"); } + /// public object GetConfiguration(string key) { return _configurations.GetOrAdd(key, k => @@ -303,6 +313,7 @@ namespace Emby.Server.Implementations.AppBase } } + /// public void SaveConfiguration(string key, object configuration) { var configurationStore = GetConfigurationStore(key); @@ -339,6 +350,11 @@ namespace Emby.Server.Implementations.AppBase OnNamedConfigurationUpdated(key, configuration); } + /// + /// Event handler for when a named configuration got updates. + /// + /// The key of the configuration. + /// The old configuration. protected virtual void OnNamedConfigurationUpdated(string key, object configuration) { NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs @@ -348,6 +364,7 @@ namespace Emby.Server.Implementations.AppBase }); } + /// public Type GetConfigurationType(string key) { return GetConfigurationStore(key) diff --git a/Emby.Server.Implementations/Archiving/ZipClient.cs b/Emby.Server.Implementations/Archiving/ZipClient.cs index 6b0fd2dc6..4a6e5cfd7 100644 --- a/Emby.Server.Implementations/Archiving/ZipClient.cs +++ b/Emby.Server.Implementations/Archiving/ZipClient.cs @@ -10,15 +10,10 @@ using SharpCompress.Readers.Zip; namespace Emby.Server.Implementations.Archiving { /// - /// Class DotNetZipClient + /// Class DotNetZipClient. /// public class ZipClient : IZipClient { - public ZipClient() - { - - } - /// /// Extracts all. /// @@ -144,7 +139,6 @@ namespace Emby.Server.Implementations.Archiving } } - /// /// Extracts all from tar. /// diff --git a/Emby.Server.Implementations/Branding/BrandingConfigurationFactory.cs b/Emby.Server.Implementations/Branding/BrandingConfigurationFactory.cs index b27f84848..93000ae12 100644 --- a/Emby.Server.Implementations/Branding/BrandingConfigurationFactory.cs +++ b/Emby.Server.Implementations/Branding/BrandingConfigurationFactory.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System.Collections.Generic; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Branding; diff --git a/Emby.Server.Implementations/Browser/BrowserLauncher.cs b/Emby.Server.Implementations/Browser/BrowserLauncher.cs index 718129ef0..f5da0d018 100644 --- a/Emby.Server.Implementations/Browser/BrowserLauncher.cs +++ b/Emby.Server.Implementations/Browser/BrowserLauncher.cs @@ -4,7 +4,7 @@ using MediaBrowser.Controller; namespace Emby.Server.Implementations.Browser { /// - /// Class BrowserLauncher + /// Class BrowserLauncher. /// public static class BrowserLauncher { @@ -32,6 +32,7 @@ namespace Emby.Server.Implementations.Browser /// /// Opens the URL. /// + /// The application host instance. /// The URL. private static void OpenUrl(IServerApplicationHost appHost, string url) { diff --git a/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs b/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs index c10f00f9b..6016fed07 100644 --- a/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs +++ b/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Threading; @@ -13,11 +15,16 @@ namespace Emby.Server.Implementations.Channels { private readonly ChannelManager _channelManager; + /// + /// Initializes a new instance of the class. + /// + /// The channel manager. public ChannelDynamicMediaSourceProvider(IChannelManager channelManager) { _channelManager = (ChannelManager)channelManager; } + /// public Task> GetMediaSources(BaseItem item, CancellationToken cancellationToken) { if (item.SourceType == SourceType.Channel) @@ -28,6 +35,7 @@ namespace Emby.Server.Implementations.Channels return Task.FromResult>(new List()); } + /// public Task OpenMediaSource(string openToken, List currentLiveStreams, CancellationToken cancellationToken) { throw new NotImplementedException(); diff --git a/Emby.Server.Implementations/Channels/ChannelImageProvider.cs b/Emby.Server.Implementations/Channels/ChannelImageProvider.cs index bafa68818..62aeb9bcb 100644 --- a/Emby.Server.Implementations/Channels/ChannelImageProvider.cs +++ b/Emby.Server.Implementations/Channels/ChannelImageProvider.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System.Collections.Generic; using System.Linq; using System.Threading; diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 151670074..ceca87822 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Concurrent; using System.Collections.Generic; diff --git a/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs b/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs index 3c7cbb115..2712fc8c5 100644 --- a/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs +++ b/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Linq; using System.Threading; diff --git a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs index 303a8ac7b..5774c0415 100644 --- a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs +++ b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Threading; diff --git a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs index 0244c4a68..485adf14a 100644 --- a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs +++ b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Linq; diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index c5a77ce5b..2b8a5bdc5 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs index 2291345be..4def7ca40 100644 --- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Globalization; using System.IO; using Emby.Server.Implementations.AppBase; using MediaBrowser.Common.Configuration; @@ -17,7 +19,6 @@ namespace Emby.Server.Implementations.Configuration /// public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager { - /// /// Initializes a new instance of the class. /// @@ -31,6 +32,9 @@ namespace Emby.Server.Implementations.Configuration UpdateMetadataPath(); } + /// + /// Configuration updating event. + /// public event EventHandler> ConfigurationUpdating; /// @@ -97,7 +101,7 @@ namespace Emby.Server.Implementations.Configuration /// Validates the SSL certificate. /// /// The new configuration. - /// + /// The certificate path doesn't exist. private void ValidateSslCertificate(BaseApplicationConfiguration newConfig) { var serverConfig = (ServerConfiguration)newConfig; @@ -105,12 +109,16 @@ namespace Emby.Server.Implementations.Configuration var newPath = serverConfig.CertificatePath; if (!string.IsNullOrWhiteSpace(newPath) - && !string.Equals(Configuration.CertificatePath ?? string.Empty, newPath)) + && !string.Equals(Configuration.CertificatePath, newPath, StringComparison.Ordinal)) { // Validate if (!File.Exists(newPath)) { - throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", newPath)); + throw new FileNotFoundException( + string.Format( + CultureInfo.InvariantCulture, + "Certificate file '{0}' does not exist.", + newPath)); } } } @@ -119,24 +127,32 @@ namespace Emby.Server.Implementations.Configuration /// Validates the metadata path. /// /// The new configuration. - /// + /// The new config path doesn't exist. private void ValidateMetadataPath(ServerConfiguration newConfig) { var newPath = newConfig.MetadataPath; if (!string.IsNullOrWhiteSpace(newPath) - && !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath)) + && !string.Equals(Configuration.MetadataPath, newPath, StringComparison.Ordinal)) { // Validate if (!Directory.Exists(newPath)) { - throw new FileNotFoundException(string.Format("{0} does not exist.", newPath)); + throw new DirectoryNotFoundException( + string.Format( + CultureInfo.InvariantCulture, + "{0} does not exist.", + newPath)); } EnsureWriteAccess(newPath); } } + /// + /// Sets all config values to the optimal value. + /// + /// If the configuration changed. public bool SetOptimalValues() { var config = Configuration; diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs index fec7d161e..776074b72 100644 --- a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs +++ b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs @@ -6,6 +6,9 @@ using static MediaBrowser.Common.Cryptography.Constants; namespace Emby.Server.Implementations.Cryptography { + /// + /// Class providing abstractions over cryptographic functions. + /// public class CryptographyProvider : ICryptoProvider, IDisposable { private static readonly HashSet _supportedHashMethods = new HashSet() @@ -42,8 +45,10 @@ namespace Emby.Server.Implementations.Cryptography _randomNumberGenerator = RandomNumberGenerator.Create(); } + /// public string DefaultHashMethod => "PBKDF2"; + /// public IEnumerable GetSupportedHashMethods() => _supportedHashMethods; @@ -62,6 +67,7 @@ namespace Emby.Server.Implementations.Cryptography throw new CryptographicException($"Cannot currently use PBKDF2 with requested hash method: {method}"); } + /// public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt) { if (hashMethod == DefaultHashMethod) @@ -89,12 +95,15 @@ namespace Emby.Server.Implementations.Cryptography throw new CryptographicException($"Requested hash method is not supported: {hashMethod}"); } + /// public byte[] ComputeHashWithDefaultMethod(byte[] bytes, byte[] salt) => PBKDF2(DefaultHashMethod, bytes, salt, DefaultIterations); + /// public byte[] GenerateSalt() => GenerateSalt(DefaultSaltLength); + /// public byte[] GenerateSalt(int length) { byte[] salt = new byte[length]; @@ -109,6 +118,10 @@ namespace Emby.Server.Implementations.Cryptography GC.SuppressFinalize(this); } + /// + /// Releases unmanaged and - optionally - managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool disposing) { if (_disposed) diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index 4e392f6c9..30f29beee 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +13,10 @@ namespace Emby.Server.Implementations.Data { private bool _disposed = false; + /// + /// Initializes a new instance of the class. + /// + /// The ogger. protected BaseSqliteRepository(ILogger logger) { Logger = logger; diff --git a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs index f7743a3c2..2a8f2d6b3 100644 --- a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs +++ b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Threading; using System.Threading.Tasks; diff --git a/Emby.Server.Implementations/Data/ManagedConnection.cs b/Emby.Server.Implementations/Data/ManagedConnection.cs index 4c3424410..5c094ddd2 100644 --- a/Emby.Server.Implementations/Data/ManagedConnection.cs +++ b/Emby.Server.Implementations/Data/ManagedConnection.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Threading; diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 2f6c1288d..d474f1c6b 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index c76ae0cac..c87793072 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index 26ac17bdc..22955850a 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.IO; diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index 26798993b..a042320c9 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.IO; diff --git a/Emby.Server.Implementations/Data/TypeMapper.cs b/Emby.Server.Implementations/Data/TypeMapper.cs index 0e67affbf..7044b1d19 100644 --- a/Emby.Server.Implementations/Data/TypeMapper.cs +++ b/Emby.Server.Implementations/Data/TypeMapper.cs @@ -5,25 +5,22 @@ using System.Linq; namespace Emby.Server.Implementations.Data { /// - /// Class TypeMapper + /// Class TypeMapper. /// public class TypeMapper { /// - /// This holds all the types in the running assemblies so that we can de-serialize properly when we don't have strong types + /// This holds all the types in the running assemblies + /// so that we can de-serialize properly when we don't have strong types. /// private readonly ConcurrentDictionary _typeMap = new ConcurrentDictionary(); - public TypeMapper() - { - } - /// /// Gets the type. /// /// Name of the type. /// Type. - /// + /// typeName is null. public Type GetType(string typeName) { if (string.IsNullOrEmpty(typeName)) diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 7344dc72f..f0d43e665 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Globalization; using System.IO; diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index 36d441851..2393f1f45 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs index 175a8f3ce..bfa49ac5f 100644 --- a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs +++ b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Diagnostics; using System.IO; diff --git a/Emby.Server.Implementations/Diagnostics/ProcessFactory.cs b/Emby.Server.Implementations/Diagnostics/ProcessFactory.cs index 14aadaaae..02ad3c1a8 100644 --- a/Emby.Server.Implementations/Diagnostics/ProcessFactory.cs +++ b/Emby.Server.Implementations/Diagnostics/ProcessFactory.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using MediaBrowser.Model.Diagnostics; namespace Emby.Server.Implementations.Diagnostics diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 6c0e32e05..3d622b3fc 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs index 19ea09359..d69b0909d 100644 --- a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Linq; using System.Threading; diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index a2619367d..e290c62e1 100644 --- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Net; diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 24906220d..5f938e59a 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs index 0186da9e1..dbb3503c4 100644 --- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Linq; using System.Threading; diff --git a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs index 3a7516dca..1ca25ba6f 100644 --- a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs +++ b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; @@ -12,32 +11,19 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.EntryPoints { /// - /// Class RefreshUsersMetadata + /// Class RefreshUsersMetadata. /// public class RefreshUsersMetadata : IScheduledTask, IConfigurableScheduledTask { private readonly ILogger _logger; + /// - /// The _user manager + /// The _user manager. /// private readonly IUserManager _userManager; private IFileSystem _fileSystem; - public string Name => "Refresh Users"; - - public string Key => "RefreshUsers"; - - public string Description => "Refresh user infos"; - - public string Category => "Library"; - - public bool IsHidden => true; - - public bool IsEnabled => true; - - public bool IsLogged => true; - /// /// Initializes a new instance of the class. /// @@ -48,6 +34,28 @@ namespace Emby.Server.Implementations.EntryPoints _fileSystem = fileSystem; } + /// + public string Name => "Refresh Users"; + + /// + public string Key => "RefreshUsers"; + + /// + public string Description => "Refresh user infos"; + + /// + public string Category => "Library"; + + /// + public bool IsHidden => true; + + /// + public bool IsEnabled => true; + + /// + public bool IsLogged => true; + + /// public async Task Execute(CancellationToken cancellationToken, IProgress progress) { foreach (var user in _userManager.Users) @@ -58,9 +66,10 @@ namespace Emby.Server.Implementations.EntryPoints } } + /// public IEnumerable GetDefaultTriggers() { - return new List + return new[] { new TaskTriggerInfo { diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs index 3ff8d9968..9ccbf7535 100644 --- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs @@ -16,33 +16,46 @@ using MediaBrowser.Model.Tasks; namespace Emby.Server.Implementations.EntryPoints { /// - /// Class WebSocketEvents + /// Class WebSocketEvents. /// public class ServerEventNotifier : IServerEntryPoint { /// - /// The _user manager + /// The _user manager. /// private readonly IUserManager _userManager; /// - /// The _installation manager + /// The _installation manager. /// private readonly IInstallationManager _installationManager; /// - /// The _kernel + /// The _kernel. /// private readonly IServerApplicationHost _appHost; /// - /// The _task manager + /// The _task manager. /// private readonly ITaskManager _taskManager; private readonly ISessionManager _sessionManager; - public ServerEventNotifier(IServerApplicationHost appHost, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager, ISessionManager sessionManager) + /// + /// Initializes a new instance of the class. + /// + /// The application host. + /// The user manager. + /// The installation manager. + /// The task manager. + /// The session manager. + public ServerEventNotifier( + IServerApplicationHost appHost, + IUserManager userManager, + IInstallationManager installationManager, + ITaskManager taskManager, + ISessionManager sessionManager) { _userManager = userManager; _installationManager = installationManager; @@ -51,47 +64,48 @@ namespace Emby.Server.Implementations.EntryPoints _sessionManager = sessionManager; } + /// public Task RunAsync() { - _userManager.UserDeleted += userManager_UserDeleted; - _userManager.UserUpdated += userManager_UserUpdated; - _userManager.UserPolicyUpdated += _userManager_UserPolicyUpdated; - _userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated; + _userManager.UserDeleted += OnUserDeleted; + _userManager.UserUpdated += OnUserUpdated; + _userManager.UserPolicyUpdated += OnUserPolicyUpdated; + _userManager.UserConfigurationUpdated += OnUserConfigurationUpdated; - _appHost.HasPendingRestartChanged += kernel_HasPendingRestartChanged; + _appHost.HasPendingRestartChanged += OnHasPendingRestartChanged; - _installationManager.PluginUninstalled += InstallationManager_PluginUninstalled; - _installationManager.PackageInstalling += _installationManager_PackageInstalling; - _installationManager.PackageInstallationCancelled += _installationManager_PackageInstallationCancelled; - _installationManager.PackageInstallationCompleted += _installationManager_PackageInstallationCompleted; - _installationManager.PackageInstallationFailed += _installationManager_PackageInstallationFailed; + _installationManager.PluginUninstalled += OnPluginUninstalled; + _installationManager.PackageInstalling += OnPackageInstalling; + _installationManager.PackageInstallationCancelled += OnPackageInstallationCancelled; + _installationManager.PackageInstallationCompleted += OnPackageInstallationCompleted; + _installationManager.PackageInstallationFailed += OnPackageInstallationFailed; - _taskManager.TaskCompleted += _taskManager_TaskCompleted; + _taskManager.TaskCompleted += OnTaskCompleted; return Task.CompletedTask; } - void _installationManager_PackageInstalling(object sender, InstallationEventArgs e) + private void OnPackageInstalling(object sender, InstallationEventArgs e) { SendMessageToAdminSessions("PackageInstalling", e.InstallationInfo); } - void _installationManager_PackageInstallationCancelled(object sender, InstallationEventArgs e) + private void OnPackageInstallationCancelled(object sender, InstallationEventArgs e) { SendMessageToAdminSessions("PackageInstallationCancelled", e.InstallationInfo); } - void _installationManager_PackageInstallationCompleted(object sender, InstallationEventArgs e) + private void OnPackageInstallationCompleted(object sender, InstallationEventArgs e) { SendMessageToAdminSessions("PackageInstallationCompleted", e.InstallationInfo); } - void _installationManager_PackageInstallationFailed(object sender, InstallationFailedEventArgs e) + private void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e) { SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo); } - void _taskManager_TaskCompleted(object sender, TaskCompletionEventArgs e) + private void OnTaskCompleted(object sender, TaskCompletionEventArgs e) { SendMessageToAdminSessions("ScheduledTaskEnded", e.Result); } @@ -101,7 +115,7 @@ namespace Emby.Server.Implementations.EntryPoints /// /// The sender. /// The e. - void InstallationManager_PluginUninstalled(object sender, GenericEventArgs e) + private void OnPluginUninstalled(object sender, GenericEventArgs e) { SendMessageToAdminSessions("PluginUninstalled", e.Argument.GetPluginInfo()); } @@ -111,7 +125,7 @@ namespace Emby.Server.Implementations.EntryPoints /// /// The source of the event. /// The instance containing the event data. - void kernel_HasPendingRestartChanged(object sender, EventArgs e) + private void OnHasPendingRestartChanged(object sender, EventArgs e) { _sessionManager.SendRestartRequiredNotification(CancellationToken.None); } @@ -121,7 +135,7 @@ namespace Emby.Server.Implementations.EntryPoints /// /// The sender. /// The e. - void userManager_UserUpdated(object sender, GenericEventArgs e) + private void OnUserUpdated(object sender, GenericEventArgs e) { var dto = _userManager.GetUserDto(e.Argument); @@ -133,19 +147,19 @@ namespace Emby.Server.Implementations.EntryPoints /// /// The sender. /// The e. - void userManager_UserDeleted(object sender, GenericEventArgs e) + private void OnUserDeleted(object sender, GenericEventArgs e) { SendMessageToUserSession(e.Argument, "UserDeleted", e.Argument.Id.ToString("N", CultureInfo.InvariantCulture)); } - void _userManager_UserPolicyUpdated(object sender, GenericEventArgs e) + private void OnUserPolicyUpdated(object sender, GenericEventArgs e) { var dto = _userManager.GetUserDto(e.Argument); SendMessageToUserSession(e.Argument, "UserPolicyUpdated", dto); } - void _userManager_UserConfigurationUpdated(object sender, GenericEventArgs e) + private void OnUserConfigurationUpdated(object sender, GenericEventArgs e) { var dto = _userManager.GetUserDto(e.Argument); @@ -168,7 +182,11 @@ namespace Emby.Server.Implementations.EntryPoints { try { - await _sessionManager.SendMessageToUserSessions(new List { user.Id }, name, data, CancellationToken.None); + await _sessionManager.SendMessageToUserSessions( + new List { user.Id }, + name, + data, + CancellationToken.None).ConfigureAwait(false); } catch (Exception) { @@ -176,12 +194,11 @@ namespace Emby.Server.Implementations.EntryPoints } } - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// @@ -192,18 +209,20 @@ namespace Emby.Server.Implementations.EntryPoints { if (dispose) { - _userManager.UserDeleted -= userManager_UserDeleted; - _userManager.UserUpdated -= userManager_UserUpdated; - _userManager.UserPolicyUpdated -= _userManager_UserPolicyUpdated; - _userManager.UserConfigurationUpdated -= _userManager_UserConfigurationUpdated; + _userManager.UserDeleted -= OnUserDeleted; + _userManager.UserUpdated -= OnUserUpdated; + _userManager.UserPolicyUpdated -= OnUserPolicyUpdated; + _userManager.UserConfigurationUpdated -= OnUserConfigurationUpdated; - _installationManager.PluginUninstalled -= InstallationManager_PluginUninstalled; - _installationManager.PackageInstalling -= _installationManager_PackageInstalling; - _installationManager.PackageInstallationCancelled -= _installationManager_PackageInstallationCancelled; - _installationManager.PackageInstallationCompleted -= _installationManager_PackageInstallationCompleted; - _installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed; + _installationManager.PluginUninstalled -= OnPluginUninstalled; + _installationManager.PackageInstalling -= OnPackageInstalling; + _installationManager.PackageInstallationCancelled -= OnPackageInstallationCancelled; + _installationManager.PackageInstallationCompleted -= OnPackageInstallationCompleted; + _installationManager.PackageInstallationFailed -= OnPackageInstallationFailed; - _appHost.HasPendingRestartChanged -= kernel_HasPendingRestartChanged; + _appHost.HasPendingRestartChanged -= OnHasPendingRestartChanged; + + _taskManager.TaskCompleted -= OnTaskCompleted; } } } diff --git a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs index 8be6db87d..9cef77dc8 100644 --- a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs +++ b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs @@ -8,21 +8,28 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.EntryPoints { /// - /// Class StartupWizard + /// Class StartupWizard. /// public class StartupWizard : IServerEntryPoint { /// - /// The _app host + /// The _app host. /// private readonly IServerApplicationHost _appHost; + /// - /// The _user manager + /// The _user manager. /// private readonly ILogger _logger; private IServerConfigurationManager _config; + /// + /// Initializes a new instance of the class. + /// + /// The application host. + /// The logger. + /// The configuration manager. public StartupWizard(IServerApplicationHost appHost, ILogger logger, IServerConfigurationManager config) { _appHost = appHost; @@ -30,9 +37,7 @@ namespace Emby.Server.Implementations.EntryPoints _config = config; } - /// - /// Runs this instance. - /// + /// public Task RunAsync() { if (!_appHost.CanLaunchWebBrowser) @@ -57,9 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints return Task.CompletedTask; } - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { } diff --git a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs index 5b90dc1fb..24ac6d1fd 100644 --- a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -10,30 +10,36 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.EntryPoints { /// - /// Class UdpServerEntryPoint + /// Class UdpServerEntryPoint. /// public class UdpServerEntryPoint : IServerEntryPoint { /// - /// Gets or sets the UDP server. + /// The port of the UDP server. /// - /// The UDP server. - private UdpServer UdpServer { get; set; } + public const int PortNumber = 7359; /// - /// The _logger + /// The _logger. /// private readonly ILogger _logger; private readonly ISocketFactory _socketFactory; private readonly IServerApplicationHost _appHost; private readonly IJsonSerializer _json; - public const int PortNumber = 7359; + /// + /// The UDP server. + /// + private UdpServer _udpServer; /// /// Initializes a new instance of the class. /// - public UdpServerEntryPoint(ILogger logger, IServerApplicationHost appHost, IJsonSerializer json, ISocketFactory socketFactory) + public UdpServerEntryPoint( + ILogger logger, + IServerApplicationHost appHost, + IJsonSerializer json, + ISocketFactory socketFactory) { _logger = logger; _appHost = appHost; @@ -41,9 +47,7 @@ namespace Emby.Server.Implementations.EntryPoints _socketFactory = socketFactory; } - /// - /// Runs this instance. - /// + /// public Task RunAsync() { var udpServer = new UdpServer(_logger, _appHost, _json, _socketFactory); @@ -52,7 +56,7 @@ namespace Emby.Server.Implementations.EntryPoints { udpServer.Start(PortNumber); - UdpServer = udpServer; + _udpServer = udpServer; } catch (Exception ex) { @@ -62,12 +66,11 @@ namespace Emby.Server.Implementations.EntryPoints return Task.CompletedTask; } - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// @@ -78,9 +81,9 @@ namespace Emby.Server.Implementations.EntryPoints { if (dispose) { - if (UdpServer != null) + if (_udpServer != null) { - UdpServer.Dispose(); + _udpServer.Dispose(); } } } diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index bae3422ff..e431da148 100644 --- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 2da0191dd..50233ea48 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -282,6 +282,7 @@ namespace Emby.Server.Implementations.HttpClientManager }; } + /// public Task Post(HttpRequestOptions options) => SendAsync(options, HttpMethod.Post); diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.cs index 2c7e81361..c1c8c3eb3 100644 --- a/Emby.Server.Implementations/HttpServer/FileWriter.cs +++ b/Emby.Server.Implementations/HttpServer/FileWriter.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 6dd016f8a..2aefc9fe5 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index b5cfb6b09..f9eb3a897 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; @@ -5,12 +7,10 @@ using System.IO; using System.IO.Compression; using System.Net; using System.Runtime.Serialization; -using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Xml; using Emby.Server.Implementations.Services; -using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; @@ -24,12 +24,12 @@ using MimeTypes = MediaBrowser.Model.Net.MimeTypes; namespace Emby.Server.Implementations.HttpServer { /// - /// Class HttpResultFactory + /// Class HttpResultFactory. /// public class HttpResultFactory : IHttpResultFactory { /// - /// The _logger + /// The _logger. /// private readonly ILogger _logger; private readonly IFileSystem _fileSystem; diff --git a/Emby.Server.Implementations/HttpServer/IHttpListener.cs b/Emby.Server.Implementations/HttpServer/IHttpListener.cs index 005656d2c..501593725 100644 --- a/Emby.Server.Implementations/HttpServer/IHttpListener.cs +++ b/Emby.Server.Implementations/HttpServer/IHttpListener.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Threading; using System.Threading.Tasks; diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs index 320136d11..8b9028f6b 100644 --- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs index 3e731366e..5e0466629 100644 --- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs +++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs @@ -8,11 +8,17 @@ using Microsoft.Net.Http.Headers; namespace Emby.Server.Implementations.HttpServer { + /// + /// Class ResponseFilter. + /// public class ResponseFilter { - private static readonly CultureInfo _usCulture = CultureInfo.ReadOnly(new CultureInfo("en-US")); private readonly ILogger _logger; + /// + /// Initializes a new instance of the class. + /// + /// The logger. public ResponseFilter(ILogger logger) { _logger = logger; @@ -37,7 +43,7 @@ namespace Emby.Server.Implementations.HttpServer if (!string.IsNullOrEmpty(exception.Message)) { - var error = exception.Message.Replace(Environment.NewLine, " "); + var error = exception.Message.Replace(Environment.NewLine, " ", StringComparison.Ordinal); error = RemoveControlCharacters(error); res.Headers.Add("X-Application-Error-Code", error); @@ -55,7 +61,7 @@ namespace Emby.Server.Implementations.HttpServer if (hasHeaders.Headers.TryGetValue(HeaderNames.ContentLength, out string contentLength) && !string.IsNullOrEmpty(contentLength)) { - var length = long.Parse(contentLength, _usCulture); + var length = long.Parse(contentLength, CultureInfo.InvariantCulture); if (length > 0) { diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index 594f46498..58421aaf1 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Linq; using Emby.Server.Implementations.SocketSharp; diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index 457448604..129faeaab 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Linq; diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs index 81e11d312..166952c64 100644 --- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs index 194d04441..eda236028 100644 --- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs +++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs @@ -10,37 +10,20 @@ using Microsoft.Net.Http.Headers; namespace Emby.Server.Implementations.HttpServer { /// - /// Class StreamWriter + /// Class StreamWriter. /// public class StreamWriter : IAsyncStreamWriter, IHasHeaders { /// - /// Gets or sets the source stream. - /// - /// The source stream. - private Stream SourceStream { get; set; } - - private byte[] SourceBytes { get; set; } - - /// - /// The _options + /// The _options. /// private readonly IDictionary _options = new Dictionary(); - /// - /// Gets the options. - /// - /// The options. - public IDictionary Headers => _options; - - public Action OnComplete { get; set; } - public Action OnError { get; set; } /// /// Initializes a new instance of the class. /// /// The source. /// Type of the content. - /// The logger. public StreamWriter(Stream source, string contentType) { if (string.IsNullOrEmpty(contentType)) @@ -65,6 +48,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// The source. /// Type of the content. + /// The content length. public StreamWriter(byte[] source, string contentType, int contentLength) { if (string.IsNullOrEmpty(contentType)) @@ -78,6 +62,31 @@ namespace Emby.Server.Implementations.HttpServer Headers[HeaderNames.ContentType] = contentType; } + /// + /// Gets or sets the source stream. + /// + /// The source stream. + private Stream SourceStream { get; set; } + + private byte[] SourceBytes { get; set; } + + /// + /// Gets the options. + /// + /// The options. + public IDictionary Headers => _options; + + /// + /// Fires when complete. + /// + public Action OnComplete { get; set; } + + /// + /// Fires when an error occours. + /// + public Action OnError { get; set; } + + /// public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken) { try @@ -98,19 +107,13 @@ namespace Emby.Server.Implementations.HttpServer } catch { - if (OnError != null) - { - OnError(); - } + OnError?.Invoke(); throw; } finally { - if (OnComplete != null) - { - OnComplete(); - } + OnComplete?.Invoke(); } } } diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 54a16040f..5d657b8a7 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -7,7 +7,6 @@ using Emby.Server.Implementations.Net; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Net; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using UtfUnknown; @@ -15,32 +14,74 @@ using UtfUnknown; namespace Emby.Server.Implementations.HttpServer { /// - /// Class WebSocketConnection + /// Class WebSocketConnection. /// public class WebSocketConnection : IWebSocketConnection { - public event EventHandler Closed; - /// - /// The _socket - /// - private readonly IWebSocket _socket; - - /// - /// The _remote end point - /// - public string RemoteEndPoint { get; private set; } - - /// - /// The logger + /// The logger. /// private readonly ILogger _logger; /// - /// The _json serializer + /// The _json serializer. /// private readonly IJsonSerializer _jsonSerializer; + /// + /// The _socket. + /// + private readonly IWebSocket _socket; + + /// + /// Initializes a new instance of the class. + /// + /// The socket. + /// The remote end point. + /// The json serializer. + /// The logger. + /// socket + public WebSocketConnection(IWebSocket socket, string remoteEndPoint, IJsonSerializer jsonSerializer, ILogger logger) + { + if (socket == null) + { + throw new ArgumentNullException(nameof(socket)); + } + + if (string.IsNullOrEmpty(remoteEndPoint)) + { + throw new ArgumentNullException(nameof(remoteEndPoint)); + } + + if (jsonSerializer == null) + { + throw new ArgumentNullException(nameof(jsonSerializer)); + } + + if (logger == null) + { + throw new ArgumentNullException(nameof(logger)); + } + + Id = Guid.NewGuid(); + _jsonSerializer = jsonSerializer; + _socket = socket; + _socket.OnReceiveBytes = OnReceiveInternal; + + RemoteEndPoint = remoteEndPoint; + _logger = logger; + + socket.Closed += OnSocketClosed; + } + + /// + public event EventHandler Closed; + + /// + /// Gets or sets the _remote end point. + /// + public string RemoteEndPoint { get; private set; } + /// /// Gets or sets the receive action. /// @@ -64,6 +105,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// The URL. public string Url { get; set; } + /// /// Gets or sets the query string. /// @@ -71,44 +113,12 @@ namespace Emby.Server.Implementations.HttpServer public IQueryCollection QueryString { get; set; } /// - /// Initializes a new instance of the class. + /// Gets the state. /// - /// The socket. - /// The remote end point. - /// The json serializer. - /// The logger. - /// socket - public WebSocketConnection(IWebSocket socket, string remoteEndPoint, IJsonSerializer jsonSerializer, ILogger logger) - { - if (socket == null) - { - throw new ArgumentNullException(nameof(socket)); - } - if (string.IsNullOrEmpty(remoteEndPoint)) - { - throw new ArgumentNullException(nameof(remoteEndPoint)); - } - if (jsonSerializer == null) - { - throw new ArgumentNullException(nameof(jsonSerializer)); - } - if (logger == null) - { - throw new ArgumentNullException(nameof(logger)); - } + /// The state. + public WebSocketState State => _socket.State; - Id = Guid.NewGuid(); - _jsonSerializer = jsonSerializer; - _socket = socket; - _socket.OnReceiveBytes = OnReceiveInternal; - - RemoteEndPoint = remoteEndPoint; - _logger = logger; - - socket.Closed += socket_Closed; - } - - void socket_Closed(object sender, EventArgs e) + void OnSocketClosed(object sender, EventArgs e) { Closed?.Invoke(this, EventArgs.Empty); } @@ -210,6 +220,7 @@ namespace Emby.Server.Implementations.HttpServer return _socket.SendAsync(buffer, true, cancellationToken); } + /// public Task SendAsync(string text, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(text)) @@ -222,18 +233,11 @@ namespace Emby.Server.Implementations.HttpServer return _socket.SendAsync(text, true, cancellationToken); } - /// - /// Gets the state. - /// - /// The state. - public WebSocketState State => _socket.State; - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs b/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs index 48b34a3a0..3150f3367 100644 --- a/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs +++ b/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + namespace Emby.Server.Implementations.IO { public class ExtendedFileSystemInfo diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 40e8ed5dc..4b5b11f01 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.IO; diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index aeb541c54..b1fb8cc63 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -16,22 +18,22 @@ namespace Emby.Server.Implementations.IO public class LibraryMonitor : ILibraryMonitor { /// - /// The file system watchers + /// The file system watchers. /// private readonly ConcurrentDictionary _fileSystemWatchers = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); /// - /// The affected paths + /// The affected paths. /// private readonly List _activeRefreshers = new List(); /// - /// A dynamic list of paths that should be ignored. Added to during our own file sytem modifications. + /// A dynamic list of paths that should be ignored. Added to during our own file system modifications. /// private readonly ConcurrentDictionary _tempIgnoredPaths = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); /// - /// Any file name ending in any of these will be ignored by the watchers + /// Any file name ending in any of these will be ignored by the watchers. /// private static readonly HashSet _alwaysIgnoreFiles = new HashSet(StringComparer.OrdinalIgnoreCase) { diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index ae8371a32..442fbabd1 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs index 5e5e91bb3..e6696b8c4 100644 --- a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs +++ b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.IO; using MediaBrowser.Model.IO; diff --git a/Emby.Server.Implementations/IO/StreamHelper.cs b/Emby.Server.Implementations/IO/StreamHelper.cs index 7c8c079e3..40b397edc 100644 --- a/Emby.Server.Implementations/IO/StreamHelper.cs +++ b/Emby.Server.Implementations/IO/StreamHelper.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Buffers; using System.IO; diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index 6afcf567a..fd50f156a 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index 8bdb38784..bc1398332 100644 --- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -42,6 +42,10 @@ namespace Emby.Server.Implementations.Library ".grab", }; + /// + /// Initializes a new instance of the class. + /// + /// The library manager. public CoreResolutionIgnoreRule(ILibraryManager libraryManager) { _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs index c043568d5..94f60ea62 100644 --- a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs +++ b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs @@ -10,10 +10,17 @@ using MediaBrowser.Model.Cryptography; namespace Emby.Server.Implementations.Library { + /// + /// The default authentication provider. + /// public class DefaultAuthenticationProvider : IAuthenticationProvider, IRequiresResolvedUser { private readonly ICryptoProvider _cryptographyProvider; + /// + /// Initializes a new instance of the class. + /// + /// The cryptography provider. public DefaultAuthenticationProvider(ICryptoProvider cryptographyProvider) { _cryptographyProvider = cryptographyProvider; @@ -38,12 +45,13 @@ namespace Emby.Server.Implementations.Library // This is the version that we need to use for local users. Because reasons. public Task Authenticate(string username, string password, User resolvedUser) { - bool success = false; if (resolvedUser == null) { throw new ArgumentNullException(nameof(resolvedUser)); } + bool success = false; + // As long as jellyfin supports passwordless users, we need this little block here to accommodate if (!HasPassword(resolvedUser) && string.IsNullOrEmpty(password)) { diff --git a/Emby.Server.Implementations/Library/DefaultPasswordResetProvider.cs b/Emby.Server.Implementations/Library/DefaultPasswordResetProvider.cs index fa6bbcf91..6c6fbd86f 100644 --- a/Emby.Server.Implementations/Library/DefaultPasswordResetProvider.cs +++ b/Emby.Server.Implementations/Library/DefaultPasswordResetProvider.cs @@ -12,6 +12,9 @@ using MediaBrowser.Model.Users; namespace Emby.Server.Implementations.Library { + /// + /// The default password reset provider. + /// public class DefaultPasswordResetProvider : IPasswordResetProvider { private const string BaseResetFileName = "passwordreset"; @@ -22,6 +25,12 @@ namespace Emby.Server.Implementations.Library private readonly string _passwordResetFileBase; private readonly string _passwordResetFileBaseDir; + /// + /// Initializes a new instance of the class. + /// + /// The configuration manager. + /// The JSON serializer. + /// The user manager. public DefaultPasswordResetProvider( IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, @@ -56,8 +65,8 @@ namespace Emby.Server.Implementations.Library File.Delete(resetfile); } else if (string.Equals( - spr.Pin.Replace("-", string.Empty), - pin.Replace("-", string.Empty), + spr.Pin.Replace("-", string.Empty, StringComparison.Ordinal), + pin.Replace("-", string.Empty, StringComparison.Ordinal), StringComparison.InvariantCultureIgnoreCase)) { var resetUser = _userManager.GetUserByName(spr.UserName); diff --git a/Emby.Server.Implementations/Library/ExclusiveLiveStream.cs b/Emby.Server.Implementations/Library/ExclusiveLiveStream.cs index a3c879f12..9a7186898 100644 --- a/Emby.Server.Implementations/Library/ExclusiveLiveStream.cs +++ b/Emby.Server.Implementations/Library/ExclusiveLiveStream.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Globalization; using System.Threading; diff --git a/Emby.Server.Implementations/Library/InvalidAuthProvider.cs b/Emby.Server.Implementations/Library/InvalidAuthProvider.cs index 7913df5e4..dc61aacd7 100644 --- a/Emby.Server.Implementations/Library/InvalidAuthProvider.cs +++ b/Emby.Server.Implementations/Library/InvalidAuthProvider.cs @@ -4,37 +4,48 @@ using MediaBrowser.Controller.Entities; namespace Emby.Server.Implementations.Library { + /// + /// An invalid authentication provider. + /// public class InvalidAuthProvider : IAuthenticationProvider { + /// public string Name => "InvalidOrMissingAuthenticationProvider"; + /// public bool IsEnabled => true; + /// public Task Authenticate(string username, string password) { throw new AuthenticationException("User Account cannot login with this provider. The Normal provider for this user cannot be found"); } + /// public bool HasPassword(User user) { return true; } + /// public Task ChangePassword(User user, string newPassword) { return Task.CompletedTask; } + /// public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash) { // Nothing here } + /// public string GetPasswordHash(User user) { return string.Empty; } + /// public string GetEasyPasswordHash(User user) { return string.Empty; diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 528636ecd..4de06f84a 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Concurrent; using System.Collections.Generic; diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs index 33e6f2434..ed7d8aa40 100644 --- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index 7a26e0c37..22193c997 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Globalization; diff --git a/Emby.Server.Implementations/Library/MediaStreamSelector.cs b/Emby.Server.Implementations/Library/MediaStreamSelector.cs index 0a6c8845d..6b9f4d052 100644 --- a/Emby.Server.Implementations/Library/MediaStreamSelector.cs +++ b/Emby.Server.Implementations/Library/MediaStreamSelector.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Linq; diff --git a/Emby.Server.Implementations/Library/MusicManager.cs b/Emby.Server.Implementations/Library/MusicManager.cs index 10602fea7..72e120b25 100644 --- a/Emby.Server.Implementations/Library/MusicManager.cs +++ b/Emby.Server.Implementations/Library/MusicManager.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.Linq; diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs index d3a81f622..4fdf73b77 100644 --- a/Emby.Server.Implementations/Library/PathExtensions.cs +++ b/Emby.Server.Implementations/Library/PathExtensions.cs @@ -3,6 +3,9 @@ using System.Text.RegularExpressions; namespace Emby.Server.Implementations.Library { + /// + /// Class providing extension methods for working with paths. + /// public static class PathExtensions { /// @@ -32,6 +35,7 @@ namespace Emby.Server.Implementations.Library int end = str.IndexOf(']', start); return str.Substring(start, end - start); } + // for imdbid we also accept pattern matching if (string.Equals(attrib, "imdbid", StringComparison.OrdinalIgnoreCase)) { diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index e39192d28..9d4bd9e59 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; using System.IO; @@ -13,7 +15,7 @@ using MediaBrowser.Model.IO; namespace Emby.Server.Implementations.Library.Resolvers.Audio { /// - /// Class AudioResolver + /// Class AudioResolver. /// public class AudioResolver : ItemResolver, IMultiItemResolver { diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 3ce1da81a..4a2d210d5 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -13,7 +13,7 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Resolvers.Audio { /// - /// Class MusicAlbumResolver + /// Class MusicAlbumResolver. /// public class MusicAlbumResolver : ItemResolver { @@ -21,6 +21,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio private readonly IFileSystem _fileSystem; private readonly ILibraryManager _libraryManager; + /// + /// Initializes a new instance of the class. + /// + /// The logger. + /// The file system. + /// The library manager. public MusicAlbumResolver(ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager) { _logger = logger; @@ -50,16 +56,25 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio return null; } - if (!args.IsDirectory) return null; + if (!args.IsDirectory) + { + return null; + } // Avoid mis-identifying top folders - if (args.HasParent()) return null; - if (args.Parent.IsRoot) return null; + if (args.HasParent()) + { + return null; + } + + if (args.Parent.IsRoot) + { + return null; + } return IsMusicAlbum(args) ? new MusicAlbum() : null; } - /// /// Determine if the supplied file data points to a music album /// @@ -78,8 +93,11 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio // Args points to an album if parent is an Artist folder or it directly contains music if (args.IsDirectory) { - //if (args.Parent is MusicArtist) return true; //saves us from testing children twice - if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, args.GetLibraryOptions(), _libraryManager)) return true; + // if (args.Parent is MusicArtist) return true; //saves us from testing children twice + if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, args.GetLibraryOptions(), _libraryManager)) + { + return true; + } } return false; @@ -88,7 +106,8 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio /// /// Determine if the supplied list contains what we should consider music /// - private bool ContainsMusic(IEnumerable list, + private bool ContainsMusic( + IEnumerable list, bool allowSubfolders, IDirectoryService directoryService, ILogger logger, diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs index 74e9b8304..ee7e84929 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs @@ -11,7 +11,7 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Resolvers.Audio { /// - /// Class MusicArtistResolver + /// Class MusicArtistResolver. /// public class MusicArtistResolver : ItemResolver { @@ -20,6 +20,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio private readonly ILibraryManager _libraryManager; private readonly IServerConfigurationManager _config; + /// + /// Initializes a new instance of the class. + /// + /// The logger. + /// The file system. + /// The library manager. + /// The configuration manager. public MusicArtistResolver(ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager, IServerConfigurationManager config) { _logger = logger; @@ -41,7 +48,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio /// MusicArtist. protected override MusicArtist Resolve(ItemResolveArgs args) { - if (!args.IsDirectory) return null; + if (!args.IsDirectory) + { + return null; + } // Don't allow nested artists if (args.HasParent() || args.HasParent()) @@ -79,6 +89,5 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio // If we contain an album assume we are an artist folder return args.FileSystemChildren.Where(i => i.IsDirectory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService, args.GetLibraryOptions())) ? new MusicArtist() : null; } - } } diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index 541b13cbe..c4bb861b8 100644 --- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.IO; using System.Linq; @@ -10,7 +12,7 @@ using MediaBrowser.Model.Entities; namespace Emby.Server.Implementations.Library.Resolvers { /// - /// Resolves a Path into a Video or Video subclass + /// Resolves a Path into a Video or Video subclass. /// /// public abstract class BaseVideoResolver : MediaBrowser.Controller.Resolvers.ItemResolver diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs index f22554ee5..0b93ebeb8 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS1591 + using System; using System.IO; using System.Linq; @@ -7,18 +9,10 @@ using MediaBrowser.Model.Entities; namespace Emby.Server.Implementations.Library.Resolvers.Books { - /// - /// - /// public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver { private readonly string[] _validExtensions = { ".pdf", ".epub", ".mobi", ".cbr", ".cbz", ".azw3" }; - /// - /// - /// - /// - /// protected override Book Resolve(ItemResolveArgs args) { var collectionType = args.GetCollectionType(); @@ -47,11 +41,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books return null; } - /// - /// - /// - /// - /// private Book GetBook(ItemResolveArgs args) { var bookFiles = args.FileSystemChildren.Where(f => diff --git a/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs index e48b6c967..7dbce7a6e 100644 --- a/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs @@ -5,7 +5,7 @@ using MediaBrowser.Controller.Resolvers; namespace Emby.Server.Implementations.Library.Resolvers { /// - /// Class FolderResolver + /// Class FolderResolver. /// public class FolderResolver : FolderResolver { @@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Library.Resolvers } /// - /// Class FolderResolver + /// Class FolderResolver. /// /// The type of the T item type. public abstract class FolderResolver : ItemResolver diff --git a/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs index a6db40714..32ccc7fdd 100644 --- a/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs @@ -5,7 +5,7 @@ using MediaBrowser.Controller.Resolvers; namespace Emby.Server.Implementations.Library.Resolvers { /// - /// Class ItemResolver + /// Class ItemResolver. /// /// public abstract class ItemResolver : IItemResolver diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs index 922bd4bbb..e4bc4a469 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs @@ -4,12 +4,11 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.Library.Resolvers.Movies { /// - /// Class BoxSetResolver + /// Class BoxSetResolver. /// public class BoxSetResolver : FolderResolver { @@ -63,7 +62,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies /// The item. private static void SetProviderIdFromPath(BaseItem item) { - //we need to only look at the name of this actual item (not parents) + // we need to only look at the name of this actual item (not parents) var justName = Path.GetFileName(item.Path); var id = justName.GetAttributeValue("tmdbid"); diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 1b63b00a3..6c7690055 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -17,7 +17,7 @@ using MediaBrowser.Model.IO; namespace Emby.Server.Implementations.Library.Resolvers.Movies { /// - /// Class MovieResolver + /// Class MovieResolver. /// public class MovieResolver : BaseVideoResolver /// The library manager. + /// The logger. + /// The item repository. public ArtistsPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) { _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs index d06cda177..dbadaeefb 100644 --- a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -12,17 +12,17 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { /// - /// Class ArtistsValidator + /// Class ArtistsValidator. /// public class ArtistsValidator { /// - /// The _library manager + /// The _library manager. /// private readonly ILibraryManager _libraryManager; /// - /// The _logger + /// The _logger. /// private readonly ILogger _logger; private readonly IItemRepository _itemRepo; diff --git a/Emby.Server.Implementations/Library/Validators/GenresPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/GenresPostScanTask.cs index 3bc5c2fb2..06d1dd89d 100644 --- a/Emby.Server.Implementations/Library/Validators/GenresPostScanTask.cs +++ b/Emby.Server.Implementations/Library/Validators/GenresPostScanTask.cs @@ -7,6 +7,9 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { + /// + /// Class GenresPostScanTask. + /// public class GenresPostScanTask : ILibraryPostScanTask { /// diff --git a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs index f8459c61f..6478f1873 100644 --- a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs @@ -7,19 +7,28 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { - class GenresValidator + /// + /// Class GenresValidator. + /// + public class GenresValidator { /// - /// The _library manager + /// The _library manager. /// private readonly ILibraryManager _libraryManager; private readonly IItemRepository _itemRepo; /// - /// The _logger + /// The _logger. /// private readonly ILogger _logger; + /// + /// Initializes a new instance of the class. + /// + /// The library manager. + /// The logger. + /// The item repository. public GenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) { _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs index 9ac4bf761..1b5c83f1e 100644 --- a/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs +++ b/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs @@ -8,12 +8,12 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { /// - /// Class MusicGenresPostScanTask + /// Class MusicGenresPostScanTask. /// public class MusicGenresPostScanTask : ILibraryPostScanTask { /// - /// The _library manager + /// The _library manager. /// private readonly ILibraryManager _libraryManager; private readonly ILogger _logger; diff --git a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs index 710e5d043..23a28e936 100644 --- a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -7,19 +7,28 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { - class MusicGenresValidator + /// + /// Class MusicGenresValidator. + /// + public class MusicGenresValidator { /// - /// The _library manager + /// The _library manager. /// private readonly ILibraryManager _libraryManager; /// - /// The _logger + /// The _logger. /// private readonly ILogger _logger; private readonly IItemRepository _itemRepo; + /// + /// Initializes a new instance of the class. + /// + /// The library manager. + /// The logger. + /// The item repository. public MusicGenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) { _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs b/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs index 137a010ec..8275c873a 100644 --- a/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -32,6 +32,7 @@ namespace Emby.Server.Implementations.Library.Validators /// /// The library manager. /// The logger. + /// The file system. public PeopleValidator(ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem) { _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Library/Validators/StudiosPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/StudiosPostScanTask.cs index 2efae0fe4..00899c336 100644 --- a/Emby.Server.Implementations/Library/Validators/StudiosPostScanTask.cs +++ b/Emby.Server.Implementations/Library/Validators/StudiosPostScanTask.cs @@ -8,12 +8,12 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { /// - /// Class MusicGenresPostScanTask + /// Class MusicGenresPostScanTask. /// public class StudiosPostScanTask : ILibraryPostScanTask { /// - /// The _library manager + /// The _library manager. /// private readonly ILibraryManager _libraryManager; @@ -25,7 +25,7 @@ namespace Emby.Server.Implementations.Library.Validators /// /// The library manager. /// The logger. - /// Th item repository. + /// The item repository. public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) { _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs index 93ded9e7b..887eef5c3 100644 --- a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -9,19 +9,29 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Library.Validators { - class StudiosValidator + /// + /// Class StudiosValidator. + /// + public class StudiosValidator { /// - /// The _library manager + /// The _library manager. /// private readonly ILibraryManager _libraryManager; private readonly IItemRepository _itemRepo; + /// - /// The _logger + /// The _logger. /// private readonly ILogger _logger; + /// + /// Initializes a new instance of the class. + /// + /// The library manager. + /// The logger. + /// The item repository. public StudiosValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo) { _libraryManager = libraryManager; From 89605d4fb10d008970490c266c3f3256ce7d8db0 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Wed, 4 Dec 2019 18:46:19 +1030 Subject: [PATCH 04/53] Fix VAAPI encoding on 10-bit hevc. Update QSV encoding and scaling to take advantage of scale_qsv and overlay_qsv --- .../Playback/Hls/DynamicHlsService.cs | 7 +- .../MediaEncoding/EncodingHelper.cs | 97 ++++++++++++++----- 2 files changed, 77 insertions(+), 27 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 9ecb5fe8c..78de98198 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -945,7 +945,12 @@ namespace MediaBrowser.Api.Playback.Hls var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; - args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultEncoderPreset()) + keyFrameArg; + args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultEncoderPreset()); + + // Unable to force key frames to h264_qsv transcode + if (codec != "h264_qsv") { + args += " " + keyFrameArg; + } //args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0"; diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 0664bdd98..0859ee926 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -467,6 +467,25 @@ namespace MediaBrowser.Controller.MediaEncoding .Append(' '); } + if (state.IsVideoRequest + && string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) + { + var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); + var outputVideoCodec = GetVideoEncoder(state, encodingOptions); + + if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) + { + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + { + arg.Append("-hwaccel qsv "); + } else { + arg.Append("-init_hw_device qsv=hw -filter_hw_device hw "); + } + } + + arg.Append(videoDecoder + " "); + } + arg.Append("-i ") .Append(GetInputPathArgument(state)); @@ -496,6 +515,7 @@ namespace MediaBrowser.Controller.MediaEncoding } } + arg.Append(" -i \"").Append(subtitlePath).Append('\"'); } @@ -1536,13 +1556,11 @@ namespace MediaBrowser.Controller.MediaEncoding { outputSizeParam = "," + outputSizeParam.Substring(index); } - } - else - { + } else { var index = outputSizeParam.IndexOf("scale", StringComparison.OrdinalIgnoreCase); if (index != -1) { - outputSizeParam = "," + outputSizeParam.Substring(index); + outputSizeParam = "," + outputSizeParam.Substring(index); } } } @@ -1550,7 +1568,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && outputSizeParam.Length == 0) { - outputSizeParam = ",format=nv12|vaapi,hwupload"; + outputSizeParam = ",format=nv12|vaapi,hwupload"; // Add parameters to use VAAPI with burn-in subttiles (GH issue #642) if (state.SubtitleStream != null @@ -1570,7 +1588,12 @@ namespace MediaBrowser.Controller.MediaEncoding state.VideoStream.Width.Value, state.VideoStream.Height.Value); - videoSizeParam += ":force_original_aspect_ratio=decrease"; + if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) + { + videoSizeParam += ",hwupload=extra_hw_frames=64"; + } else { + videoSizeParam += ":force_original_aspect_ratio=decrease"; + } } var mapPrefix = state.SubtitleStream.IsExternal ? @@ -1581,11 +1604,25 @@ namespace MediaBrowser.Controller.MediaEncoding ? 0 : state.SubtitleStream.Index; + var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); + + var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\""; + + if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) + { + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + { + retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; + } else { + retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; + } + } + return string.Format( - CultureInfo.InvariantCulture, - " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"", + CultureInfo.InvariantCulture, + retStr, mapPrefix, - subtitleStreamIndex, + subtitleStreamIndex, state.VideoStream.Index, outputSizeParam, videoSizeParam); @@ -1647,18 +1684,16 @@ namespace MediaBrowser.Controller.MediaEncoding requestedMaxWidth, requestedMaxHeight); - if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) + if ((string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) || string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase)) && width.HasValue && height.HasValue) { - // Work around vaapi's reduced scaling features - var scaler = "scale_vaapi"; - // Given the input dimensions (inputWidth, inputHeight), determine the output dimensions // (outputWidth, outputHeight). The user may request precise output dimensions or maximum // output dimensions. Output dimensions are guaranteed to be even. var outputWidth = width.Value; var outputHeight = height.Value; + var vaapi_or_qsv = string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) ? "qsv" : "vaapi"; if (!videoWidth.HasValue || outputWidth != videoWidth.Value @@ -1668,11 +1703,13 @@ namespace MediaBrowser.Controller.MediaEncoding filters.Add( string.Format( CultureInfo.InvariantCulture, - "{0}=w={1}:h={2}", - scaler, + "scale_{0}=w={1}:h={2}:format=nv12", + vaapi_or_qsv, outputWidth, outputHeight)); - } + } else { + filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv)); + } } else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1 && width.HasValue @@ -1911,9 +1948,25 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { filters.Add("format=nv12|vaapi"); - filters.Add("hwupload"); + filters.Add("hwupload"); } + var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); + + // If we are software decoding, and hardware encoding + if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) + && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv"))) + { + filters.Add("format=nv12|qsv"); + filters.Add("hwupload=extra_hw_frames=64"); + } + + var inputWidth = videoStream?.Width; + var inputHeight = videoStream?.Height; + var threeDFormat = state.MediaSource.Video3DFormat; + + filters.AddRange(GetScalingFilters(inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight)); + if (state.DeInterlace("h264", true) && string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { @@ -1936,13 +1989,6 @@ namespace MediaBrowser.Controller.MediaEncoding } } - var inputWidth = videoStream?.Width; - var inputHeight = videoStream?.Height; - var threeDFormat = state.MediaSource.Video3DFormat; - - var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); - - filters.AddRange(GetScalingFilters(inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight)); var output = string.Empty; @@ -2134,10 +2180,9 @@ namespace MediaBrowser.Controller.MediaEncoding } var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); + if (!string.IsNullOrEmpty(videoDecoder)) { - inputModifier += " " + videoDecoder; - if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1) { var videoStream = state.VideoStream; From 78a161138fbcf087cf0130733647cfc541c1da59 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Thu, 5 Dec 2019 18:07:46 +1030 Subject: [PATCH 05/53] Fix formatting stuffed up by previous commit --- .../MediaEncoding/EncodingHelper.cs | 91 ++++++++++--------- 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 0859ee926..b32a3108d 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -467,24 +467,26 @@ namespace MediaBrowser.Controller.MediaEncoding .Append(' '); } - if (state.IsVideoRequest - && string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) - { - var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); - var outputVideoCodec = GetVideoEncoder(state, encodingOptions); + if (state.IsVideoRequest + && string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) + { + var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); + var outputVideoCodec = GetVideoEncoder(state, encodingOptions); - if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) - { - if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) - { - arg.Append("-hwaccel qsv "); - } else { - arg.Append("-init_hw_device qsv=hw -filter_hw_device hw "); - } - } + if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) + { + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + { + arg.Append("-hwaccel qsv "); + } + else + { + arg.Append("-init_hw_device qsv=hw -filter_hw_device hw "); + } + } - arg.Append(videoDecoder + " "); - } + arg.Append(videoDecoder + " "); + } arg.Append("-i ") .Append(GetInputPathArgument(state)); @@ -1568,7 +1570,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && outputSizeParam.Length == 0) { - outputSizeParam = ",format=nv12|vaapi,hwupload"; + outputSizeParam = ",format=nv12|vaapi,hwupload"; // Add parameters to use VAAPI with burn-in subttiles (GH issue #642) if (state.SubtitleStream != null @@ -1588,12 +1590,14 @@ namespace MediaBrowser.Controller.MediaEncoding state.VideoStream.Width.Value, state.VideoStream.Height.Value); - if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) - { - videoSizeParam += ",hwupload=extra_hw_frames=64"; - } else { - videoSizeParam += ":force_original_aspect_ratio=decrease"; - } + if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) + { + videoSizeParam += ",hwupload=extra_hw_frames=64"; + } + else + { + videoSizeParam += ":force_original_aspect_ratio=decrease"; + } } var mapPrefix = state.SubtitleStream.IsExternal ? @@ -1604,25 +1608,26 @@ namespace MediaBrowser.Controller.MediaEncoding ? 0 : state.SubtitleStream.Index; - var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); - - var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\""; + var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); + var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\""; if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) - { - if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) - { - retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; - } else { - retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; - } + { + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + { + retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; + } + else + { + retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; + } } return string.Format( - CultureInfo.InvariantCulture, - retStr, + CultureInfo.InvariantCulture, + retStr, mapPrefix, - subtitleStreamIndex, + subtitleStreamIndex, state.VideoStream.Index, outputSizeParam, videoSizeParam); @@ -1693,7 +1698,7 @@ namespace MediaBrowser.Controller.MediaEncoding // output dimensions. Output dimensions are guaranteed to be even. var outputWidth = width.Value; var outputHeight = height.Value; - var vaapi_or_qsv = string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) ? "qsv" : "vaapi"; + var vaapi_or_qsv = string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) ? "qsv" : "vaapi"; if (!videoWidth.HasValue || outputWidth != videoWidth.Value @@ -1707,9 +1712,11 @@ namespace MediaBrowser.Controller.MediaEncoding vaapi_or_qsv, outputWidth, outputHeight)); - } else { - filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv)); - } + } + else + { + filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv)); + } } else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1 && width.HasValue @@ -1955,10 +1962,10 @@ namespace MediaBrowser.Controller.MediaEncoding // If we are software decoding, and hardware encoding if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) - && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv"))) + && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv"))) { filters.Add("format=nv12|qsv"); - filters.Add("hwupload=extra_hw_frames=64"); + filters.Add("hwupload=extra_hw_frames=64"); } var inputWidth = videoStream?.Width; From 3d8f3da5d6df7b09c61eed68d31eb6aa3bdb6da4 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Thu, 5 Dec 2019 18:39:09 +1030 Subject: [PATCH 06/53] Add comments --- .../MediaEncoding/EncodingHelper.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index b32a3108d..aefa5d6c6 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1582,6 +1582,7 @@ namespace MediaBrowser.Controller.MediaEncoding var videoSizeParam = string.Empty; + // Setup subtitle scaling if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue) { videoSizeParam = string.Format( @@ -1592,6 +1593,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) { + //For QSV, feed it into hardware encoder videoSizeParam += ",hwupload=extra_hw_frames=64"; } else @@ -1609,10 +1611,17 @@ namespace MediaBrowser.Controller.MediaEncoding : state.SubtitleStream.Index; var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); + + // Setup default filtergraph utilizing FFMpeg overlay() and FFMpeg scale() (see the return of this function for index reference) var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\""; if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) { + /* + QSV in FFMpeg can now setup hardware overlay for transcodes. + For software decoding and hardware encoding option, frames must be hwuploaded into hardware + with fixed frame size. + */ if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) { retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; @@ -1705,11 +1714,12 @@ namespace MediaBrowser.Controller.MediaEncoding || !videoHeight.HasValue || outputHeight != videoHeight.Value) { + //Force nv12 pixel format to enable 10-bit to 8-bit colour conversion. filters.Add( string.Format( CultureInfo.InvariantCulture, "scale_{0}=w={1}:h={2}:format=nv12", - vaapi_or_qsv, + vaapi_or_qsv, outputWidth, outputHeight)); } From 70530e1f1415522a601709e11a31f8eb6a3f0a64 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Thu, 5 Dec 2019 19:20:47 +1030 Subject: [PATCH 07/53] Fix formatting (2) --- .../Playback/Hls/DynamicHlsService.cs | 8 +- .../MediaEncoding/EncodingHelper.cs | 86 ++++++++++--------- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 78de98198..0918d57af 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -947,10 +947,10 @@ namespace MediaBrowser.Api.Playback.Hls args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultEncoderPreset()); - // Unable to force key frames to h264_qsv transcode - if (codec != "h264_qsv") { - args += " " + keyFrameArg; - } + // Unable to force key frames to h264_qsv transcode + if (codec != "h264_qsv") { + args += " " + keyFrameArg; + } //args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0"; diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index aefa5d6c6..cd2c2ff2e 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -467,26 +467,26 @@ namespace MediaBrowser.Controller.MediaEncoding .Append(' '); } - if (state.IsVideoRequest - && string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) - { - var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); - var outputVideoCodec = GetVideoEncoder(state, encodingOptions); + if (state.IsVideoRequest + && string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) + { + var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); + var outputVideoCodec = GetVideoEncoder(state, encodingOptions); - if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) - { - if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) - { - arg.Append("-hwaccel qsv "); - } - else - { - arg.Append("-init_hw_device qsv=hw -filter_hw_device hw "); - } - } + if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) + { + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + { + arg.Append("-hwaccel qsv "); + } + else + { + arg.Append("-init_hw_device qsv=hw -filter_hw_device hw "); + } + } - arg.Append(videoDecoder + " "); - } + arg.Append(videoDecoder + " "); + } arg.Append("-i ") .Append(GetInputPathArgument(state)); @@ -1558,11 +1558,13 @@ namespace MediaBrowser.Controller.MediaEncoding { outputSizeParam = "," + outputSizeParam.Substring(index); } - } else { + } + else + { var index = outputSizeParam.IndexOf("scale", StringComparison.OrdinalIgnoreCase); if (index != -1) { - outputSizeParam = "," + outputSizeParam.Substring(index); + outputSizeParam = "," + outputSizeParam.Substring(index); } } } @@ -1595,11 +1597,11 @@ namespace MediaBrowser.Controller.MediaEncoding { //For QSV, feed it into hardware encoder videoSizeParam += ",hwupload=extra_hw_frames=64"; - } - else - { - videoSizeParam += ":force_original_aspect_ratio=decrease"; - } + } + else + { + videoSizeParam += ":force_original_aspect_ratio=decrease"; + } } var mapPrefix = state.SubtitleStream.IsExternal ? @@ -1616,27 +1618,27 @@ namespace MediaBrowser.Controller.MediaEncoding var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\""; if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) - { + { /* QSV in FFMpeg can now setup hardware overlay for transcodes. For software decoding and hardware encoding option, frames must be hwuploaded into hardware with fixed frame size. */ - if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) - { - retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; - } - else - { - retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; - } + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + { + retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; + } + else + { + retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; + } } return string.Format( CultureInfo.InvariantCulture, - retStr, + retStr, mapPrefix, - subtitleStreamIndex, + subtitleStreamIndex, state.VideoStream.Index, outputSizeParam, videoSizeParam); @@ -1725,8 +1727,8 @@ namespace MediaBrowser.Controller.MediaEncoding } else { - filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv)); - } + filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv)); + } } else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1 && width.HasValue @@ -1965,17 +1967,17 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { filters.Add("format=nv12|vaapi"); - filters.Add("hwupload"); + filters.Add("hwupload"); } var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); - // If we are software decoding, and hardware encoding + // If we are software decoding, and hardware encoding if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) - && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv"))) + && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv"))) { filters.Add("format=nv12|qsv"); - filters.Add("hwupload=extra_hw_frames=64"); + filters.Add("hwupload=extra_hw_frames=64"); } var inputWidth = videoStream?.Width; From a6f883345f1941bf99db1667e84c1caf0b370479 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 5 Dec 2019 17:44:46 +0100 Subject: [PATCH 08/53] Reduce #lines --- Emby.Dlna/Api/DlnaServerService.cs | 8 ++------ MediaBrowser.Api/BaseApiService.cs | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index f64c89389..a451bbcf9 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -216,14 +216,10 @@ namespace Emby.Dlna.Api protected internal ReadOnlySpan GetPathValue(int index) { static void ThrowIndexOutOfRangeException() - { - throw new IndexOutOfRangeException("Path doesn't contain enough segments."); - } + => throw new IndexOutOfRangeException("Path doesn't contain enough segments."); static void ThrowInvalidDataException() - { - throw new InvalidDataException("Path doesn't start with the base url."); - } + => throw new InvalidDataException("Path doesn't start with the base url."); ReadOnlySpan path = Request.PathInfo; diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 41ee314df..2b994d279 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -317,14 +317,10 @@ namespace MediaBrowser.Api protected internal ReadOnlySpan GetPathValue(int index) { static void ThrowIndexOutOfRangeException() - { - throw new IndexOutOfRangeException("Path doesn't contain enough segments."); - } + => throw new IndexOutOfRangeException("Path doesn't contain enough segments."); static void ThrowInvalidDataException() - { - throw new InvalidDataException("Path doesn't start with the base url."); - } + => throw new InvalidDataException("Path doesn't start with the base url."); ReadOnlySpan path = Request.PathInfo; From 8368815788805c610f3a88be405319ae57cb87d1 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 05:03:46 +1030 Subject: [PATCH 09/53] Remove trailing spaces --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index cd2c2ff2e..5a8366143 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1558,8 +1558,8 @@ namespace MediaBrowser.Controller.MediaEncoding { outputSizeParam = "," + outputSizeParam.Substring(index); } - } - else + } + else { var index = outputSizeParam.IndexOf("scale", StringComparison.OrdinalIgnoreCase); if (index != -1) From 7d2bfabb32a5876c977a2a9e4d4e196ee6ca73b2 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 05:12:16 +1030 Subject: [PATCH 10/53] Force original aspect ratio can be used for QSV subtitle scaling --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 5a8366143..ad5050471 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1593,14 +1593,12 @@ namespace MediaBrowser.Controller.MediaEncoding state.VideoStream.Width.Value, state.VideoStream.Height.Value); + videoSizeParam += ":force_original_aspect_ratio=decrease"; + + //For QSV, feed it into hardware encoder if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) { - //For QSV, feed it into hardware encoder videoSizeParam += ",hwupload=extra_hw_frames=64"; - } - else - { - videoSizeParam += ":force_original_aspect_ratio=decrease"; } } From 9ee0804407d2a3cbcae913386f8799d938f6b7ed Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 05:52:40 +1030 Subject: [PATCH 11/53] Move scaling filters and definitions before deinterlacing --- .../MediaEncoding/EncodingHelper.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index ad5050471..480f33e43 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1978,12 +1978,6 @@ namespace MediaBrowser.Controller.MediaEncoding filters.Add("hwupload=extra_hw_frames=64"); } - var inputWidth = videoStream?.Width; - var inputHeight = videoStream?.Height; - var threeDFormat = state.MediaSource.Video3DFormat; - - filters.AddRange(GetScalingFilters(inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight)); - if (state.DeInterlace("h264", true) && string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { @@ -2006,6 +2000,11 @@ namespace MediaBrowser.Controller.MediaEncoding } } + var inputWidth = videoStream?.Width; + var inputHeight = videoStream?.Height; + var threeDFormat = state.MediaSource.Video3DFormat; + + filters.AddRange(GetScalingFilters(inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight)); var output = string.Empty; From a9766992b7893c134c8227a134947ab2e48db0b8 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 06:08:45 +1030 Subject: [PATCH 12/53] Do not force original aspect ratio to decrease, it causes bitmap subtitles to be off-centre --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 480f33e43..d3cef23bd 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1593,9 +1593,7 @@ namespace MediaBrowser.Controller.MediaEncoding state.VideoStream.Width.Value, state.VideoStream.Height.Value); - videoSizeParam += ":force_original_aspect_ratio=decrease"; - - //For QSV, feed it into hardware encoder + //For QSV, feed it into hardware encoder now if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) { videoSizeParam += ",hwupload=extra_hw_frames=64"; From 535390bb6408bc158ea9de99ef6bf0699ffee072 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 06:30:09 +1030 Subject: [PATCH 13/53] QSV can hardware deinterlace too now --- .../MediaEncoding/EncodingHelper.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index d3cef23bd..0b6c2a2d1 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1976,10 +1976,16 @@ namespace MediaBrowser.Controller.MediaEncoding filters.Add("hwupload=extra_hw_frames=64"); } - if (state.DeInterlace("h264", true) - && string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) + if (state.DeInterlace("h264", true)) { - filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_vaapi")); + if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) + { + filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_vaapi")); + } + else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) + { + filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_qsv")); + } } if ((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true)) From 3f43aef9974b01f88d795641fb947758cd1cc95e Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 16:04:29 +1030 Subject: [PATCH 14/53] Add back code removed during testing/debugging --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 0b6c2a2d1..550ad78b8 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -2203,6 +2203,8 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(videoDecoder)) { + inputModifier += " " + videoDecoder; + if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1) { var videoStream = state.VideoStream; From 75426d00042f1140d1a9cd2bb3b53e57cc6db343 Mon Sep 17 00:00:00 2001 From: Petr Janda Date: Fri, 6 Dec 2019 17:21:24 +1030 Subject: [PATCH 15/53] Add logging when force_key_frames is disabled --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 0918d57af..3207a6882 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -948,9 +948,13 @@ namespace MediaBrowser.Api.Playback.Hls args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultEncoderPreset()); // Unable to force key frames to h264_qsv transcode - if (codec != "h264_qsv") { - args += " " + keyFrameArg; - } + if (codec == "h264_qsv") { + Logger.LogInformation("Bug Workaround: Disabling force_key_frames for h264_qsv"); + } + else + { + args += " " + keyFrameArg; + } //args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0"; From 94edb5b9f98cf3b06144255eccc988712332f0a8 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Fri, 6 Dec 2019 11:58:45 +0100 Subject: [PATCH 16/53] Add else --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 438ca39ea..4f74bb222 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -1278,6 +1278,7 @@ namespace Emby.Dlna.ContentDirectory { query.OrderBy = Array.Empty<(string, SortOrder)>(); } + else { query.OrderBy = new[] { (ItemSortBy.SortName, sort.SortOrder) }; } From 8befab5b5dc586a7673a1dc384cf41044c37351c Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Fri, 6 Dec 2019 20:21:18 +0100 Subject: [PATCH 17/53] Simplify regex to avoid catastrophic backtracking --- Emby.Naming/Common/NamingOptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index d37be0e63..4c2c43437 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -314,7 +314,7 @@ namespace Emby.Naming.Common // This isn't a Kodi naming rule, but the expression below causes false positives, // so we make sure this one gets tested first. // "Foo Bar 889" - new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?(\w+\s*?)*)\s(?\d{1,3})(-(?\d{2,3}))*[^\\\/]*$") + new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?[\w\s]+?)\s(?\d{1,3})(-(?\d{2,3}))*[^\\\/]*$") { IsNamed = true }, @@ -337,7 +337,7 @@ namespace Emby.Naming.Common // *** End Kodi Standard Naming                 // [bar] Foo - 1 [baz] - new EpisodeExpression(@".*?(\[.*?\])+.*?(?(\w+\s*?)+?)[-\s_]+(?\d+).*$") + new EpisodeExpression(@".*?(\[.*?\])+.*?(?[\w\s]+?)[-\s_]+(?\d+).*$") { IsNamed = true }, From 803ec1515061ea470f7751eb81d91a4e42e122e6 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 6 Dec 2019 21:08:11 +0100 Subject: [PATCH 18/53] Fix ubuntu x64 docker build --- deployment/ubuntu-package-x64/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/ubuntu-package-x64/Dockerfile b/deployment/ubuntu-package-x64/Dockerfile index 99022891b..21a536e5e 100644 --- a/deployment/ubuntu-package-x64/Dockerfile +++ b/deployment/ubuntu-package-x64/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/dotnet:2.2-sdk-bionic +FROM microsoft/dotnet:3.0-sdk-bionic # Docker build arguments ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-x64 From 68edb9734dfc2feec207f00319588d3cec3b67fb Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 7 Dec 2019 06:46:24 +1030 Subject: [PATCH 19/53] Add space between if statement and boolean expression Co-Authored-By: Vasily --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 550ad78b8..8078efced 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -473,7 +473,7 @@ namespace MediaBrowser.Controller.MediaEncoding var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); var outputVideoCodec = GetVideoEncoder(state, encodingOptions); - if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) + if (encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) { if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) { From 5b5d527a09a94ef847c60578306c858fe6feff89 Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 7 Dec 2019 06:47:57 +1030 Subject: [PATCH 20/53] Use string.Equals instead of of equals operator Co-Authored-By: Vasily --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 3207a6882..e3bd3c8c9 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -948,7 +948,7 @@ namespace MediaBrowser.Api.Playback.Hls args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultEncoderPreset()); // Unable to force key frames to h264_qsv transcode - if (codec == "h264_qsv") { + if (string.Equals(codec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) { Logger.LogInformation("Bug Workaround: Disabling force_key_frames for h264_qsv"); } else From 408cf017a44748f7085af7e5ffa0ca1c46f0ba19 Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 7 Dec 2019 06:48:44 +1030 Subject: [PATCH 21/53] Remove newline Co-Authored-By: Vasily --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 8078efced..268895540 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -517,7 +517,6 @@ namespace MediaBrowser.Controller.MediaEncoding } } - arg.Append(" -i \"").Append(subtitlePath).Append('\"'); } From ec70f3ac75dad10b076a475bbec6d71ded9881a6 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 6 Dec 2019 22:06:16 +0100 Subject: [PATCH 22/53] Fix plugin installation and correct api behaviour The `/Packages/{Name}` endpoint would return a package that had either the corrent name or the correct guid. In reality it shoud check if both are correct. --- .../Updates/InstallationManager.cs | 3 +-- MediaBrowser.Api/PackageService.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 09a5a0dca..2705e0628 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -141,8 +141,7 @@ namespace Emby.Server.Implementations.Updates if (guid != Guid.Empty) { - var strGuid = guid.ToString("N", CultureInfo.InvariantCulture); - availablePackages = availablePackages.Where(x => x.guid.Equals(strGuid, StringComparison.OrdinalIgnoreCase)); + availablePackages = availablePackages.Where(x => Guid.Parse(x.guid) == guid); } return availablePackages; diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index 1e5a93210..325acfb7b 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common; using MediaBrowser.Common.Extensions; @@ -133,10 +132,11 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetPackage request) { - var packages = _installationManager.GetAvailablePackages().Result; - - var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase)) - ?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); + var packages = _installationManager.GetAvailablePackages().GetAwaiter().GetResult(); + var result = _installationManager.FilterPackages( + packages, + request.Name, + string.IsNullOrEmpty(request.AssemblyGuid) ? default : Guid.Parse(request.AssemblyGuid)).FirstOrDefault(); return ToOptimizedResult(result); } @@ -181,7 +181,7 @@ namespace MediaBrowser.Api var package = _installationManager.GetCompatibleVersions( packages, request.Name, - new Guid(request.AssemblyGuid), + string.IsNullOrEmpty(request.AssemblyGuid) ? Guid.Empty : Guid.Parse(request.AssemblyGuid), string.IsNullOrEmpty(request.Version) ? null : Version.Parse(request.Version), request.UpdateClass).FirstOrDefault(); From 4fa8f9ccfe6e570d6d122ee41c70a242370576df Mon Sep 17 00:00:00 2001 From: antoniy Date: Thu, 5 Dec 2019 22:14:29 +0000 Subject: [PATCH 23/53] Translated using Weblate (Bulgarian) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/bg/ --- Emby.Server.Implementations/Localization/Core/bg-BG.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/bg-BG.json b/Emby.Server.Implementations/Localization/Core/bg-BG.json index bfe32a6c2..46c10d912 100644 --- a/Emby.Server.Implementations/Localization/Core/bg-BG.json +++ b/Emby.Server.Implementations/Localization/Core/bg-BG.json @@ -5,13 +5,13 @@ "Artists": "Изпълнители", "AuthenticationSucceededWithUserName": "{0} се удостовери успешно", "Books": "Книги", - "CameraImageUploadedFrom": "", + "CameraImageUploadedFrom": "Нова снимка от камера беше качена от {0}", "Channels": "Канали", "ChapterNameValue": "Глава {0}", "Collections": "Колекции", "DeviceOfflineWithName": "{0} се разкачи", "DeviceOnlineWithName": "{0} е свързан", - "FailedLoginAttemptWithUserName": "", + "FailedLoginAttemptWithUserName": "Неуспешен опит за влизане от {0}", "Favorites": "Любими", "Folders": "Папки", "Genres": "Жанрове", From 52f31775fc26f98e5557bdef2f0f63b8b8ee4b16 Mon Sep 17 00:00:00 2001 From: Matzi24GR Date: Sat, 7 Dec 2019 23:39:10 +0000 Subject: [PATCH 24/53] Translated using Weblate (Greek) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/el/ --- Emby.Server.Implementations/Localization/Core/el.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/el.json b/Emby.Server.Implementations/Localization/Core/el.json index 3589a4893..580b42330 100644 --- a/Emby.Server.Implementations/Localization/Core/el.json +++ b/Emby.Server.Implementations/Localization/Core/el.json @@ -3,7 +3,7 @@ "AppDeviceValues": "Εφαρμογή: {0}, Συσκευή: {1}", "Application": "Εφαρμογή", "Artists": "Καλλιτέχνες", - "AuthenticationSucceededWithUserName": "Ο χρήστης {0} επαληθεύτηκε με επιτυχία", + "AuthenticationSucceededWithUserName": "Ο χρήστης {0} επαληθεύτηκε επιτυχώς", "Books": "Βιβλία", "CameraImageUploadedFrom": "Μια νέα εικόνα κάμερας έχει αποσταλεί από {0}", "Channels": "Κανάλια", From f0dbcfca6e669e0c48e31173fadaf241ebd04629 Mon Sep 17 00:00:00 2001 From: tanto faz Date: Fri, 6 Dec 2019 16:32:12 +0000 Subject: [PATCH 25/53] Translated using Weblate (Portuguese (Brazil)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/pt_BR/ --- .../Localization/Core/pt-BR.json | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/pt-BR.json b/Emby.Server.Implementations/Localization/Core/pt-BR.json index faa8499b8..fcc724a7d 100644 --- a/Emby.Server.Implementations/Localization/Core/pt-BR.json +++ b/Emby.Server.Implementations/Localization/Core/pt-BR.json @@ -1,7 +1,7 @@ { "Albums": "Álbuns", "AppDeviceValues": "App: {0}, Dispositivo: {1}", - "Application": "Inscrição", + "Application": "Aplicativo", "Artists": "Artistas", "AuthenticationSucceededWithUserName": "{0} autenticado com sucesso", "Books": "Livros", @@ -10,7 +10,7 @@ "ChapterNameValue": "Capítulo {0}", "Collections": "Coletâneas", "DeviceOfflineWithName": "{0} se desconectou", - "DeviceOnlineWithName": "{0} está conectado", + "DeviceOnlineWithName": "{0} se conectou", "FailedLoginAttemptWithUserName": "Falha na tentativa de login de {0}", "Favorites": "Favoritos", "Folders": "Pastas", @@ -40,16 +40,16 @@ "MixedContent": "Conteúdo misto", "Movies": "Filmes", "Music": "Música", - "MusicVideos": "Clipes", + "MusicVideos": "Videoclipes", "NameInstallFailed": "A instalação de {0} falhou", "NameSeasonNumber": "Temporada {0}", "NameSeasonUnknown": "Temporada Desconhecida", "NewVersionIsAvailable": "Uma nova versão do Servidor Jellyfin está disponível para download.", - "NotificationOptionApplicationUpdateAvailable": "Atualização de aplicativo disponível", - "NotificationOptionApplicationUpdateInstalled": "Atualização de aplicativo instalada", + "NotificationOptionApplicationUpdateAvailable": "Atualização do aplicativo disponível", + "NotificationOptionApplicationUpdateInstalled": "Atualização do aplicativo instalada", "NotificationOptionAudioPlayback": "Reprodução de áudio iniciada", "NotificationOptionAudioPlaybackStopped": "Reprodução de áudio parada", - "NotificationOptionCameraImageUploaded": "Imagem de câmera enviada", + "NotificationOptionCameraImageUploaded": "Imagem da câmera enviada", "NotificationOptionInstallationFailed": "Falha na instalação", "NotificationOptionNewLibraryContent": "Novo conteúdo adicionado", "NotificationOptionPluginError": "Falha de plugin", @@ -73,7 +73,7 @@ "ServerNameNeedsToBeRestarted": "O servidor {0} precisa ser reiniciado", "Shows": "Séries", "Songs": "Músicas", - "StartupEmbyServerIsLoading": "O Servidor Jellyfin está carregando. Por favor tente novamente em breve.", + "StartupEmbyServerIsLoading": "O Servidor Jellyfin está carregando. Por favor, tente novamente mais tarde.", "SubtitleDownloadFailureForItem": "Download de legendas falhou para {0}", "SubtitleDownloadFailureFromForItem": "Houve um problema ao baixar as legendas de {0} para {1}", "SubtitlesDownloadedForItem": "Legendas baixadas para {0}", @@ -86,12 +86,12 @@ "UserDownloadingItemWithValues": "{0} está baixando {1}", "UserLockedOutWithName": "Usuário {0} foi bloqueado", "UserOfflineFromDevice": "{0} se desconectou de {1}", - "UserOnlineFromDevice": "{0} está ativo em {1}", + "UserOnlineFromDevice": "{0} está online em {1}", "UserPasswordChangedWithName": "A senha foi alterada para o usuário {0}", "UserPolicyUpdatedWithName": "A política de usuário foi atualizada para {0}", - "UserStartedPlayingItemWithValues": "{0} iniciou a reprodução de {1}", - "UserStoppedPlayingItemWithValues": "{0} parou de reproduzir {1}", - "ValueHasBeenAddedToLibrary": "{0} foi adicionado a sua biblioteca", + "UserStartedPlayingItemWithValues": "{0} está reproduzindo {1} em {2}", + "UserStoppedPlayingItemWithValues": "{0} parou de reproduzir {1} em {2}", + "ValueHasBeenAddedToLibrary": "{0} foi adicionado à sua biblioteca de mídia", "ValueSpecialEpisodeName": "Especial - {0}", "VersionNumber": "Versão {0}" } From 7d4c4c369edcefc00cc36e2f4024c2edbbdf2caa Mon Sep 17 00:00:00 2001 From: translit Date: Sat, 7 Dec 2019 10:32:31 +0000 Subject: [PATCH 26/53] Translated using Weblate (Russian) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/ru/ --- Emby.Server.Implementations/Localization/Core/ru.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/ru.json b/Emby.Server.Implementations/Localization/Core/ru.json index 0ad4b37aa..7cf957a94 100644 --- a/Emby.Server.Implementations/Localization/Core/ru.json +++ b/Emby.Server.Implementations/Localization/Core/ru.json @@ -1,11 +1,11 @@ { "Albums": "Альбомы", - "AppDeviceValues": "Прил.: {0}, Устр.: {1}", + "AppDeviceValues": "Приложение.: {0}, Устройство.: {1}", "Application": "Приложение", "Artists": "Исполнители", "AuthenticationSucceededWithUserName": "{0} - авторизация успешна", - "Books": "Литература", - "CameraImageUploadedFrom": "Новое фото было выложено с камеры {0}", + "Books": "Книги", + "CameraImageUploadedFrom": "Новое фото загружено с камеры {0}", "Channels": "Каналы", "ChapterNameValue": "Сцена {0}", "Collections": "Коллекции", From cf1eb2798cb3b5bc1b087d7214ab788223809bb2 Mon Sep 17 00:00:00 2001 From: nextlooper42 Date: Mon, 9 Dec 2019 01:27:14 +0000 Subject: [PATCH 27/53] Translated using Weblate (Slovak) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/sk/ --- .../Localization/Core/sk.json | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/sk.json b/Emby.Server.Implementations/Localization/Core/sk.json index 75eecbe3e..9bac305a2 100644 --- a/Emby.Server.Implementations/Localization/Core/sk.json +++ b/Emby.Server.Implementations/Localization/Core/sk.json @@ -1,6 +1,6 @@ { "Albums": "Albumy", - "AppDeviceValues": "Apka: {0}, Zariadenie: {1}", + "AppDeviceValues": "Aplikácia: {0}, Zariadenie: {1}", "Application": "Aplikácia", "Artists": "Umelci", "AuthenticationSucceededWithUserName": "{0} úspešne overený", @@ -8,7 +8,7 @@ "CameraImageUploadedFrom": "Z {0} bola nahraná nová fotografia", "Channels": "Kanály", "ChapterNameValue": "Kapitola {0}", - "Collections": "Zbierky", + "Collections": "Kolekcie", "DeviceOfflineWithName": "{0} sa odpojil", "DeviceOnlineWithName": "{0} je pripojený", "FailedLoginAttemptWithUserName": "Neúspešný pokus o prihlásenie z {0}", @@ -22,7 +22,7 @@ "HeaderFavoriteArtists": "Obľúbení umelci", "HeaderFavoriteEpisodes": "Obľúbené epizódy", "HeaderFavoriteShows": "Obľúbené seriály", - "HeaderFavoriteSongs": "Obľúbené pesničky", + "HeaderFavoriteSongs": "Obľúbené piesne", "HeaderLiveTV": "Živá TV", "HeaderNextUp": "Nasleduje", "HeaderRecordingGroups": "Skupiny nahrávok", @@ -34,7 +34,7 @@ "LabelRunningTimeValue": "Dĺžka: {0}", "Latest": "Najnovšie", "MessageApplicationUpdated": "Jellyfin Server bol aktualizovaný", - "MessageApplicationUpdatedTo": "Jellyfin Server bol aktualizový na {0}", + "MessageApplicationUpdatedTo": "Jellyfin Server bol aktualizový na verziu {0}", "MessageNamedServerConfigurationUpdatedWithValue": "Sekcia {0} konfigurácie servera bola aktualizovaná", "MessageServerConfigurationUpdated": "Konfigurácia servera bola aktualizovaná", "MixedContent": "Zmiešaný obsah", @@ -42,23 +42,23 @@ "Music": "Hudba", "MusicVideos": "Hudobné videá", "NameInstallFailed": "Inštalácia {0} zlyhala", - "NameSeasonNumber": "Sezóna {0}", - "NameSeasonUnknown": "Neznáma sezóna", - "NewVersionIsAvailable": "Nová verzia Jellyfin Server je dostupná na stiahnutie.", - "NotificationOptionApplicationUpdateAvailable": "Je dostupná aktualizácia aplikácie", + "NameSeasonNumber": "Séria {0}", + "NameSeasonUnknown": "Neznáma séria", + "NewVersionIsAvailable": "Nová verzia Jellyfin Serveru je dostupná na stiahnutie.", + "NotificationOptionApplicationUpdateAvailable": "Aktualizácia aplikácie je dostupná", "NotificationOptionApplicationUpdateInstalled": "Aktualizácia aplikácie nainštalovaná", - "NotificationOptionAudioPlayback": "Spustené prehrávanie audia", - "NotificationOptionAudioPlaybackStopped": "Zastavené prehrávanie audia", - "NotificationOptionCameraImageUploaded": "Nahraný obrázok z fotoaparátu", + "NotificationOptionAudioPlayback": "Prehrávanie audia bolo spustené", + "NotificationOptionAudioPlaybackStopped": "Prehrávanie audia bolo zastavené", + "NotificationOptionCameraImageUploaded": "Obrázok z fotoaparátu bol nahraný", "NotificationOptionInstallationFailed": "Chyba inštalácie", - "NotificationOptionNewLibraryContent": "Pridaný nový obsah", + "NotificationOptionNewLibraryContent": "Nový obsah bol pridaný", "NotificationOptionPluginError": "Chyba rozšírenia", "NotificationOptionPluginInstalled": "Rozšírenie nainštalované", "NotificationOptionPluginUninstalled": "Rozšírenie odinštalované", "NotificationOptionPluginUpdateInstalled": "Aktualizácia rozšírenia nainštalovaná", "NotificationOptionServerRestartRequired": "Vyžaduje sa reštart servera", "NotificationOptionTaskFailed": "Naplánovaná úloha zlyhala", - "NotificationOptionUserLockedOut": "User locked out", + "NotificationOptionUserLockedOut": "Používateľ je uzamknutý", "NotificationOptionVideoPlayback": "Spustené prehrávanie videa", "NotificationOptionVideoPlaybackStopped": "Zastavené prehrávanie videa", "Photos": "Fotky", @@ -69,9 +69,9 @@ "PluginUpdatedWithName": "{0} bol aktualizovaný", "ProviderValue": "Poskytovateľ: {0}", "ScheduledTaskFailedWithName": "{0} zlyhalo", - "ScheduledTaskStartedWithName": "{0} started", + "ScheduledTaskStartedWithName": "{0} zahájených", "ServerNameNeedsToBeRestarted": "{0} vyžaduje reštart", - "Shows": "Series", + "Shows": "Seriály", "Songs": "Skladby", "StartupEmbyServerIsLoading": "Jellyfin Server sa spúšťa. Skúste to prosím o chvíľu znova.", "SubtitleDownloadFailureForItem": "Sťahovanie titulkov pre {0} zlyhalo", @@ -84,11 +84,11 @@ "UserCreatedWithName": "Používateľ {0} bol vytvorený", "UserDeletedWithName": "Používateľ {0} bol vymazaný", "UserDownloadingItemWithValues": "{0} sťahuje {1}", - "UserLockedOutWithName": "User {0} has been locked out", + "UserLockedOutWithName": "Používateľ {0} bol vymknutý", "UserOfflineFromDevice": "{0} sa odpojil od {1}", "UserOnlineFromDevice": "{0} je online z {1}", "UserPasswordChangedWithName": "Heslo používateľa {0} zmenené", - "UserPolicyUpdatedWithName": "User policy has been updated for {0}", + "UserPolicyUpdatedWithName": "Používateľské zásady pre {0} boli aktualizované", "UserStartedPlayingItemWithValues": "{0} spustil prehrávanie {1}", "UserStoppedPlayingItemWithValues": "{0} zastavil prehrávanie {1}", "ValueHasBeenAddedToLibrary": "{0} bolo pridané do vašej knižnice médií", From f25c1e40d4a6c38c8191d8724ba0d81b6421c40d Mon Sep 17 00:00:00 2001 From: Michael Berggren Date: Fri, 6 Dec 2019 18:48:28 +0000 Subject: [PATCH 28/53] Translated using Weblate (Swedish) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/sv/ --- .../Localization/Core/sv.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/sv.json b/Emby.Server.Implementations/Localization/Core/sv.json index fb2761a7d..744b0e2d3 100644 --- a/Emby.Server.Implementations/Localization/Core/sv.json +++ b/Emby.Server.Implementations/Localization/Core/sv.json @@ -5,7 +5,7 @@ "Artists": "Artister", "AuthenticationSucceededWithUserName": "{0} har autentiserats", "Books": "Böcker", - "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", + "CameraImageUploadedFrom": "En ny kamerabild har laddats upp från {0}", "Channels": "Kanaler", "ChapterNameValue": "Kapitel {0}", "Collections": "Samlingar", @@ -16,7 +16,7 @@ "Folders": "Mappar", "Genres": "Genrer", "HeaderAlbumArtists": "Albumartister", - "HeaderCameraUploads": "Camera Uploads", + "HeaderCameraUploads": "Kamera Uppladdningar", "HeaderContinueWatching": "Fortsätt kolla på", "HeaderFavoriteAlbums": "Favoritalbum", "HeaderFavoriteArtists": "Favoritartister", @@ -34,17 +34,17 @@ "LabelRunningTimeValue": "Speltid: {0}", "Latest": "Senaste", "MessageApplicationUpdated": "Jellyfin Server har uppdaterats", - "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}", + "MessageApplicationUpdatedTo": "Jellyfin Server har uppgraderats till {0}", "MessageNamedServerConfigurationUpdatedWithValue": "Serverinställningarna {0} har uppdaterats", "MessageServerConfigurationUpdated": "Server konfigurationen har uppdaterats", "MixedContent": "Blandat innehåll", "Movies": "Filmer", "Music": "Musik", "MusicVideos": "Musikvideos", - "NameInstallFailed": "{0} installation failed", + "NameInstallFailed": "{0} installationen misslyckades", "NameSeasonNumber": "Säsong {0}", "NameSeasonUnknown": "Okänd säsong", - "NewVersionIsAvailable": "A new version of Jellyfin Server is available for download.", + "NewVersionIsAvailable": "En ny version av Jellyfin Server är klar för nedladdning.", "NotificationOptionApplicationUpdateAvailable": "Ny programversion tillgänglig", "NotificationOptionApplicationUpdateInstalled": "Programuppdatering installerad", "NotificationOptionAudioPlayback": "Ljuduppspelning har påbörjats", @@ -70,12 +70,12 @@ "ProviderValue": "Källa: {0}", "ScheduledTaskFailedWithName": "{0} misslyckades", "ScheduledTaskStartedWithName": "{0} startad", - "ServerNameNeedsToBeRestarted": "{0} needs to be restarted", + "ServerNameNeedsToBeRestarted": "{0} behöver startas om", "Shows": "Serier", "Songs": "Låtar", "StartupEmbyServerIsLoading": "Jellyfin server arbetar. Pröva igen inom kort.", "SubtitleDownloadFailureForItem": "Nerladdning av undertexter för {0} misslyckades", - "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}", + "SubtitleDownloadFailureFromForItem": "Undertexter misslyckades att ladda ner {0} för {1}", "SubtitlesDownloadedForItem": "Undertexter har laddats ner till {0}", "Sync": "Synk", "System": "System", @@ -91,7 +91,7 @@ "UserPolicyUpdatedWithName": "Användarpolicyn har uppdaterats för {0}", "UserStartedPlayingItemWithValues": "{0} har börjat spela upp {1}", "UserStoppedPlayingItemWithValues": "{0} har avslutat uppspelningen av {1}", - "ValueHasBeenAddedToLibrary": "{0} has been added to your media library", + "ValueHasBeenAddedToLibrary": "{0} har blivit tillagd till ditt mediabibliotek", "ValueSpecialEpisodeName": "Specialavsnitt - {0}", "VersionNumber": "Version {0}" } From 1b5da55ae554176f272b956402671170cce3817b Mon Sep 17 00:00:00 2001 From: gustinn Date: Thu, 5 Dec 2019 18:29:56 +0000 Subject: [PATCH 29/53] Translated using Weblate (Icelandic) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/is/ --- .../Localization/Core/is.json | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/is.json b/Emby.Server.Implementations/Localization/Core/is.json index 0967ef424..982232afd 100644 --- a/Emby.Server.Implementations/Localization/Core/is.json +++ b/Emby.Server.Implementations/Localization/Core/is.json @@ -1 +1,34 @@ -{} +{ + "LabelIpAddressValue": "IP tala: {0}", + "ItemRemovedWithName": "{0} var fjarlægt úr safninu", + "ItemAddedWithName": "{0} var bætt í safnið", + "Inherit": "Erfa", + "HomeVideos": "Myndbönd að heiman", + "HeaderRecordingGroups": "Upptökuhópar", + "HeaderNextUp": "Næst á dagskrá", + "HeaderLiveTV": "Sjónvarp í beinni útsendingu", + "HeaderFavoriteSongs": "Uppáhalds lög", + "HeaderFavoriteShows": "Uppáhalds sjónvarpsþættir", + "HeaderFavoriteEpisodes": "Uppáhalds þættir", + "HeaderFavoriteArtists": "Uppáhalds listamenn", + "HeaderFavoriteAlbums": "Uppáhalds plötur", + "HeaderContinueWatching": "Halda áfram að horfa", + "HeaderCameraUploads": "Myndavéla upphal", + "HeaderAlbumArtists": "Höfundur plötu", + "Genres": "Tegundir", + "Folders": "Möppur", + "Favorites": "Uppáhalds", + "FailedLoginAttemptWithUserName": "{0} reyndi að auðkenna sig", + "DeviceOnlineWithName": "{0} hefur tengst", + "DeviceOfflineWithName": "{0} hefur aftengst", + "Collections": "Söfn", + "ChapterNameValue": "Kafli {0}", + "Channels": "Stöðvar", + "CameraImageUploadedFrom": "Ný ljósmynd frá myndavél hefur verið hlaðið upp frá {0}", + "Books": "Bækur", + "AuthenticationSucceededWithUserName": "{0} náði að auðkennast", + "Artists": "Listamaður", + "Application": "Forrit", + "AppDeviceValues": "Snjallforrit: {0}, Tæki: {1}", + "Albums": "Plötur" +} From affb58ef9e11f7f14192c76074b1199604f6bd67 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 10 Dec 2019 16:22:03 +0100 Subject: [PATCH 30/53] Apply suggestions from code review Co-Authored-By: dkanada --- .../AppBase/BaseConfigurationManager.cs | 2 +- .../Configuration/ServerConfigurationManager.cs | 2 +- Emby.Server.Implementations/Data/BaseSqliteRepository.cs | 2 +- .../EntryPoints/RefreshUsersMetadata.cs | 2 +- .../EntryPoints/ServerEventNotifier.cs | 8 ++++---- Emby.Server.Implementations/EntryPoints/StartupWizard.cs | 4 ++-- .../EntryPoints/UdpServerEntryPoint.cs | 2 +- .../HttpServer/HttpResultFactory.cs | 2 +- Emby.Server.Implementations/HttpServer/StreamWriter.cs | 2 +- .../HttpServer/WebSocketConnection.cs | 6 +++--- Emby.Server.Implementations/Library/UserManager.cs | 2 +- .../Library/Validators/ArtistsValidator.cs | 4 ++-- .../Library/Validators/GenresValidator.cs | 4 ++-- .../Library/Validators/MusicGenresPostScanTask.cs | 2 +- .../Library/Validators/MusicGenresValidator.cs | 4 ++-- .../Library/Validators/StudiosValidator.cs | 4 ++-- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index f5ca8e144..edf68cf7c 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -351,7 +351,7 @@ namespace Emby.Server.Implementations.AppBase } /// - /// Event handler for when a named configuration got updates. + /// Event handler for when a named configuration has been updated. /// /// The key of the configuration. /// The old configuration. diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs index 4def7ca40..3d8d15d19 100644 --- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.Configuration } /// - /// Sets all config values to the optimal value. + /// Sets all configuration values to their optimal values. /// /// If the configuration changed. public bool SetOptimalValues() diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index 30f29beee..0654132f4 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.Data /// /// Initializes a new instance of the class. /// - /// The ogger. + /// The logger. protected BaseSqliteRepository(ILogger logger) { Logger = logger; diff --git a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs index 1ca25ba6f..f00996b5f 100644 --- a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs +++ b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs @@ -18,7 +18,7 @@ namespace Emby.Server.Implementations.EntryPoints private readonly ILogger _logger; /// - /// The _user manager. + /// The user manager. /// private readonly IUserManager _userManager; diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs index 9ccbf7535..e1dbb663b 100644 --- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs @@ -21,22 +21,22 @@ namespace Emby.Server.Implementations.EntryPoints public class ServerEventNotifier : IServerEntryPoint { /// - /// The _user manager. + /// The user manager. /// private readonly IUserManager _userManager; /// - /// The _installation manager. + /// The installation manager. /// private readonly IInstallationManager _installationManager; /// - /// The _kernel. + /// The kernel. /// private readonly IServerApplicationHost _appHost; /// - /// The _task manager. + /// The task manager. /// private readonly ITaskManager _taskManager; diff --git a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs index 9cef77dc8..161788c63 100644 --- a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs +++ b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs @@ -13,12 +13,12 @@ namespace Emby.Server.Implementations.EntryPoints public class StartupWizard : IServerEntryPoint { /// - /// The _app host. + /// The app host. /// private readonly IServerApplicationHost _appHost; /// - /// The _user manager. + /// The user manager. /// private readonly ILogger _logger; diff --git a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs index 24ac6d1fd..9ee219854 100644 --- a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -20,7 +20,7 @@ namespace Emby.Server.Implementations.EntryPoints public const int PortNumber = 7359; /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; private readonly ISocketFactory _socketFactory; diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index f9eb3a897..a62b4e7af 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.HttpServer public class HttpResultFactory : IHttpResultFactory { /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; private readonly IFileSystem _fileSystem; diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs index eda236028..5afc51dbc 100644 --- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs +++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs @@ -15,7 +15,7 @@ namespace Emby.Server.Implementations.HttpServer public class StreamWriter : IAsyncStreamWriter, IHasHeaders { /// - /// The _options. + /// The options. /// private readonly IDictionary _options = new Dictionary(); diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 5d657b8a7..2292d86a4 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -24,12 +24,12 @@ namespace Emby.Server.Implementations.HttpServer private readonly ILogger _logger; /// - /// The _json serializer. + /// The json serializer. /// private readonly IJsonSerializer _jsonSerializer; /// - /// The _socket. + /// The socket. /// private readonly IWebSocket _socket; @@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.HttpServer public event EventHandler Closed; /// - /// Gets or sets the _remote end point. + /// Gets or sets the remote end point. /// public string RemoteEndPoint { get; private set; } diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 1233dcc43..eaad05f92 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -43,7 +43,7 @@ namespace Emby.Server.Implementations.Library public class UserManager : IUserManager { /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; diff --git a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs index dbadaeefb..1497f4a3a 100644 --- a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -17,12 +17,12 @@ namespace Emby.Server.Implementations.Library.Validators public class ArtistsValidator { /// - /// The _library manager. + /// The library manager. /// private readonly ILibraryManager _libraryManager; /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; private readonly IItemRepository _itemRepo; diff --git a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs index 6478f1873..b0cd5f87a 100644 --- a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs @@ -13,13 +13,13 @@ namespace Emby.Server.Implementations.Library.Validators public class GenresValidator { /// - /// The _library manager. + /// The library manager. /// private readonly ILibraryManager _libraryManager; private readonly IItemRepository _itemRepo; /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; diff --git a/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs index 1b5c83f1e..58549e9d7 100644 --- a/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs +++ b/Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs @@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.Library.Validators public class MusicGenresPostScanTask : ILibraryPostScanTask { /// - /// The _library manager. + /// The library manager. /// private readonly ILibraryManager _libraryManager; private readonly ILogger _logger; diff --git a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs index 23a28e936..5ee4ca72e 100644 --- a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -13,12 +13,12 @@ namespace Emby.Server.Implementations.Library.Validators public class MusicGenresValidator { /// - /// The _library manager. + /// The library manager. /// private readonly ILibraryManager _libraryManager; /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; private readonly IItemRepository _itemRepo; diff --git a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs index 887eef5c3..15e7a0dbb 100644 --- a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -15,14 +15,14 @@ namespace Emby.Server.Implementations.Library.Validators public class StudiosValidator { /// - /// The _library manager. + /// The library manager. /// private readonly ILibraryManager _libraryManager; private readonly IItemRepository _itemRepo; /// - /// The _logger. + /// The logger. /// private readonly ILogger _logger; From 19844a2c2a80d27d8aea88edf68c822cf78c0eac Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 10 Dec 2019 17:07:23 +0100 Subject: [PATCH 31/53] Fix typo --- MediaBrowser.Api/Images/ImageService.cs | 2 +- MediaBrowser.Api/Music/AlbumsService.cs | 2 +- MediaBrowser.Api/Playback/Progressive/VideoService.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index f1b88de64..e94c1321f 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -239,7 +239,7 @@ namespace MediaBrowser.Api.Images /// Initializes a new instance of the class. /// public ImageService( - Logger logger, + ILogger logger, IServerConfigurationManager serverConfigurationManager, IHttpResultFactory httpResultFactory, IUserManager userManager, diff --git a/MediaBrowser.Api/Music/AlbumsService.cs b/MediaBrowser.Api/Music/AlbumsService.cs index fd6c0b7da..58c95d053 100644 --- a/MediaBrowser.Api/Music/AlbumsService.cs +++ b/MediaBrowser.Api/Music/AlbumsService.cs @@ -44,7 +44,7 @@ namespace MediaBrowser.Api.Music private readonly IAuthorizationContext _authContext; public AlbumsService( - Logger logger, + ILogger logger, IServerConfigurationManager serverConfigurationManager, IHttpResultFactory httpResultFactory, IUserManager userManager, diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index fc5603d27..56ec86cd4 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -70,7 +70,7 @@ namespace MediaBrowser.Api.Playback.Progressive public class VideoService : BaseProgressiveStreamingService { public VideoService( - Logger logger, + ILogger logger, IServerConfigurationManager serverConfigurationManager, IHttpResultFactory httpResultFactory, IHttpClient httpClient, From b98e25a07e9b487a65019dc53b28d9337bafd1d4 Mon Sep 17 00:00:00 2001 From: chaosinnovator Date: Tue, 10 Dec 2019 09:30:44 -0800 Subject: [PATCH 32/53] Add StartIndex result to /Items API query --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 8 ++++++-- MediaBrowser.Model/Querying/QueryResult.cs | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index b4a302648..1cddcb9c3 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -127,6 +127,7 @@ namespace MediaBrowser.Api.UserLibrary var result = new QueryResult { + StartIndex = request.StartIndex.GetValueOrDefault(), TotalRecordCount = itemsResult.TotalRecordCount, Items = returnItems }; @@ -177,6 +178,7 @@ namespace MediaBrowser.Api.UserLibrary return new QueryResult { + StartIndex = request.StartIndex.GetValueOrDefault(), TotalRecordCount = result.TotalRecordCount, Items = dtoList }; @@ -237,7 +239,8 @@ namespace MediaBrowser.Api.UserLibrary return new QueryResult { Items = Array.Empty(), - TotalRecordCount = 0 + TotalRecordCount = 0, + StartIndex = 0 }; } @@ -250,7 +253,8 @@ namespace MediaBrowser.Api.UserLibrary return new QueryResult { Items = itemsArray, - TotalRecordCount = itemsArray.Length + TotalRecordCount = itemsArray.Length, + StartIndex = 0 }; } diff --git a/MediaBrowser.Model/Querying/QueryResult.cs b/MediaBrowser.Model/Querying/QueryResult.cs index c007a45d6..221645afb 100644 --- a/MediaBrowser.Model/Querying/QueryResult.cs +++ b/MediaBrowser.Model/Querying/QueryResult.cs @@ -17,6 +17,12 @@ namespace MediaBrowser.Model.Querying /// The total record count. public int TotalRecordCount { get; set; } + /// + /// The index of the first record in Items. + /// + /// First record index. + public int StartIndex { get; set; } + public QueryResult() { Items = Array.Empty(); From 1e0967f43c4eea104bd16347aaef3007cb3b820d Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Wed, 11 Dec 2019 23:47:51 +0100 Subject: [PATCH 33/53] Fix issue with episode search --- MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index e5287048d..4269d3420 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -35,9 +35,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB { var list = new List(); - // The search query must either provide an episode number or date - if (!searchInfo.IndexNumber.HasValue - || !searchInfo.PremiereDate.HasValue + // Either an episode number or date must be provided; and the dictionary of provider ids must be valid + if ((searchInfo.IndexNumber == null && searchInfo.PremiereDate == null) || !TvdbSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds)) { return list; From 421092b478419ecd72a607b88ab4cd15e89d9017 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Wed, 11 Dec 2019 23:48:41 +0100 Subject: [PATCH 34/53] Clean up checks for Dictionary keys --- .../TV/TheTVDB/TvdbSeriesProvider.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 10ed4f073..72ceadaf1 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -170,11 +170,16 @@ namespace MediaBrowser.Providers.TV.TheTVDB return result?.Data.First().Id.ToString(); } + /// + /// Check whether a dictionary of provider IDs includes an entry for a valid TV metadata provider. + /// + /// The dictionary to check. + /// True, if the dictionary contains a valid TV provider ID, otherwise false. internal static bool IsValidSeries(Dictionary seriesProviderIds) { - return seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out _) || - seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out _) || - seriesProviderIds.TryGetValue(MetadataProviders.Zap2It.ToString(), out _); + return seriesProviderIds.ContainsKey(MetadataProviders.Tvdb.ToString()) || + seriesProviderIds.ContainsKey(MetadataProviders.Imdb.ToString()) || + seriesProviderIds.ContainsKey(MetadataProviders.Zap2It.ToString()); } /// From a4ca259a64d12629d88a1c801c4bc869c8a5d44b Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 12 Dec 2019 17:25:58 +0100 Subject: [PATCH 35/53] Add improved error error for #2141 --- Emby.Server.Implementations/LiveTv/LiveTvManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 2ecf4e184..ee7db1413 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -304,9 +304,12 @@ namespace Emby.Server.Implementations.LiveTv } private ILiveTvService GetService(string name) - { - return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); - } + => Array.Find(_services, x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)) + ?? throw new KeyNotFoundException( + string.Format( + CultureInfo.InvariantCulture, + "No service with the name '{0}' can be found.", + name)); private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) { From a2462704d111095d57838b78694d755f298b890c Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Thu, 12 Dec 2019 17:48:41 +0100 Subject: [PATCH 36/53] Add self to Jellyfin contributors --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f22944a8b..d69e6330b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -30,6 +30,7 @@ - [Khinenw](https://github.com/HelloWorld017) - [fhriley](https://github.com/fhriley) - [nevado](https://github.com/nevado) + - [mark-monteiro](https://github.com/mark-monteiro) # Emby Contributors From 6231fc18eac67966340fddc121dc2895fd99ab5e Mon Sep 17 00:00:00 2001 From: Cromefire_ <26320625+cromefire@users.noreply.github.com> Date: Fri, 13 Dec 2019 15:27:12 +0100 Subject: [PATCH 37/53] Fixed invalid username handling --- .../Session/SessionManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index b87ca3a11..80079ae6c 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1393,6 +1393,13 @@ namespace Emby.Server.Implementations.Session } } + if (user == null) + { + AuthenticationFailed?.Invoke(this, new GenericEventArgs(request)); + + throw new SecurityException("Invalid user or password entered."); + } + if (enforcePassword) { user = await _userManager.AuthenticateUser( @@ -1403,13 +1410,6 @@ namespace Emby.Server.Implementations.Session true).ConfigureAwait(false); } - if (user == null) - { - AuthenticationFailed?.Invoke(this, new GenericEventArgs(request)); - - throw new SecurityException("Invalid user or password entered."); - } - var token = GetAuthorizationToken(user, request.DeviceId, request.App, request.AppVersion, request.DeviceName); var session = LogSessionActivity( From 7e987b9642fd1826b9adb8dc6e208454c44da4dc Mon Sep 17 00:00:00 2001 From: Cromefire_ <26320625+cromefire@users.noreply.github.com> Date: Fri, 13 Dec 2019 15:30:08 +0100 Subject: [PATCH 38/53] Remove whitespace Co-Authored-By: Claus Vium --- Emby.Server.Implementations/Session/SessionManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 80079ae6c..367e1d498 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1396,7 +1396,6 @@ namespace Emby.Server.Implementations.Session if (user == null) { AuthenticationFailed?.Invoke(this, new GenericEventArgs(request)); - throw new SecurityException("Invalid user or password entered."); } From c36467c4966b79162d11d75a7dd65f5586dfb027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93skar=20Freyr?= Date: Wed, 11 Dec 2019 00:15:47 +0000 Subject: [PATCH 39/53] Translated using Weblate (Icelandic) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/is/ --- .../Localization/Core/is.json | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/is.json b/Emby.Server.Implementations/Localization/Core/is.json index 982232afd..af0da4169 100644 --- a/Emby.Server.Implementations/Localization/Core/is.json +++ b/Emby.Server.Implementations/Localization/Core/is.json @@ -7,11 +7,11 @@ "HeaderRecordingGroups": "Upptökuhópar", "HeaderNextUp": "Næst á dagskrá", "HeaderLiveTV": "Sjónvarp í beinni útsendingu", - "HeaderFavoriteSongs": "Uppáhalds lög", - "HeaderFavoriteShows": "Uppáhalds sjónvarpsþættir", - "HeaderFavoriteEpisodes": "Uppáhalds þættir", - "HeaderFavoriteArtists": "Uppáhalds listamenn", - "HeaderFavoriteAlbums": "Uppáhalds plötur", + "HeaderFavoriteSongs": "Uppáhalds Lög", + "HeaderFavoriteShows": "Uppáhalds Sjónvarpsþættir", + "HeaderFavoriteEpisodes": "Uppáhalds Þættir", + "HeaderFavoriteArtists": "Uppáhalds Listamenn", + "HeaderFavoriteAlbums": "Uppáhalds Plötur", "HeaderContinueWatching": "Halda áfram að horfa", "HeaderCameraUploads": "Myndavéla upphal", "HeaderAlbumArtists": "Höfundur plötu", @@ -30,5 +30,37 @@ "Artists": "Listamaður", "Application": "Forrit", "AppDeviceValues": "Snjallforrit: {0}, Tæki: {1}", - "Albums": "Plötur" + "Albums": "Plötur", + "Plugin": "Viðbót", + "Photos": "Myndir", + "NotificationOptionVideoPlaybackStopped": "Myndbandafspilun stöðvuð", + "NotificationOptionVideoPlayback": "Myndbandafspilun hafin", + "NotificationOptionUserLockedOut": "Notandi læstur úti", + "NotificationOptionServerRestartRequired": "Endurræsing miðlara nauðsynileg", + "NotificationOptionPluginUpdateInstalled": "Viðbótar uppfærsla uppsett", + "NotificationOptionPluginUninstalled": "Viðbót fjarlægð", + "NotificationOptionPluginInstalled": "Viðbót settur upp", + "NotificationOptionPluginError": "Bilun í viðbót", + "NotificationOptionInstallationFailed": "Uppsetning tókst ekki", + "NotificationOptionCameraImageUploaded": "Myndavélarmynd hlaðið upp", + "NotificationOptionAudioPlaybackStopped": "Hljóðafspilun stöðvuð", + "NotificationOptionAudioPlayback": "Hljóðafspilun hafin", + "NotificationOptionApplicationUpdateInstalled": "Uppfærsla uppsett", + "NotificationOptionApplicationUpdateAvailable": "Uppfærsla í boði", + "NameSeasonUnknown": "Sería óþekkt", + "NameSeasonNumber": "Sería {0}", + "MixedContent": "Blandað efni", + "MessageServerConfigurationUpdated": "Stillingar miðlarans hefur verið uppfærð", + "MessageApplicationUpdatedTo": "Jellyfin Server hefur verið uppfærður í {0}", + "MessageApplicationUpdated": "Jellyfin Server hefur verið uppfærður", + "Latest": "Nýjasta", + "LabelRunningTimeValue": "Keyrslutími kerfis: {0}", + "User": "Notandi", + "System": "Kerfi", + "NotificationOptionNewLibraryContent": "Nýju efni bætt við", + "NewVersionIsAvailable": "Ný útgáfa af Jellyfin Server er fáanleg til niðurhals.", + "NameInstallFailed": "{0} uppsetning mistókst", + "MusicVideos": "Tónlistarmyndbönd", + "Music": "Tónlist", + "Movies": "Kvikmyndir" } From f18d3ed33be09c2b083ffe407b180861dc94ea16 Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 14 Dec 2019 11:15:30 +1030 Subject: [PATCH 40/53] Formatting fix (3) Co-Authored-By: Bond-009 --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index e3bd3c8c9..82fa0e856 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -948,7 +948,8 @@ namespace MediaBrowser.Api.Playback.Hls args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultEncoderPreset()); // Unable to force key frames to h264_qsv transcode - if (string.Equals(codec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) { + if (string.Equals(codec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) + { Logger.LogInformation("Bug Workaround: Disabling force_key_frames for h264_qsv"); } else From 867b61025d0ed4856e3795cce406961dca0f8e3d Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 14 Dec 2019 11:16:27 +1030 Subject: [PATCH 41/53] Use case insensitive contains (1) Co-Authored-By: Bond-009 --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 268895540..84050d4dc 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -473,7 +473,7 @@ namespace MediaBrowser.Controller.MediaEncoding var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions); var outputVideoCodec = GetVideoEncoder(state, encodingOptions); - if (encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv")) + if (encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv", StringComparison.OrdinalIgnoreCase)) { if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) { From 802a66a9e6e2f78967c01fcfeb8b043c6a7c6901 Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 14 Dec 2019 11:16:55 +1030 Subject: [PATCH 42/53] Use case insensitive contains (2) Co-Authored-By: Bond-009 --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 84050d4dc..8d2a59c87 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -475,7 +475,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv", StringComparison.OrdinalIgnoreCase)) { - if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase)) { arg.Append("-hwaccel qsv "); } From d0febd6c37454df614216d973f21b400923e8e70 Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 14 Dec 2019 11:17:37 +1030 Subject: [PATCH 43/53] Use case insensitive contains (3) Co-Authored-By: Bond-009 --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 8d2a59c87..678e851b7 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1619,7 +1619,7 @@ namespace MediaBrowser.Controller.MediaEncoding For software decoding and hardware encoding option, frames must be hwuploaded into hardware with fixed frame size. */ - if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) + if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase)) { retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; } From bafcadbe585f022b6463adad790831a31d60261b Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sat, 14 Dec 2019 11:18:53 +1030 Subject: [PATCH 44/53] Use case insensitive contains (4) Co-Authored-By: Bond-009 --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 678e851b7..46669f4e3 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1969,7 +1969,7 @@ namespace MediaBrowser.Controller.MediaEncoding // If we are software decoding, and hardware encoding if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) - && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv"))) + && (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase))) { filters.Add("format=nv12|qsv"); filters.Add("hwupload=extra_hw_frames=64"); From 02928128b998608e0a6fd2f8ac611be5961fa78f Mon Sep 17 00:00:00 2001 From: dkanada Date: Sat, 14 Dec 2019 11:36:06 +0900 Subject: [PATCH 45/53] track progress for any item that supports the feature --- Emby.Server.Implementations/Library/UserDataManager.cs | 8 +++----- Emby.Server.Implementations/Session/SessionManager.cs | 8 ++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index 48d33c26c..071681b08 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -226,24 +226,21 @@ namespace Emby.Server.Implementations.Library { var pctIn = decimal.Divide(positionTicks, runtimeTicks) * 100; - // Don't track in very beginning if (pctIn < _config.Configuration.MinResumePct) { + // ignore progress during the beginning positionTicks = 0; } - - // If we're at the end, assume completed else if (pctIn > _config.Configuration.MaxResumePct || positionTicks >= runtimeTicks) { + // mark as completed close to the end positionTicks = 0; data.Played = playedToCompletion = true; } - else { // Enforce MinResumeDuration var durationSeconds = TimeSpan.FromTicks(runtimeTicks).TotalSeconds; - if (durationSeconds < _config.Configuration.MinResumeDurationSeconds) { positionTicks = 0; @@ -263,6 +260,7 @@ namespace Emby.Server.Implementations.Library positionTicks = 0; data.Played = false; } + if (!item.SupportsPositionTicksResume) { positionTicks = 0; diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index b87ca3a11..34ffceebd 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -667,12 +667,9 @@ namespace Emby.Server.Implementations.Session data.PlayCount++; data.LastPlayedDate = DateTime.UtcNow; - if (item.SupportsPlayedStatus) + if (item.SupportsPlayedStatus && !item.SupportsPositionTicksResume) { - if (!(item is Video)) - { - data.Played = true; - } + data.Played = true; } else { @@ -769,7 +766,6 @@ namespace Emby.Server.Implementations.Session { _userDataManager.SaveUserData(user, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None); } - } private static bool UpdatePlaybackSettings(User user, PlaybackProgressInfo info, UserItemData data) From c824c564cdd1d59b04ae64df4400a90e2944ee8f Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Sat, 14 Dec 2019 06:45:29 +0100 Subject: [PATCH 46/53] Move Emby.XmlTv to a NuGet package (#2042) * Move Emby.XmlTv to a NuGet package * Update Emby.Server.Implementations/Emby.Server.Implementations.csproj Co-Authored-By: Anthony Lavado --- .../Emby.Server.Implementations.csproj | 2 +- .../LiveTv/Listings/XmlTvListingsProvider.cs | 4 +- Emby.XmlTv/.gitattributes | 63 - Emby.XmlTv/.gitignore | 212 ---- Emby.XmlTv/Emby.XmlTv.Console/App.config | 6 - .../Classes/EntityExtensions.cs | 58 - .../Emby.XmlTv.Console.csproj | 22 - Emby.XmlTv/Emby.XmlTv.Console/Program.cs | 103 -- .../Properties/AssemblyInfo.cs | 36 - .../Emby.XmlTv.Test/Emby.XmlTv.Test.csproj | 124 -- .../Properties/AssemblyInfo.cs | 36 - .../XmlTvReaderDateTimeTests.cs | 91 -- .../XmlTvReaderLanguageTests.cs | 181 --- .../Emby.XmlTv.Test/XmlTvReaderTests.cs | 219 ---- Emby.XmlTv/Emby.XmlTv.sln | 44 - Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs | 1107 ----------------- Emby.XmlTv/Emby.XmlTv/Emby.XmlTv.csproj | 13 - .../Emby.XmlTv/Entities/XmlTvChannel.cs | 50 - Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCredit.cs | 13 - .../Emby.XmlTv/Entities/XmlTvCreditType.cs | 17 - .../Emby.XmlTv/Entities/XmlTvEpisode.cs | 52 - Emby.XmlTv/Emby.XmlTv/Entities/XmlTvIcon.cs | 27 - .../Emby.XmlTv/Entities/XmlTvLanguage.cs | 15 - .../Emby.XmlTv/Entities/XmlTvPremiere.cs | 13 - .../Emby.XmlTv/Entities/XmlTvProgram.cs | 93 -- Emby.XmlTv/Emby.XmlTv/Entities/XmlTvRating.cs | 40 - .../Emby.XmlTv/Properties/AssemblyInfo.cs | 21 - Emby.XmlTv/Emby.XmlTv/XmlTvSchema.dtd | 575 --------- Emby.XmlTv/License.txt | 21 - Emby.XmlTv/Nuget/Emby.XmlTv.nuspec | 20 - Emby.XmlTv/README.md | 1 - MediaBrowser.sln | 6 - 32 files changed, 3 insertions(+), 3282 deletions(-) delete mode 100644 Emby.XmlTv/.gitattributes delete mode 100644 Emby.XmlTv/.gitignore delete mode 100644 Emby.XmlTv/Emby.XmlTv.Console/App.config delete mode 100644 Emby.XmlTv/Emby.XmlTv.Console/Classes/EntityExtensions.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.Console/Emby.XmlTv.Console.csproj delete mode 100644 Emby.XmlTv/Emby.XmlTv.Console/Program.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.Console/Properties/AssemblyInfo.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.Test/Emby.XmlTv.Test.csproj delete mode 100644 Emby.XmlTv/Emby.XmlTv.Test/Properties/AssemblyInfo.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderDateTimeTests.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderLanguageTests.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderTests.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv.sln delete mode 100644 Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Emby.XmlTv.csproj delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvChannel.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCredit.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCreditType.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvEpisode.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvIcon.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvLanguage.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvPremiere.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvProgram.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Entities/XmlTvRating.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/Properties/AssemblyInfo.cs delete mode 100644 Emby.XmlTv/Emby.XmlTv/XmlTvSchema.dtd delete mode 100644 Emby.XmlTv/License.txt delete mode 100644 Emby.XmlTv/Nuget/Emby.XmlTv.nuspec delete mode 100644 Emby.XmlTv/README.md diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index fde4d7059..4b6ba1fab 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -15,12 +15,12 @@ - + diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 88693f22a..1f38de2d8 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -7,8 +7,8 @@ using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using Emby.XmlTv.Classes; -using Emby.XmlTv.Entities; +using Jellyfin.XmlTv; +using Jellyfin.XmlTv.Entities; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; diff --git a/Emby.XmlTv/.gitattributes b/Emby.XmlTv/.gitattributes deleted file mode 100644 index 1ff0c4230..000000000 --- a/Emby.XmlTv/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/Emby.XmlTv/.gitignore b/Emby.XmlTv/.gitignore deleted file mode 100644 index b06e864a3..000000000 --- a/Emby.XmlTv/.gitignore +++ /dev/null @@ -1,212 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Visual Studio 2015 cache/options directory -.vs/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -## TODO: Comment the next line if you want to checkin your -## web deploy settings but do note that will include unencrypted -## passwords -#*.pubxml - -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml diff --git a/Emby.XmlTv/Emby.XmlTv.Console/App.config b/Emby.XmlTv/Emby.XmlTv.Console/App.config deleted file mode 100644 index 2d2a12d81..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Console/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Emby.XmlTv/Emby.XmlTv.Console/Classes/EntityExtensions.cs b/Emby.XmlTv/Emby.XmlTv.Console/Classes/EntityExtensions.cs deleted file mode 100644 index 96e508f12..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Console/Classes/EntityExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Linq; -using System.Text; - -using Emby.XmlTv.Entities; - -namespace Emby.XmlTv.Console.Classes -{ - public static class EntityExtensions - { - public static string GetHeader(this string text) - { - var channelHeaderString = " " + text; - - var builder = new StringBuilder(); - builder.AppendLine("".PadRight(5 + channelHeaderString.Length + 5, Char.Parse("*"))); - builder.AppendLine("".PadRight(5, Char.Parse("*")) + channelHeaderString + "".PadRight(5, Char.Parse("*"))); - builder.AppendLine("".PadRight(5 + channelHeaderString.Length + 5, Char.Parse("*"))); - - return builder.ToString(); - } - - public static string GetChannelDetail(this XmlTvChannel channel) - { - var builder = new StringBuilder(); - builder.AppendFormat("Id: {0}\r\n", channel.Id); - builder.AppendFormat("Display-Name: {0}\r\n", channel.DisplayName); - builder.AppendFormat("Url: {0}\r\n", channel.Url); - builder.AppendFormat("Icon: {0}\r\n", channel.Icon != null ? channel.Icon.ToString() : string.Empty); - builder.AppendLine("-------------------------------------------------------"); - - return builder.ToString(); - } - - public static string GetProgrammeDetail(this XmlTvProgram programme, XmlTvChannel channel) - { - var builder = new StringBuilder(); - builder.AppendFormat("Channel: {0} - {1}\r\n", channel.Id, channel.DisplayName); - builder.AppendFormat("Start Date: {0:G}\r\n", programme.StartDate); - builder.AppendFormat("End Date: {0:G}\r\n", programme.EndDate); - builder.AppendFormat("Name: {0}\r\n", programme.Title); - builder.AppendFormat("Episode Detail: {0}\r\n", programme.Episode); - builder.AppendFormat("Episode Title: {0}\r\n", programme.Episode.Title); - builder.AppendFormat("Description: {0}\r\n", programme.Description); - builder.AppendFormat("Categories: {0}\r\n", string.Join(", ", programme.Categories)); - builder.AppendFormat("Countries: {0}\r\n", string.Join(", ", programme.Countries)); - builder.AppendFormat("Credits: {0}\r\n", string.Join(", ", programme.Credits)); - builder.AppendFormat("Rating: {0}\r\n", programme.Rating); - builder.AppendFormat("Star Rating: {0}\r\n", programme.StarRating.HasValue ? programme.StarRating.Value.ToString() : string.Empty); - builder.AppendFormat("Previously Shown: {0:G}\r\n", programme.PreviouslyShown); - builder.AppendFormat("Copyright Date: {0:G}\r\n", programme.CopyrightDate); - builder.AppendFormat("Is Repeat: {0}\r\n", programme.IsPreviouslyShown); - builder.AppendFormat("Icon: {0}\r\n", programme.Icon != null ? programme.Icon.ToString() : string.Empty); - builder.AppendLine("-------------------------------------------------------"); - return builder.ToString(); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv.Console/Emby.XmlTv.Console.csproj b/Emby.XmlTv/Emby.XmlTv.Console/Emby.XmlTv.Console.csproj deleted file mode 100644 index c10b28e82..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Console/Emby.XmlTv.Console.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - {0d023565-5942-4d79-9098-a1b4b6665a40} - Emby.XmlTv - - - - netcoreapp2.1 - false - - - diff --git a/Emby.XmlTv/Emby.XmlTv.Console/Program.cs b/Emby.XmlTv/Emby.XmlTv.Console/Program.cs deleted file mode 100644 index 3e0c7d125..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Console/Program.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -using Emby.XmlTv.Classes; -using Emby.XmlTv.Console.Classes; -using Emby.XmlTv.Entities; - -namespace Emby.XmlTv.Console -{ - public class Program - { - static void Main(string[] args) - { - var filename = @"C:\Temp\QLD.GoldCoast.xml"; - - if (args.Length == 1 && File.Exists(args[0])) - { - filename = args[0]; - } - - var timer = Stopwatch.StartNew(); - System.Console.WriteLine("Running XMLTv Parsing"); - - var resultsFile = String.Format("C:\\Temp\\{0}_Results_{1:HHmmss}.txt", - Path.GetFileNameWithoutExtension(filename), - DateTimeOffset.UtcNow); - - System.Console.Write("Enter the language required: "); - var lang = System.Console.ReadLine(); - - ReadSourceXmlTvFile(filename, resultsFile, lang).Wait(); - - System.Console.WriteLine("Completed in {0:g} - press any key to open the file...", timer.Elapsed); - System.Console.ReadKey(); - - Process.Start(resultsFile); - } - - public static async Task ReadSourceXmlTvFile(string filename, string resultsFile, string lang) - { - System.Console.WriteLine("Writing to file: {0}", resultsFile); - - using (var resultsFileStream = new StreamWriter(resultsFile) { AutoFlush = true }) - { - var reader = new XmlTvReader(filename, lang); - await ReadOutChannels(reader, resultsFileStream); - - resultsFileStream.Close(); - } - } - - public static async Task ReadOutChannels(XmlTvReader reader, StreamWriter resultsFileStream) - { - var channels = reader.GetChannels().Distinct().ToList(); - - resultsFileStream.Write(EntityExtensions.GetHeader("Channels")); - - foreach (var channel in channels) - { - System.Console.WriteLine("Retrieved Channel: {0} - {1}", channel.Id, channel.DisplayName); - resultsFileStream.Write(channel.GetChannelDetail()); - } - - var totalProgrammeCount = 0; - - resultsFileStream.Write("\r\n"); - foreach (var channel in channels) - { - System.Console.WriteLine("Processing Channel: {0}", channel.DisplayName); - - resultsFileStream.Write(EntityExtensions.GetHeader("Programs for " + channel.DisplayName)); - var channelProgrammeCount = await ReadOutChannelProgrammes(reader, channel, resultsFileStream); - - totalProgrammeCount += channelProgrammeCount; - await resultsFileStream.WriteLineAsync(String.Format("Total Programmes for {1}: {0}", channelProgrammeCount, channel.DisplayName)); - } - - await resultsFileStream.WriteLineAsync(String.Format("Total Programmes: {0}", totalProgrammeCount)); - } - - private static async Task ReadOutChannelProgrammes(XmlTvReader reader, XmlTvChannel channel, StreamWriter resultsFileStream) - { - //var startDate = new DateTime(2015, 11, 28); - //var endDate = new DateTime(2015, 11, 29); - var startDate = DateTimeOffset.MinValue; - var endDate = DateTimeOffset.MaxValue; - - var count = 0; - - foreach (var programme in reader.GetProgrammes(channel.Id, startDate, endDate, new CancellationToken()).Distinct()) - { - count++; - await resultsFileStream.WriteLineAsync(programme.GetProgrammeDetail(channel)); - } - - return count; - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv.Console/Properties/AssemblyInfo.cs b/Emby.XmlTv/Emby.XmlTv.Console/Properties/AssemblyInfo.cs deleted file mode 100644 index ff59f890f..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Console/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Emby.XmlTv.Console")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.XmlTv.Console")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("add1d993-6d74-480a-b1fc-7fd9fd05a769")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Emby.XmlTv/Emby.XmlTv.Test/Emby.XmlTv.Test.csproj b/Emby.XmlTv/Emby.XmlTv.Test/Emby.XmlTv.Test.csproj deleted file mode 100644 index d7c4ad0b7..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Test/Emby.XmlTv.Test.csproj +++ /dev/null @@ -1,124 +0,0 @@ - - - - Debug - AnyCPU - {C8298223-2468-466C-9B06-FBF61926CECB} - Library - Properties - Emby.XmlTv.Test - Emby.XmlTv.Test - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - False - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - Designer - - - - - {0D023565-5942-4D79-9098-A1B4B6665A40} - Emby.XmlTv - - - - - - - False - - - False - - - False - - - False - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - netstandard2.0 - false - - diff --git a/Emby.XmlTv/Emby.XmlTv.Test/Properties/AssemblyInfo.cs b/Emby.XmlTv/Emby.XmlTv.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index 902860363..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Emby.XmlTv.Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.XmlTv.Test")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c8298223-2468-466c-9b06-fbf61926cecb")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderDateTimeTests.cs b/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderDateTimeTests.cs deleted file mode 100644 index 857cc339c..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderDateTimeTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.IO; - -using Emby.XmlTv.Classes; - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Emby.XmlTv.Test -{ - [TestClass] - public class XmlTvReaderDateTimeTests - { - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_HandlePartDates() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); - - Assert.AreEqual(Parse("01 Jan 2016 00:00:00"), reader.ParseDate("2016")); - Assert.AreEqual(Parse("01 Jan 2016 00:00:00"), reader.ParseDate("201601")); - Assert.AreEqual(Parse("01 Jan 2016 00:00:00"), reader.ParseDate("20160101")); - Assert.AreEqual(Parse("01 Jan 2016 12:00:00"), reader.ParseDate("2016010112")); - Assert.AreEqual(Parse("01 Jan 2016 12:34:00"), reader.ParseDate("201601011234")); - Assert.AreEqual(Parse("01 Jan 2016 12:34:56"), reader.ParseDate("20160101123456")); - } - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_HandleDateWithOffset() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); - - // parse variations on 1:00AM - Assert.AreEqual(Parse("01 Jan 2016 12:00:00"), reader.ParseDate("20160101120000 +0000")); - Assert.AreEqual(Parse("01 Jan 2016 02:00:00"), reader.ParseDate("20160101120000 +1000")); - Assert.AreEqual(Parse("01 Jan 2016 11:00:00"), reader.ParseDate("20160101120000 +0100")); - Assert.AreEqual(Parse("01 Jan 2016 11:50:00"), reader.ParseDate("20160101120000 +0010")); - Assert.AreEqual(Parse("01 Jan 2016 11:59:00"), reader.ParseDate("20160101120000 +0001")); - - Assert.AreEqual(Parse("01 Jan 2016 22:00:00"), reader.ParseDate("20160101120000 -1000")); - Assert.AreEqual(Parse("01 Jan 2016 13:00:00"), reader.ParseDate("20160101120000 -0100")); - Assert.AreEqual(Parse("01 Jan 2016 12:10:00"), reader.ParseDate("20160101120000 -0010")); - Assert.AreEqual(Parse("01 Jan 2016 12:01:00"), reader.ParseDate("20160101120000 -0001")); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_HandlePartDatesWithOffset() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); - - Assert.AreEqual(Parse("01 Jan 2016 01:00:00"), reader.ParseDate("2016 -0100")); - Assert.AreEqual(Parse("01 Jan 2016 01:00:00"), reader.ParseDate("201601 -0100")); - Assert.AreEqual(Parse("01 Jan 2016 01:00:00"), reader.ParseDate("20160101 -0100")); - Assert.AreEqual(Parse("01 Jan 2016 13:00:00"), reader.ParseDate("2016010112 -0100")); - Assert.AreEqual(Parse("01 Jan 2016 13:00:00"), reader.ParseDate("201601011200 -0100")); - Assert.AreEqual(Parse("01 Jan 2016 13:00:00"), reader.ParseDate("20160101120000 -0100")); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_HandleSpaces() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); - - // parse variations on 1:00AM - Assert.AreEqual(Parse("01 Jan 2016 12:00:00"), reader.ParseDate("20160101120000 +000")); - Assert.AreEqual(Parse("01 Jan 2016 12:00:00"), reader.ParseDate("20160101120000 +00")); - Assert.AreEqual(Parse("01 Jan 2016 12:00:00"), reader.ParseDate("20160101120000 +0")); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_HandleSpaces2() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); - - // parse variations on 1:00AM - Assert.AreEqual(Parse("01 Jan 2016 12:00:00"), reader.ParseDate("20160101120000 0")); - } - - private DateTimeOffset Parse(string value) - { - return new DateTimeOffset(DateTimeOffset.Parse(value).Ticks, TimeSpan.Zero); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderLanguageTests.cs b/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderLanguageTests.cs deleted file mode 100644 index 32a0431d2..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderLanguageTests.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; - -using Emby.XmlTv.Classes; - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Emby.XmlTv.Test -{ - [TestClass] - public class XmlTvReaderLanguageTests - { - /* Homes Under the Hammer - Spanish - * Homes Under the Hammer - Spanish 2 - * Homes Under the Hammer - English - * Homes Under the Hammer - English 2 - * Homes Under the Hammer - Empty Language - * Homes Under the Hammer - Empty Language 2 - * Homes Under the Hammer - No Language - * Homes Under the Hammer - No Language 2 - */ - - /* Expected Behaviour: - * - Language = Null Homes Under the Hammer - No Language - * - Language = "" Homes Under the Hammer - No Language - * - Language = es Homes Under the Hammer - Spanish - * - Language = en Homes Under the Hammer - English - */ - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_The_First_Matching_Language_ES() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); - var channel = reader.GetChannels().FirstOrDefault(); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).FirstOrDefault(); - - Assert.IsNotNull(programme); - Assert.AreEqual("Homes Under the Hammer - Spanish", programme.Title); - Assert.AreEqual(1, programme.Categories.Count); - Assert.AreEqual("Property - Spanish", programme.Categories[0]); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_The_First_Matching_Language_EN() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "en"); - - var channel = reader.GetChannels().FirstOrDefault(); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).FirstOrDefault(); - - Assert.IsNotNull(programme); - Assert.AreEqual("Homes Under the Hammer - English", programme.Title); - Assert.AreEqual(1, programme.Categories.Count); - Assert.AreEqual("Property - English", programme.Categories[0]); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_The_First_Matching_With_No_Language() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, null); - - var channel = reader.GetChannels().FirstOrDefault(); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).FirstOrDefault(); - - Assert.IsNotNull(programme); - Assert.AreEqual("Homes Under the Hammer - No Language", programme.Title); - Assert.AreEqual(1, programme.Categories.Count); - Assert.AreEqual("Property - No Language", programme.Categories[0]); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_The_First_Matching_With_Empty_Language() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, String.Empty); - - var channel = reader.GetChannels().FirstOrDefault(); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).FirstOrDefault(); - - Assert.IsNotNull(programme); - Assert.AreEqual("Homes Under the Hammer - Empty Language", programme.Title); - Assert.AreEqual(1, programme.Categories.Count); - Assert.AreEqual("Property - Empty Language", programme.Categories[0]); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_The_First_When_NoMatchFound() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); // There are no titles or categories for spanish - - var channel = reader.GetChannels().FirstOrDefault(); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).Skip(1).FirstOrDefault(); - - Assert.IsNotNull(programme); - Assert.AreEqual("Homes Under the Hammer - English", programme.Title); - - // Should return all categories - Assert.AreEqual(2, programme.Categories.Count); - Assert.IsTrue(programme.Categories.Contains("Property - English")); - Assert.IsTrue(programme.Categories.Contains("Property - Empty Language")); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_The_First_When_NoLanguage() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile, null); - - var channel = reader.GetChannels().FirstOrDefault(); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).Skip(1).FirstOrDefault(); - - Assert.IsNotNull(programme); - Assert.AreEqual("Homes Under the Hammer - English", programme.Title); // Should return the first in the list - - // Should return all categories - Assert.AreEqual(2, programme.Categories.Count); - Assert.IsTrue(programme.Categories.Contains("Property - English")); - Assert.IsTrue(programme.Categories.Contains("Property - Empty Language")); - } - - [TestMethod] - [DeploymentItem("Xml Files\\MultilanguageData.xml")] - public void Should_Return_All_Languages() - { - var testFile = Path.GetFullPath(@"MultilanguageData.xml"); - var reader = new XmlTvReader(testFile); - var cancellationToken = new CancellationToken(); - - var results = reader.GetLanguages(cancellationToken); - Assert.IsNotNull(results); - - foreach (var result in results) - { - Console.WriteLine("{0} - {1}", result.Name, result.Relevance); - } - - Assert.AreEqual(2, results.Count); - Assert.AreEqual("en", results[0].Name); - Assert.AreEqual(11, results[0].Relevance); - Assert.AreEqual("es", results[1].Name); - Assert.AreEqual(3, results[1].Relevance); - } - - } -} diff --git a/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderTests.cs b/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderTests.cs deleted file mode 100644 index b1dffc59c..000000000 --- a/Emby.XmlTv/Emby.XmlTv.Test/XmlTvReaderTests.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; - -using Emby.XmlTv.Classes; - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Emby.XmlTv.Test -{ - [TestClass] - public class XmlTvReaderTests - { - [TestMethod] - [DeploymentItem("Xml Files\\UK_Data.xml")] - public void UK_DataTest_ChannelsTest() - { - var testFile = Path.GetFullPath(@"UK_Data.xml"); - var reader = new XmlTvReader(testFile); - - var channels = reader.GetChannels().ToList(); - Assert.AreEqual(5, channels.Count); - - // Check each channel - var channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2667"); - Assert.IsNotNull(channel); - Assert.AreEqual("BBC1 HD", channel.DisplayName); - Assert.AreEqual("7.1", channel.Number); - Assert.IsNotNull(channel.Icon); - Assert.AreEqual("Logo_UK_RT_2667", channel.Icon.Source); - Assert.AreEqual(100, channel.Icon.Width); - Assert.AreEqual(200, channel.Icon.Height); - - channel = channels.SingleOrDefault(c => c.Id == "UK_RT_105"); - Assert.IsNotNull(channel); - Assert.AreEqual("BBC2", channel.DisplayName); - Assert.IsNotNull(channel.Icon); - Assert.AreEqual("Logo_UK_RT_105", channel.Icon.Source); - Assert.IsFalse(channel.Icon.Width.HasValue); - Assert.IsFalse(channel.Icon.Height.HasValue); - - channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2118"); - Assert.IsNotNull(channel); - Assert.AreEqual("ITV1 HD", channel.DisplayName); - Assert.IsNotNull(channel.Icon); - Assert.AreEqual("Logo_UK_RT_2118", channel.Icon.Source); - Assert.AreEqual(100, channel.Icon.Width); - Assert.IsFalse(channel.Icon.Height.HasValue); - - channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2056"); - Assert.IsNotNull(channel); - Assert.AreEqual("Channel 4 HD", channel.DisplayName); - Assert.IsNotNull(channel.Icon); - Assert.AreEqual("Logo_UK_RT_2056", channel.Icon.Source); - Assert.IsFalse(channel.Icon.Width.HasValue); - Assert.AreEqual(200, channel.Icon.Height); - - channel = channels.SingleOrDefault(c => c.Id == "UK_RT_134"); - Assert.IsNotNull(channel); - Assert.AreEqual("Channel 5", channel.DisplayName); - Assert.IsNull(channel.Icon); - } - - [TestMethod] - [DeploymentItem("Xml Files\\UK_Data.xml")] - public void UK_DataTest_GeneralTest() - { - var testFile = Path.GetFullPath(@"UK_Data.xml"); - var reader = new XmlTvReader(testFile, null); - - var channels = reader.GetChannels().ToList(); - Assert.AreEqual(5, channels.Count); - - // Pick a channel to check the data for - var channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2056"); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programmes = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).ToList(); - - Assert.AreEqual(27, programmes.Count); - var programme = programmes.SingleOrDefault(p => p.Title == "The Secret Life of"); - - Assert.IsNotNull(programme); - Assert.AreEqual(new DateTime(2015, 11, 26, 20, 0, 0), programme.StartDate); - Assert.AreEqual(new DateTime(2015, 11, 26, 21, 0, 0), programme.EndDate); - Assert.AreEqual("Cameras follow the youngsters' development after two weeks apart and time has made the heart grow fonder for Alfie and Emily, who are clearly happy to be back together. And although Alfie struggled to empathise with the rest of his peers before, a painting competition proves to be a turning point for him. George takes the children's rejection of his family recipe to heart, but goes on to triumph elsewhere, and romance is in the air when newcomer Sienna captures Arthur's heart.", programme.Description); - Assert.AreEqual("Documentary", programme.Categories.Single()); - Assert.IsNotNull(programme.Episode); - Assert.AreEqual("The Secret Life of 5 Year Olds", programme.Episode.Title); - Assert.AreEqual(1, programme.Episode.Series); - Assert.IsNull(programme.Episode.SeriesCount); - Assert.AreEqual(4, programme.Episode.Episode); - Assert.AreEqual(6, programme.Episode.EpisodeCount); - Assert.IsNotNull(programme.Premiere); - //Assert.AreEqual("First showing on national terrestrial TV", programme.Premiere.Details); - Assert.IsTrue(programme.IsNew); - } - - [TestMethod] - [DeploymentItem("Xml Files\\UK_Data.xml")] - public void UK_DataTest_MultipleTitles_SameLanguage_Should_ReturnFirstValue() - { - var testFile = Path.GetFullPath(@"UK_Data.xml"); - var reader = new XmlTvReader(testFile, null); - - /* - Homes Under the Hammer - Title 1 - Homes Under the Hammer - Title 2 - Homes Under the Hammer - Title 3 - */ - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programmes = reader.GetProgrammes("UK_RT_2667", startDate, startDate.AddDays(1), cancellationToken).ToList(); - var programme = programmes.SingleOrDefault(p => p.Title == "Homes Under the Hammer - Title 1"); - - Assert.IsNotNull(programme); - } - - [TestMethod] - [DeploymentItem("Xml Files\\UK_Data.xml")] - public void UK_DataTest_MultipleTitles_NoLanguage_Should_ReturnFirstValue() - { - var testFile = Path.GetFullPath(@"UK_Data.xml"); - var reader = new XmlTvReader(testFile, null); - - /* - Oxford Street Revealed - Title 1 - Oxford Street Revealed - Title 2 - Oxford Street Revealed - Title 3 - */ - - var startDate = new DateTime(2015, 11, 26); - var cancellationToken = new CancellationToken(); - var programmes = reader.GetProgrammes("UK_RT_2667", startDate, startDate.AddDays(1), cancellationToken).ToList(); - var programme = programmes.SingleOrDefault(p => p.Title == "Oxford Street Revealed - Title 1"); - - Assert.IsNotNull(programme); - } - - [TestMethod] - [DeploymentItem("Xml Files\\ES_MultiLanguageData.xml")] - public void ES_MultiLanguageDataTest() - { - var testFile = Path.GetFullPath(@"ES_MultiLanguageData.xml"); - var reader = new XmlTvReader(testFile, "es"); // Specify the spanish language explicitly - - var channels = reader.GetChannels().ToList(); - Assert.AreEqual(141, channels.Count); - - // Pick a channel to check the data for - var channel = channels.SingleOrDefault(c => c.Id == "Canal + HD" && c.DisplayName == "Canal + HD"); - Assert.IsNotNull(channel); - - var startDate = new DateTime(2016, 02, 18); - var cancellationToken = new CancellationToken(); - var programmes = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).ToList(); - - Assert.AreEqual(22, programmes.Count); - var programme = programmes.SingleOrDefault(p => p.Title == "This is Comedy. Judd Apatow & Co."); - - /* - - This is Comedy. Judd Apatow & Co. - This is Comedy - El resurgir creativo de la comedia estadounidense en los últimos 15 años ha tenido un nombre indiscutible, Judd Apatow, y unos colaboradores indispensables, sus amigos (actores, cómicos, escritores) Jonah Hill, Steve Carrell, Paul Rudd, Seth Rogen, Lena Dunham... A través de extractos de sus filmes y de entrevistas a algunos los miembros de su 'banda' (Adam Sandler, Lena Dunham o Jason Segel), este documental muestra la carrera de un productor y director excepcional que ha sido capaz de llevar la risa a su máxima expresión - - Jacky Goldberg - - 2014 - Documentales - Sociedad - - Francia - - TV-G - - - 3/5 - - - */ - - Assert.IsNotNull(programme); - Assert.AreEqual(new DateTime(2016, 02, 18, 4, 51, 0), programme.StartDate); - Assert.AreEqual(new DateTime(2016, 02, 18, 5, 54, 0), programme.EndDate); - Assert.AreEqual("El resurgir creativo de la comedia estadounidense en los últimos 15 años ha tenido un nombre indiscutible, Judd Apatow, y unos colaboradores indispensables, sus amigos (actores, cómicos, escritores) Jonah Hill, Steve Carrell, Paul Rudd, Seth Rogen, Lena Dunham... A través de extractos de sus filmes y de entrevistas a algunos los miembros de su 'banda' (Adam Sandler, Lena Dunham o Jason Segel), este documental muestra la carrera de un productor y director excepcional que ha sido capaz de llevar la risa a su máxima expresión", programme.Description); - Assert.AreEqual(2, programme.Categories.Count); - Assert.AreEqual("Documentales", programme.Categories[0]); - Assert.AreEqual("Sociedad", programme.Categories[1]); - Assert.IsNotNull(programme.Episode); - Assert.IsNull(programme.Episode.Episode); - Assert.IsNull(programme.Episode.EpisodeCount); - Assert.IsNull(programme.Episode.Part); - Assert.IsNull(programme.Episode.PartCount); - Assert.IsNull(programme.Episode.Series); - Assert.IsNull(programme.Episode.SeriesCount); - Assert.IsNull(programme.Episode.Title); - } - - [TestMethod] - [DeploymentItem("Xml Files\\honeybee.xml")] - public void HoneybeeTest() - { - var testFile = Path.GetFullPath(@"honeybee.xml"); - var reader = new XmlTvReader(testFile, null); - - var channels = reader.GetChannels().ToList(); - Assert.AreEqual(16, channels.Count); - - var programs = reader.GetProgrammes("2013.honeybee.it", DateTime.UtcNow.AddYears(-1), - DateTime.UtcNow.AddYears(1), CancellationToken.None).ToList(); - Assert.AreEqual(297, programs.Count); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv.sln b/Emby.XmlTv/Emby.XmlTv.sln deleted file mode 100644 index 8243d4b72..000000000 --- a/Emby.XmlTv/Emby.XmlTv.sln +++ /dev/null @@ -1,44 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.XmlTv.Console", "Emby.XmlTv.Console\Emby.XmlTv.Console.csproj", "{ADD1D993-6D74-480A-B1FC-7FD9FD05A769}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.XmlTv", "Emby.XmlTv\Emby.XmlTv.csproj", "{0D023565-5942-4D79-9098-A1B4B6665A40}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{BB0FD191-A9D0-4CC9-A79E-ECBCF1275268}" - ProjectSection(SolutionItems) = preProject - .nuget\NuGet.Config = .nuget\NuGet.Config - .nuget\NuGet.exe = .nuget\NuGet.exe - .nuget\NuGet.targets = .nuget\NuGet.targets - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{E9F625D5-979E-48E8-9987-F4BCADD79A41}" - ProjectSection(SolutionItems) = preProject - Nuget\Emby.XmlTv.nuspec = Nuget\Emby.XmlTv.nuspec - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ADD1D993-6D74-480A-B1FC-7FD9FD05A769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ADD1D993-6D74-480A-B1FC-7FD9FD05A769}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ADD1D993-6D74-480A-B1FC-7FD9FD05A769}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ADD1D993-6D74-480A-B1FC-7FD9FD05A769}.Release|Any CPU.Build.0 = Release|Any CPU - {0D023565-5942-4D79-9098-A1B4B6665A40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0D023565-5942-4D79-9098-A1B4B6665A40}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0D023565-5942-4D79-9098-A1B4B6665A40}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0D023565-5942-4D79-9098-A1B4B6665A40}.Release|Any CPU.Build.0 = Release|Any CPU - {C8298223-2468-466C-9B06-FBF61926CECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C8298223-2468-466C-9B06-FBF61926CECB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C8298223-2468-466C-9B06-FBF61926CECB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C8298223-2468-466C-9B06-FBF61926CECB}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs deleted file mode 100644 index 46bf6cc21..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs +++ /dev/null @@ -1,1107 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading; -using System.Xml; -using Emby.XmlTv.Entities; - -namespace Emby.XmlTv.Classes -{ - // Reads an XmlTv file - public class XmlTvReader - { - private readonly string _fileName; - private readonly string _language; - - /// - /// Initializes a new instance of the class. - /// - /// Name of the file. - /// The specific language to return. - public XmlTvReader(string fileName, string language = null) - { - _fileName = fileName; - - // Normalize null/string.empty - if (string.IsNullOrWhiteSpace(language)) - { - language = null; - } - _language = language; - } - - private static XmlReader CreateXmlTextReader(string path) - { - var settings = new XmlReaderSettings(); - - // https://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.xmlresolver(v=vs.110).aspx - // Looks like we don't need this anyway? - // Starting with the .NET Framework 4.5.2, this setting has a default value of null. - //settings.XmlResolver = null; - - settings.DtdProcessing = DtdProcessing.Ignore; - - settings.CheckCharacters = false; - settings.IgnoreProcessingInstructions = true; - settings.IgnoreComments = true; - //settings.ValidationType = ValidationType.None; - - return XmlReader.Create(path, settings); - } - - /// - /// Gets the list of channels present in the XML - /// - /// - public IEnumerable GetChannels() - { - var list = new List(); - - using (var reader = CreateXmlTextReader(_fileName)) - { - if (reader.ReadToDescendant("tv")) - { - if (reader.ReadToDescendant("channel")) - { - do - { - var channel = GetChannel(reader); - if (channel != null) - { - list.Add(channel); - } - } - while (reader.ReadToFollowing("channel")); - } - } - } - - return list; - } - - private XmlTvChannel GetChannel(XmlReader reader) - { - var id = reader.GetAttribute("id"); - - if (string.IsNullOrEmpty(id)) - { - // LogError("No id found for channel row"); - // Log.Error(" channel#{0} doesnt contain an id", iChannel); - return null; - } - - var result = new XmlTvChannel() { Id = id }; - - using (var xmlChannel = reader.ReadSubtree()) - { - xmlChannel.MoveToContent(); - xmlChannel.Read(); - - // Read out the data for each node and process individually - while (!xmlChannel.EOF && xmlChannel.ReadState == ReadState.Interactive) - { - if (xmlChannel.NodeType == XmlNodeType.Element) - { - switch (xmlChannel.Name) - { - case "display-name": - ProcessNode(xmlChannel, s => result.DisplayName = s, _language, s => SetChannelNumber(result, s)); - break; - case "url": - result.Url = xmlChannel.ReadElementContentAsString(); - break; - case "icon": - result.Icon = ProcessIconNode(xmlChannel); - xmlChannel.Skip(); - break; - default: - xmlChannel.Skip(); // unknown, skip entire node - break; - } - } - else - { - xmlChannel.Read(); - } - } - } - - if (string.IsNullOrEmpty(result.DisplayName)) - { - // LogError("No display-name found for channel {0}", id); - return null; - } - - return result; - } - - private void SetChannelNumber(XmlTvChannel channel, string value) - { - value = value.Replace("-", "."); - if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var number)) - { - channel.Number = value; - } - } - - /// - /// Gets the programmes for a specified channel - /// - /// The channel id. - /// The UTC start date. - /// The UTC end date. - /// A cancellation token. - /// - public IEnumerable GetProgrammes( - string channelId, - DateTimeOffset startDateUtc, - DateTimeOffset endDateUtc, - CancellationToken cancellationToken) - { - var list = new List(); - - using (var reader = CreateXmlTextReader(_fileName)) - { - if (reader.ReadToDescendant("tv")) - { - if (reader.ReadToDescendant("programme")) - { - do - { - if (cancellationToken.IsCancellationRequested) - { - continue; // Break out - } - - var programme = GetProgramme(reader, channelId, startDateUtc, endDateUtc); - if (programme != null) - { - list.Add(programme); - } - } - while (reader.ReadToFollowing("programme")); - } - } - } - - return list; - } - - public XmlTvProgram GetProgramme(XmlReader reader, string channelId, DateTimeOffset startDateUtc, DateTimeOffset endDateUtc) - { - var result = new XmlTvProgram(); - - PopulateHeader(reader, result); - - using (var xmlProg = reader.ReadSubtree()) - { - // First up, validate that this is the correct channel, and programme is within the time we are expecting - if (!string.Equals(result.ChannelId, channelId, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - - if (result.EndDate < startDateUtc || result.StartDate >= endDateUtc) - { - return null; - } - - xmlProg.MoveToContent(); - xmlProg.Read(); - - // Loop through each element - while (!xmlProg.EOF && xmlProg.ReadState == ReadState.Interactive) - { - if (xmlProg.NodeType == XmlNodeType.Element) - { - switch (xmlProg.Name) - { - case "title": - ProcessTitleNode(xmlProg, result); - break; - case "category": - ProcessCategory(xmlProg, result); - break; - case "country": - ProcessCountry(xmlProg, result); - break; - case "desc": - ProcessDescription(xmlProg, result); - break; - case "sub-title": - ProcessSubTitle(xmlProg, result); - break; - case "new": - ProcessNew(xmlProg, result); - break; - case "previously-shown": - ProcessPreviouslyShown(xmlProg, result); - break; - case "quality": - ProcessQuality(xmlProg, result); - break; - case "episode-num": - ProcessEpisodeNum(xmlProg, result); - break; - case "date": // Copyright date - ProcessCopyrightDate(xmlProg, result); - break; - case "star-rating": // Community Rating - ProcessStarRating(xmlProg, result); - break; - case "rating": // Certification Rating - ProcessRating(xmlProg, result); - break; - case "credits": - if (xmlProg.IsEmptyElement) - { - xmlProg.Skip(); - } - else - { - using (var subtree = xmlProg.ReadSubtree()) - { - ProcessCredits(subtree, result); - } - } - break; - case "icon": - result.Icon = ProcessIconNode(xmlProg); - xmlProg.Skip(); - break; - case "premiere": - result.Premiere = new XmlTvPremiere(); - // This was causing data after the premiere node to not be read. Reactivate this and debug if the premiere details are ever needed. - //ProcessPremiereNode(xmlProg, result); - xmlProg.Skip(); - break; - default: - // unknown, skip entire node - xmlProg.Skip(); - break; - } - } - else - { - xmlProg.Read(); - } - } - } - return result; - } - - /// - /// Gets the list of supported languages in the XML - /// - /// - public List GetLanguages(CancellationToken cancellationToken) - { - var results = new Dictionary(); - - //Loop through and parse out all elements and then lang= attributes - //logger.LogInformation("Loading file {0}", _fileName); - using (var reader = CreateXmlTextReader(_fileName)) - { - while (reader.Read()) - { - if (cancellationToken.IsCancellationRequested) - { - continue; // Break out - } - - if (reader.NodeType == XmlNodeType.Element) - { - var language = reader.GetAttribute("lang"); - if (!string.IsNullOrEmpty(language)) - { - if (!results.ContainsKey(language)) - { - results[language] = 0; - } - results[language]++; - } - } - } - } - - return - results.Keys.Select(k => new XmlTvLanguage() { Name = k, Relevance = results[k] }) - .OrderByDescending(l => l.Relevance) - .ToList(); - } - - private void ProcessCopyrightDate(XmlReader xmlProg, XmlTvProgram result) - { - var startValue = xmlProg.ReadElementContentAsString(); - if (string.IsNullOrEmpty(startValue)) - { - // Log.Error(" programme#{0} doesnt contain a start date", iChannel); - result.CopyrightDate = null; - } - else - { - var copyrightDate = ParseDate(startValue); - if (copyrightDate != null) - { - result.CopyrightDate = copyrightDate; - } - } - } - - public void ProcessCredits(XmlReader creditsXml, XmlTvProgram result) - { - creditsXml.MoveToContent(); - creditsXml.Read(); - - // Loop through each element - while (!creditsXml.EOF && creditsXml.ReadState == ReadState.Interactive) - { - if (creditsXml.NodeType == XmlNodeType.Element) - { - XmlTvCredit credit = null; - switch (creditsXml.Name) - { - case "director": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Director }; - break; - case "actor": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Actor }; - break; - case "writer": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Writer }; - break; - case "adapter": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Adapter }; - break; - case "producer": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Producer }; - break; - case "composer": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Composer }; - break; - case "editor": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Editor }; - break; - case "presenter": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Presenter }; - break; - case "commentator": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Commentator }; - break; - case "guest": - credit = new XmlTvCredit() { Type = XmlTvCreditType.Guest }; - break; - } - - if (credit != null) - { - credit.Name = creditsXml.ReadElementContentAsString(); - result.Credits.Add(credit); - } - else - { - creditsXml.Skip(); - } - } - else - creditsXml.Read(); - } - } - - public void ProcessStarRating(XmlReader reader, XmlTvProgram result) - { - /* - - 3/3 - - */ - - reader.ReadToDescendant("value"); - if (reader.Name == "value") - { - var textValue = reader.ReadElementContentAsString(); - if (textValue.Contains("/")) - { - var components = textValue.Split('/'); - if (float.TryParse(components[0], out var value)) - { - result.StarRating = value; - } - } - } - else - { - reader.Skip(); - } - } - - public void ProcessRating(XmlReader reader, XmlTvProgram result) - { - /* - - TV-G - - */ - - var system = reader.GetAttribute("system"); - - reader.ReadToDescendant("value"); - if (reader.Name == "value") - { - result.Rating = new XmlTvRating() - { - System = system, - Value = reader.ReadElementContentAsString() - }; - } - else - { - reader.Skip(); - } - } - - public void ProcessEpisodeNum(XmlReader reader, XmlTvProgram result) - { - /* - EP00003026.0666 - 2706 - .26/0. - */ - - var episodeSystem = reader.GetAttribute("system"); - switch (episodeSystem) - { - case "dd_progid": - ParseEpisodeDataForProgramId(reader, result); - break; - case "icetv": - result.ProviderIds["icetv"] = reader.ReadElementContentAsString(); - break; - case "xmltv_ns": - ParseEpisodeDataForXmlTvNs(reader, result); - break; - case "onscreen": - ParseEpisodeDataForOnScreen(reader, result); - break; - case "thetvdb.com": - ParseTvdbSystem(reader, result); - break; - case "imdb.com": - ParseImdbSystem(reader, result); - break; - case "themoviedb.org": - ParseMovieDbSystem(reader, result); - break; - case "SxxExx": - ParseSxxExxSystem(reader, result); - break; - default: // Handles empty string and nulls - reader.Skip(); - break; - } - } - - public void ParseSxxExxSystem(XmlReader reader, XmlTvProgram result) - { - // S012E32 - - var value = reader.ReadElementContentAsString(); - var res = Regex.Match(value, "s([0-9]+)e([0-9]+)", RegexOptions.IgnoreCase); - - if (res.Success) - { - int parsedInt; - - if (int.TryParse(res.Groups[1].Value, out parsedInt)) - { - result.Episode.Series = parsedInt; - } - - if (int.TryParse(res.Groups[2].Value, out parsedInt)) - { - result.Episode.Episode = parsedInt; - } - } - } - - public void ParseMovieDbSystem(XmlReader reader, XmlTvProgram result) - { - // series/248841 - // episode/4749206 - - var value = reader.ReadElementContentAsString(); - var parts = value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - - if (string.Equals(parts[0], "series", StringComparison.OrdinalIgnoreCase)) - { - result.SeriesProviderIds["tmdb"] = parts[1]; - } - - else if (parts.Length == 1 || string.Equals(parts[0], "episode", StringComparison.OrdinalIgnoreCase)) - { - result.ProviderIds["tmdb"] = parts.Last(); - } - } - - public void ParseImdbSystem(XmlReader reader, XmlTvProgram result) - { - // series/tt1837576 - // episode/tt3288596 - - var value = reader.ReadElementContentAsString(); - if (string.IsNullOrWhiteSpace(value)) - { - return; - } - var parts = value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length != 2) - { - return; - } - - if (string.Equals(parts[0], "series", StringComparison.OrdinalIgnoreCase)) - { - result.SeriesProviderIds["imdb"] = parts[1]; - } - - else if (string.Equals(parts[0], "episode", StringComparison.OrdinalIgnoreCase)) - { - result.ProviderIds["imdb"] = parts[1]; - } - } - - public void ParseTvdbSystem(XmlReader reader, XmlTvProgram result) - { - // series/248841 - // episode/4749206 - - var value = reader.ReadElementContentAsString(); - var parts = value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length != 2) - { - return; - } - - if (string.Equals(parts[0], "series", StringComparison.OrdinalIgnoreCase)) - { - result.SeriesProviderIds["tvdb"] = parts[1]; - } - - else if (string.Equals(parts[0], "episode", StringComparison.OrdinalIgnoreCase)) - { - result.ProviderIds["tvdb"] = parts[1]; - } - } - - public void ParseEpisodeDataForOnScreen(XmlReader reader, XmlTvProgram result) - { - //// example: 'Episode #FFEE' - //serEpNum = ConvertHTMLToAnsi(nodeEpisodeNum); - //int num1 = serEpNum.IndexOf("#", 0); - //if (num1 < 0) num1 = 0; - //episodeNum = CorrectEpisodeNum(serEpNum.Substring(num1, serEpNum.Length - num1), 0); - - var value = reader.ReadElementContentAsString(); - // value = HttpUtility.HtmlDecode(value); - value = value.Replace(" ", ""); - - var hashIndex = value.IndexOf("#", StringComparison.Ordinal); - if (hashIndex > -1) - { - // Take everything from the hash to the end. - //TODO: This could be textual - how do we populate an Int32 - // result.EpisodeNumber - } - } - - public void ParseEpisodeDataForProgramId(XmlReader reader, XmlTvProgram result) - { - var value = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(value)) - { - result.ProgramId = value; - } - } - - public void ParseEpisodeDataForXmlTvNs(XmlReader reader, XmlTvProgram result) - { - var value = reader.ReadElementContentAsString(); - - value = value.Replace(" ", ""); - - // Episode details - var components = value.Split(new[] { "." }, StringSplitOptions.None); - - int parsedInt; - - if (!string.IsNullOrEmpty(components[0])) - { - // Handle either "5/12" or "5" - var seriesComponents = components[0].Split(new[] { "/" }, StringSplitOptions.None); - - // handle the zero basing! - if (int.TryParse(seriesComponents[0], out parsedInt)) - { - result.Episode.Series = parsedInt + 1; - if (seriesComponents.Length == 2) - { - if (int.TryParse(seriesComponents[1], out parsedInt)) - { - result.Episode.SeriesCount = parsedInt; - } - } - } - } - - if (components.Length >= 2) - { - if (!string.IsNullOrEmpty(components[1])) - { - // Handle either "5/12" or "5" - var episodeComponents = components[1].Split(new[] { "/" }, StringSplitOptions.None); - - // handle the zero basing! - if (int.TryParse(episodeComponents[0], out parsedInt)) - { - result.Episode.Episode = parsedInt + 1; - if (episodeComponents.Count() == 2) - { - if (int.TryParse(episodeComponents[1], out parsedInt)) - { - result.Episode.EpisodeCount = parsedInt; - } - } - } - } - } - - if (components.Length >= 3) - { - if (!string.IsNullOrEmpty(components[2])) - { - // Handle either "5/12" or "5" - var partComponents = components[2].Split(new[] { "/" }, StringSplitOptions.None); - - // handle the zero basing! - if (int.TryParse(partComponents[0], out parsedInt)) - { - result.Episode.Part = parsedInt + 1; - if (partComponents.Count() == 2) - { - if (int.TryParse(partComponents[1], out parsedInt)) - { - result.Episode.PartCount = parsedInt; - } - } - } - } - } - } - - public void ProcessQuality(XmlReader reader, XmlTvProgram result) - { - result.Quality = reader.ReadElementContentAsString(); - } - - public void ProcessPreviouslyShown(XmlReader reader, XmlTvProgram result) - { - // - var value = reader.GetAttribute("start"); - if (!string.IsNullOrEmpty(value)) - { - // TODO: this may not be correct = validate it - result.PreviouslyShown = ParseDate(value); - if (result.PreviouslyShown != result.StartDate) - { - result.IsPreviouslyShown = true; - } - } - else - { - result.IsPreviouslyShown = true; - } - - reader.Skip(); // Move on - } - - public void ProcessNew(XmlReader reader, XmlTvProgram result) - { - result.IsNew = true; - reader.Skip(); // Move on - } - - public void ProcessCategory(XmlReader reader, XmlTvProgram result) - { - /* - News - */ - - result.Categories = result.Categories ?? new List(); - ProcessMultipleNodes(reader, s => result.Categories.Add(s), _language); - - //result.Categories.Add(reader.ReadElementContentAsString()); - } - public void ProcessCountry(XmlReader reader, XmlTvProgram result) - { - /* - Canadá - EE.UU - */ - - result.Countries = result.Countries ?? new List(); - ProcessNode(reader, s => result.Countries.Add(s), _language); - } - - public void ProcessSubTitle(XmlReader reader, XmlTvProgram result) - { - /* - Gino's Italian Escape - Islands in the Sun: Southern Sardinia Celebrate the Sea - 8782 - */ - ProcessNode(reader, s => result.Episode.Title = s, _language); - } - - public void ProcessDescription(XmlReader reader, XmlTvProgram result) - { - ProcessNode(reader, s => result.Description = s, _language); - } - - public void ProcessTitleNode(XmlReader reader, XmlTvProgram result) - { - // Gino's Italian Escape - ProcessNode(reader, s => result.Title = s, _language); - } - - public void ProcessPremiereNode(XmlReader reader, XmlTvProgram result) - { - // Gino's Italian Escape - ProcessNode(reader, - s => - { - if (result.Premiere == null) - { - result.Premiere = new XmlTvPremiere() { Details = s }; - } - else - { - result.Premiere.Details = s; - } - }, _language); - } - - public XmlTvIcon ProcessIconNode(XmlReader reader) - { - var result = new XmlTvIcon(); - var isPopulated = false; - - var source = reader.GetAttribute("src"); - if (!string.IsNullOrEmpty(source)) - { - result.Source = source; - isPopulated = true; - } - - var widthString = reader.GetAttribute("width"); - var width = 0; - if (!string.IsNullOrEmpty(widthString) && int.TryParse(widthString, out width)) - { - result.Width = width; - isPopulated = true; - } - - var heightString = reader.GetAttribute("height"); - var height = 0; - if (!string.IsNullOrEmpty(heightString) && int.TryParse(heightString, out height)) - { - result.Height = height; - isPopulated = true; - } - - return isPopulated ? result : null; - } - - - //public void ProcessNodeWithLanguage(XmlReader reader, Action setter) - //{ - // var currentElementName = reader.Name; - // var result = string.Empty; - // var resultCandidate = reader.ReadElementContentAsString(); - // var exactMatchFound = false; - - // while (reader.Name == currentElementName) - // { - // var language = reader.GetAttribute("lang"); - // resultCandidate = reader.ReadElementContentAsString(); - - // if (language == _language && !exactMatchFound) - // { - // result = resultCandidate; - // } - - // reader.Skip(); - // } - - // result = String.IsNullOrEmpty(result) ? resultCandidate : result; - // setter(result); - //} - - public void ProcessNode(XmlReader reader, Action setter, string languageRequired = null, Action allOccurrencesSetter = null) - { - /* Homes Under the Hammer - Spanish - * Homes Under the Hammer - Spanish 2 - * Homes Under the Hammer - English - * Homes Under the Hammer - English 2 - * Homes Under the Hammer - Empty Language - * Homes Under the Hammer - Empty Language 2 - * Homes Under the Hammer - No Language - * Homes Under the Hammer - No Language 2 - */ - - /* Expected Behaviour: - * - Language = Null Homes Under the Hammer - No Language - * - Language = "" Homes Under the Hammer - No Language - * - Language = es Homes Under the Hammer - Spanish - * - Language = en Homes Under the Hammer - English - */ - - var results = new List>(); - - // We will always use the first value - so that if there are no matches we can return something - var currentElementName = reader.Name; - - var lang = reader.HasAttributes ? reader.GetAttribute("lang") : null; - var currentValue = reader.ReadElementContentAsString(); - results.Add(new Tuple(currentValue, lang)); - - if (allOccurrencesSetter != null) - { - allOccurrencesSetter(currentValue); - } - - while (!reader.EOF && reader.ReadState == ReadState.Interactive) - { - if (reader.NodeType == XmlNodeType.Element) - { - if (reader.Name == currentElementName) - { - lang = reader.HasAttributes ? reader.GetAttribute("lang") : null; - currentValue = reader.ReadElementContentAsString(); - - if (allOccurrencesSetter != null) - { - allOccurrencesSetter(currentValue); - } - - results.Add(new Tuple(currentValue, lang)); - } - else - { - break; - } - } - else - { - reader.Read(); - } - } - - if (languageRequired != null) - { - foreach (var result in results) - { - if (string.Equals(languageRequired, result.Item2, StringComparison.OrdinalIgnoreCase)) - { - setter(result.Item1); - return; - } - } - } - - foreach (var result in results) - { - if (string.IsNullOrWhiteSpace(result.Item2)) - { - setter(result.Item1); - return; - } - } - - foreach (var result in results) - { - setter(result.Item1); - return; - } - } - - public void ProcessMultipleNodes(XmlReader reader, Action setter, string languageRequired = null) - { - /* Property - English - * Property - English 2 - * Property - Spanish - * Property - Spanish 2 - * Property - Empty Language - * Property - Empty Language 2 - * Property - No Language - * Property - No Language 2 - */ - - /* Expected Behaviour: - * - Language = Null Property - No Language / Property - No Language 2 - * - Language = "" Property - Empty Language / Property - Empty Language 2 - * - Language = es Property - Spanish / Property - Spanish 2 - * - Language = en Property - English / Property - English 2 - */ - - var currentElementName = reader.Name; - var values = new[] { new { Language = reader.GetAttribute("lang"), Value = reader.ReadElementContentAsString() } }.ToList(); - - while (reader.Read()) - { - if (reader.NodeType == XmlNodeType.Element && reader.Name != currentElementName) - { - break; - } - - if (reader.NodeType == XmlNodeType.Element && reader.Name == currentElementName) - { - values.Add(new { Language = reader.GetAttribute("lang"), Value = reader.ReadElementContentAsString() }); - } - } - - if (values.Count(v => v.Language == languageRequired) > 0) - { - values.RemoveAll(v => v.Language != languageRequired); - } - - // ENumerate and return all the matches - foreach (var result in values) - { - setter(result.Value); - } - } - - public void ProcessMultipleNodesWithLanguage(XmlReader reader, Action setter) - { - var currentElementName = reader.Name; - while (reader.Name == currentElementName) - { - var language = reader.GetAttribute("lang"); - if (string.IsNullOrEmpty(_language) || string.IsNullOrEmpty(language) || language == _language) - { - setter(reader.ReadElementContentAsString()); - } - reader.Skip(); - } - } - - private void PopulateHeader(XmlReader reader, XmlTvProgram result) - { - result.ChannelId = reader.GetAttribute("channel"); - - var startValue = reader.GetAttribute("start"); - if (string.IsNullOrEmpty(startValue)) - { - // Log.Error(" programme#{0} doesnt contain a start date", iChannel); - result.StartDate = DateTimeOffset.MinValue; - } - else - { - result.StartDate = ParseDate(startValue).GetValueOrDefault(); - } - - - var endValue = reader.GetAttribute("stop"); - if (string.IsNullOrEmpty(endValue)) - { - // Log.Error(" programme#{0} doesnt contain an end date", iChannel); - result.EndDate = DateTimeOffset.MinValue; - } - else - { - result.EndDate = ParseDate(endValue).GetValueOrDefault(); - } - } - - public const string _regDateWithOffset = @"^(?[0-9]{4,14})(\s(?[+-]*[0-9]{1,4}))?$"; - - public DateTimeOffset? ParseDate(string dateValue) - { - /* - All dates and times in this DTD follow the same format, loosely based - on ISO 8601. They can be 'YYYYMMDDhhmmss' or some initial - substring, for example if you only know the year and month you can - have 'YYYYMM'. You can also append a timezone to the end; if no - explicit timezone is given, UTC is assumed. Examples: - '200007281733 BST', '200209', '19880523083000 +0300'. (BST == +0100.) - */ - - if (string.IsNullOrEmpty(dateValue)) - { - return null; - } - - var completeDate = "20000101000000"; - var dateComponent = string.Empty; - var dateOffset = "+00:00"; - var match = Regex.Match(dateValue, _regDateWithOffset); - if (match.Success) - { - dateComponent = match.Groups["dateDigits"].Value; - if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value)) - { - dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later - if (dateOffset.Length == 5) - { - dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later - } - else - { - dateOffset = "+00:00"; - } - } - } - - // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000 - if (dateComponent.Length < 14) - { - dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length); - } - - var standardDate = string.Format("{0} {1}", dateComponent, dateOffset); - if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTimeOffset parsedDateTime)) - { - return parsedDateTime.ToUniversalTime(); - } - - // Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate); - - return null; - } - - public string StandardiseDate(string value) - { - var completeDate = "20000101000000"; - var dateComponent = string.Empty; - var dateOffset = "+0000"; - - var match = Regex.Match(value, _regDateWithOffset); - if (match.Success) - { - dateComponent = match.Groups["dateDigits"].Value; - dateOffset = match.Groups["dateOffset"].Value; - } - - // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000 - if (dateComponent.Length < 14) - { - dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length); - } - - return string.Format("{0} {1}", dateComponent, dateOffset); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Emby.XmlTv.csproj b/Emby.XmlTv/Emby.XmlTv/Emby.XmlTv.csproj deleted file mode 100644 index 04f558173..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Emby.XmlTv.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - netstandard2.0 - false - true - - - - - - - diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvChannel.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvChannel.cs deleted file mode 100644 index 2673d711c..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvChannel.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Text; - -namespace Emby.XmlTv.Entities -{ - public class XmlTvChannel : IEquatable - { - public string Id { get; set; } - public string DisplayName { get; set; } - public string Number { get; set; } - public string Url { get; set; } - public XmlTvIcon Icon { get; set; } - - public bool Equals(XmlTvChannel other) - { - // If both are null, or both are same instance, return true. - if (ReferenceEquals(this, other)) - { - return true; - } - - // If the other is null then return false - if (other == null) - { - return false; - } - - // Return true if the fields match: - return Id == other.Id; - } - - public override int GetHashCode() - { - return (Id.GetHashCode() * 17); - } - - public override string ToString() - { - var builder = new StringBuilder(); - builder.AppendFormat("{0} - {1} ", Id, DisplayName); - - if (!string.IsNullOrEmpty(Url)) - { - builder.AppendFormat(" ({0})", Url); - } - - return builder.ToString(); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCredit.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCredit.cs deleted file mode 100644 index d959ce76f..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCredit.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Emby.XmlTv.Entities -{ - public class XmlTvCredit - { - public XmlTvCreditType Type { get; set; } - public string Name { get; set; } - - public override string ToString() - { - return string.Format("{0} - ({1})", Name, Type); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCreditType.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCreditType.cs deleted file mode 100644 index 31c7f5e44..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvCreditType.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Emby.XmlTv.Entities -{ - public enum XmlTvCreditType - { - NotSpecified = 0, - Director, - Actor, - Writer, - Adapter, - Producer, - Composer, - Editor, - Presenter, - Commentator, - Guest - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvEpisode.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvEpisode.cs deleted file mode 100644 index 47525b57c..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvEpisode.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Text; - -namespace Emby.XmlTv.Entities -{ - public class XmlTvEpisode - { - public int? Series { get; set; } - public int? SeriesCount { get; set; } - public int? Episode { get; set; } - public int? EpisodeCount { get; set; } - public string Title { get; set; } - public int? Part { get; set; } - public int? PartCount { get; set; } - - public override string ToString() - { - var builder = new StringBuilder(); - if (Series.HasValue || SeriesCount.HasValue) - { - builder.AppendFormat("Series {0}", Series.HasValue ? Series.Value.ToString() : "?"); - if (SeriesCount.HasValue) - { - builder.AppendFormat(" of {0}", SeriesCount); - } - } - - if (Episode.HasValue || EpisodeCount.HasValue) - { - builder.Append(builder.Length > 0 ? ", " : string.Empty); - builder.AppendFormat("Episode {0}", Episode.HasValue ? Episode.Value.ToString() : "?"); - if (EpisodeCount.HasValue) - { - builder.AppendFormat(" of {0}", EpisodeCount); - } - } - - if (Part.HasValue || PartCount.HasValue) - { - builder.Append(builder.Length > 0 ? ", " : string.Empty); - builder.AppendFormat("Part {0}", Part.HasValue ? Part.Value.ToString() : "?"); - if (PartCount.HasValue) - { - builder.AppendFormat(" of {0}", PartCount); - } - } - - return builder.ToString(); - } - } - - -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvIcon.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvIcon.cs deleted file mode 100644 index 77ef8d5fd..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvIcon.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Text; - -namespace Emby.XmlTv.Entities -{ - public class XmlTvIcon - { - public string Source { get; set; } - public int? Width { get; set; } - public int? Height { get; set; } - - public override string ToString() - { - var builder = new StringBuilder(); - builder.AppendFormat("Source: {0}", Source); - if (Width.HasValue) - { - builder.AppendFormat(", Width: {0}", Width); - } - if (Height.HasValue) - { - builder.AppendFormat(", Height: {0}", Height); - } - - return builder.ToString(); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvLanguage.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvLanguage.cs deleted file mode 100644 index 0fd5573cd..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvLanguage.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Emby.XmlTv.Entities -{ - public class XmlTvLanguage - { - /// - /// The name. - /// - public string Name { get; set; } - - /// - /// The relevance (number of occurances) of the language, can be used to order (desc) - /// - public int Relevance { get; set; } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvPremiere.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvPremiere.cs deleted file mode 100644 index a1920bc77..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvPremiere.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Emby.XmlTv.Entities -{ - public class XmlTvPremiere - { - /* - - First showing on national terrestrial TV - - */ - - public string Details { get; set; } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvProgram.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvProgram.cs deleted file mode 100644 index 1725e17d7..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvProgram.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Emby.XmlTv.Entities -{ - public class XmlTvProgram : IEquatable - { - public string ChannelId { get; set; } - - public DateTimeOffset StartDate { get; set; } - - public DateTimeOffset EndDate { get; set; } - - public string Title { get; set; } - - public string Description { get; set; } - public string ProgramId { get; set; } - public string Quality { get; set; } - - public List Categories { get; set; } - - public List Countries { get; set; } - - public DateTimeOffset? PreviouslyShown { get; set; } - - public bool IsPreviouslyShown { get; set; } - public bool IsNew { get; set; } - - public DateTimeOffset? CopyrightDate { get; set; } - - public XmlTvEpisode Episode { get; set; } - - public List Credits { get; set; } - - public XmlTvRating Rating { get; set; } - - public float? StarRating { get; set; } - - public XmlTvIcon Icon { get; set; } - - public XmlTvPremiere Premiere { get; set; } - - public Dictionary ProviderIds { get; set; } - public Dictionary SeriesProviderIds { get; set; } - - public XmlTvProgram() - { - Credits = new List(); - Categories = new List(); - Countries = new List(); - Episode = new XmlTvEpisode(); - - ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - SeriesProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - } - - public bool Equals(XmlTvProgram other) - { - // If both are null, or both are same instance, return true. - if (ReferenceEquals(this, other)) - { - return true; - } - - // If the other is null then return false - if (other == null) - { - return false; - } - - // Return true if the fields match: - return ChannelId == other.ChannelId && - StartDate == other.StartDate && - EndDate == other.EndDate; - } - - public override int GetHashCode() - { - return (ChannelId.GetHashCode() * 17) + (StartDate.GetHashCode() * 17) + (EndDate.GetHashCode() * 17); - } - - public override string ToString() - { - var builder = new StringBuilder(); - builder.AppendFormat("ChannelId: \t\t{0}\r\n", ChannelId); - builder.AppendFormat("Title: \t\t{0}\r\n", Title); - builder.AppendFormat("StartDate: \t\t{0}\r\n", StartDate); - builder.AppendFormat("EndDate: \t\t{0}\r\n", EndDate); - return builder.ToString(); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvRating.cs b/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvRating.cs deleted file mode 100644 index e37113d7a..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Entities/XmlTvRating.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Text; - -namespace Emby.XmlTv.Entities -{ - /// - /// Describes the rating (certification) applied to a program - /// - /// Example XML: - /// - public class XmlTvRating - { - /// - /// The literal name of the rating system - /// - /// MPAA - public string System { get; set; } - - /// - /// Describes the rating using the system specificed - /// - /// TV-14 - public string Value { get; set; } - - public override string ToString() - { - var builder = new StringBuilder(); - if (!string.IsNullOrEmpty(Value)) - { - builder.Append(Value); - } - - if (!string.IsNullOrEmpty(System)) - { - builder.AppendFormat(" ({0})", System); - } - - return builder.ToString(); - } - } -} diff --git a/Emby.XmlTv/Emby.XmlTv/Properties/AssemblyInfo.cs b/Emby.XmlTv/Emby.XmlTv/Properties/AssemblyInfo.cs deleted file mode 100644 index 7beec09cb..000000000 --- a/Emby.XmlTv/Emby.XmlTv/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("XmlTv")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Jellyfin Project")] -[assembly: AssemblyProduct("Jellyfin Server")] -[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("en")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] diff --git a/Emby.XmlTv/Emby.XmlTv/XmlTvSchema.dtd b/Emby.XmlTv/Emby.XmlTv/XmlTvSchema.dtd deleted file mode 100644 index 889939224..000000000 --- a/Emby.XmlTv/Emby.XmlTv/XmlTvSchema.dtd +++ /dev/null @@ -1,575 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Emby.XmlTv/License.txt b/Emby.XmlTv/License.txt deleted file mode 100644 index 3c4f73ddb..000000000 --- a/Emby.XmlTv/License.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Alex Stevens - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Emby.XmlTv/Nuget/Emby.XmlTv.nuspec b/Emby.XmlTv/Nuget/Emby.XmlTv.nuspec deleted file mode 100644 index 087ce1e6e..000000000 --- a/Emby.XmlTv/Nuget/Emby.XmlTv.nuspec +++ /dev/null @@ -1,20 +0,0 @@ - - - - Emby.XmlTv - 1.0.19 - Emby.XmlTv - Emby Team - ebr,Luke,scottisafool - https://github.com/MediaBrowser/Emby.XmlTv - http://www.mb3admin.com/images/mb3icons1-1.png - false - An XmlTv parsing library. - Copyright © Emby 2013 - - - - - - - \ No newline at end of file diff --git a/Emby.XmlTv/README.md b/Emby.XmlTv/README.md deleted file mode 100644 index 86e777bb2..000000000 --- a/Emby.XmlTv/README.md +++ /dev/null @@ -1 +0,0 @@ -# Emby.XmlTv diff --git a/MediaBrowser.sln b/MediaBrowser.sln index da828927b..cf3f56cd9 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -36,8 +36,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.Notifications", "Emby. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.Naming", "Emby.Naming\Emby.Naming.csproj", "{E5AF7B26-2239-4CE0-B477-0AA2018EDAA2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.XmlTv", "Emby.XmlTv\Emby.XmlTv\Emby.XmlTv.csproj", "{6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediaBrowser.MediaEncoding", "MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj", "{960295EE-4AF4-4440-A525-B4C295B01A61}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server", "Jellyfin.Server\Jellyfin.Server.csproj", "{07E39F42-A2C6-4B32-AF8C-725F957A73FF}" @@ -136,10 +134,6 @@ Global {E5AF7B26-2239-4CE0-B477-0AA2018EDAA2}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5AF7B26-2239-4CE0-B477-0AA2018EDAA2}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5AF7B26-2239-4CE0-B477-0AA2018EDAA2}.Release|Any CPU.Build.0 = Release|Any CPU - {6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Release|Any CPU.Build.0 = Release|Any CPU {960295EE-4AF4-4440-A525-B4C295B01A61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {960295EE-4AF4-4440-A525-B4C295B01A61}.Debug|Any CPU.Build.0 = Debug|Any CPU {960295EE-4AF4-4440-A525-B4C295B01A61}.Release|Any CPU.ActiveCfg = Release|Any CPU From d79242c3c7092ce1d2309937157cc513a2d7d532 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sun, 15 Dec 2019 01:55:07 -0500 Subject: [PATCH 47/53] Remove broken Microsoft SDK image (#2158) * Remove broken Microsoft SDK image This was not working; for some reason the Microsoft .NET Docker image for 3.0 still had a 2.1 binary which was wreaking havoc. Replace it with the manual download that all the other .deb packages use. * Install missing dependency --- deployment/ubuntu-package-x64/Dockerfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/deployment/ubuntu-package-x64/Dockerfile b/deployment/ubuntu-package-x64/Dockerfile index 21a536e5e..d881c04e3 100644 --- a/deployment/ubuntu-package-x64/Dockerfile +++ b/deployment/ubuntu-package-x64/Dockerfile @@ -1,19 +1,28 @@ -FROM microsoft/dotnet:3.0-sdk-bionic +FROM ubuntu:bionic # Docker build arguments ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-x64 ARG ARTIFACT_DIR=/dist +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist ENV DEB_BUILD_OPTIONS=noddebs +ENV ARCH=amd64 # Prepare Ubuntu build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv libc6-dev libcurl4-openssl-dev libfontconfig1-dev libfreetype6-dev libssl-dev \ + && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv libc6-dev libcurl4-openssl-dev libfontconfig1-dev libfreetype6-dev libssl-dev liblttng-ust0 \ && ln -sf ${PLATFORM_DIR}/docker-build.sh /docker-build.sh \ && mkdir -p ${SOURCE_DIR} && ln -sf ${PLATFORM_DIR}/pkg-src ${SOURCE_DIR}/debian +# Install dotnet repository +# https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ + && mkdir -p dotnet-sdk \ + && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ + && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet + # Install npm package manager RUN wget -q -O- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \ && echo "deb https://deb.nodesource.com/node_8.x $(lsb_release -s -c) main" > /etc/apt/sources.list.d/npm.list \ From d063300af481fe385ce1fb61b440217cdd89ef04 Mon Sep 17 00:00:00 2001 From: cryptobank Date: Sun, 15 Dec 2019 20:35:52 +1030 Subject: [PATCH 48/53] Add space Co-Authored-By: Bond-009 --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 46669f4e3..897e22018 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1711,7 +1711,7 @@ namespace MediaBrowser.Controller.MediaEncoding || !videoHeight.HasValue || outputHeight != videoHeight.Value) { - //Force nv12 pixel format to enable 10-bit to 8-bit colour conversion. + // Force nv12 pixel format to enable 10-bit to 8-bit colour conversion. filters.Add( string.Format( CultureInfo.InvariantCulture, From c6851bd72c88070126ac3517eeb63496900d9f9b Mon Sep 17 00:00:00 2001 From: schbal Date: Sun, 15 Dec 2019 03:06:42 +0000 Subject: [PATCH 49/53] Translated using Weblate (Korean) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/ko/ --- Emby.Server.Implementations/Localization/Core/ko.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/ko.json b/Emby.Server.Implementations/Localization/Core/ko.json index 3d2350c07..0320a0a1b 100644 --- a/Emby.Server.Implementations/Localization/Core/ko.json +++ b/Emby.Server.Implementations/Localization/Core/ko.json @@ -5,13 +5,13 @@ "Artists": "아티스트", "AuthenticationSucceededWithUserName": "{0}이 성공적으로 인증됨", "Books": "도서", - "CameraImageUploadedFrom": "{0}에서 새로운 카메라 이미지가 업로드되었습니다", + "CameraImageUploadedFrom": "{0}에서 새로운 카메라 이미지가 업로드됨", "Channels": "채널", "ChapterNameValue": "챕터 {0}", "Collections": "컬렉션", - "DeviceOfflineWithName": "{0} 연결 끊김", - "DeviceOnlineWithName": "{0} 연결됨", - "FailedLoginAttemptWithUserName": "{0} 로그인 실패", + "DeviceOfflineWithName": "{0}의 연결 끊김", + "DeviceOnlineWithName": "{0}이 연결됨", + "FailedLoginAttemptWithUserName": "{0}에서 로그인 실패", "Favorites": "즐겨찾기", "Folders": "폴더", "Genres": "장르", From a7a4974d95d65476db931d904296a7644a760fa9 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 14 Dec 2019 13:53:29 +0000 Subject: [PATCH 50/53] Translated using Weblate (Dutch) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/nl/ --- Emby.Server.Implementations/Localization/Core/nl.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/nl.json b/Emby.Server.Implementations/Localization/Core/nl.json index 637e514ed..35b35e039 100644 --- a/Emby.Server.Implementations/Localization/Core/nl.json +++ b/Emby.Server.Implementations/Localization/Core/nl.json @@ -5,10 +5,10 @@ "Artists": "Artiesten", "AuthenticationSucceededWithUserName": "{0} is succesvol geverifieerd", "Books": "Boeken", - "CameraImageUploadedFrom": "Er is een nieuwe foto toegevoegd via {0}", + "CameraImageUploadedFrom": "Er is een nieuwe foto toegevoegd van {0}", "Channels": "Kanalen", "ChapterNameValue": "Hoofdstuk {0}", - "Collections": "Collecties", + "Collections": "Verzamelingen", "DeviceOfflineWithName": "{0} heeft de verbinding verbroken", "DeviceOnlineWithName": "{0} is verbonden", "FailedLoginAttemptWithUserName": "Mislukte aanmeld poging van {0}", From 6fb7999a148b85f798bd137d0a1468e0cb2ece0e Mon Sep 17 00:00:00 2001 From: Roland Vet Date: Sat, 14 Dec 2019 13:57:35 +0000 Subject: [PATCH 51/53] Translated using Weblate (Dutch) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/nl/ --- Emby.Server.Implementations/Localization/Core/nl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/nl.json b/Emby.Server.Implementations/Localization/Core/nl.json index 35b35e039..4423b7f98 100644 --- a/Emby.Server.Implementations/Localization/Core/nl.json +++ b/Emby.Server.Implementations/Localization/Core/nl.json @@ -58,7 +58,7 @@ "NotificationOptionPluginUpdateInstalled": "Plug-in-update geïnstalleerd", "NotificationOptionServerRestartRequired": "Server herstart nodig", "NotificationOptionTaskFailed": "Geplande taak mislukt", - "NotificationOptionUserLockedOut": "Gebruikersaccount vergrendeld", + "NotificationOptionUserLockedOut": "Gebruiker is vergrendeld", "NotificationOptionVideoPlayback": "Video gestart", "NotificationOptionVideoPlaybackStopped": "Video gestopt", "Photos": "Foto's", From dda431dff198d2b375128cd3e29cac01eb8627e1 Mon Sep 17 00:00:00 2001 From: tanto faz Date: Sat, 14 Dec 2019 15:44:06 +0000 Subject: [PATCH 52/53] Translated using Weblate (Portuguese (Brazil)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/pt_BR/ --- Emby.Server.Implementations/Localization/Core/pt-BR.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/pt-BR.json b/Emby.Server.Implementations/Localization/Core/pt-BR.json index fcc724a7d..41a389e3b 100644 --- a/Emby.Server.Implementations/Localization/Core/pt-BR.json +++ b/Emby.Server.Implementations/Localization/Core/pt-BR.json @@ -24,7 +24,7 @@ "HeaderFavoriteShows": "Séries Favoritas", "HeaderFavoriteSongs": "Músicas Favoritas", "HeaderLiveTV": "TV ao Vivo", - "HeaderNextUp": "Próximos", + "HeaderNextUp": "A Seguir", "HeaderRecordingGroups": "Grupos de Gravação", "HomeVideos": "Vídeos caseiros", "Inherit": "Herdar", From db61a58c39490f86c86c3ee6c6f11743796fb10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93skar=20Freyr?= Date: Sun, 15 Dec 2019 16:22:04 +0000 Subject: [PATCH 53/53] Translated using Weblate (Icelandic) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/is/ --- .../Localization/Core/is.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/is.json b/Emby.Server.Implementations/Localization/Core/is.json index af0da4169..c3b5211b8 100644 --- a/Emby.Server.Implementations/Localization/Core/is.json +++ b/Emby.Server.Implementations/Localization/Core/is.json @@ -62,5 +62,17 @@ "NameInstallFailed": "{0} uppsetning mistókst", "MusicVideos": "Tónlistarmyndbönd", "Music": "Tónlist", - "Movies": "Kvikmyndir" + "Movies": "Kvikmyndir", + "UserDeletedWithName": "Notanda {0} hefur verið eytt", + "UserCreatedWithName": "Notandi {0} hefur verið stofnaður", + "TvShows": "Þættir", + "Sync": "Samstilla", + "Songs": "Lög", + "ServerNameNeedsToBeRestarted": "{0} þarf að endurræsa", + "ScheduledTaskStartedWithName": "{0} hafin", + "ScheduledTaskFailedWithName": "{0} mistókst", + "PluginUpdatedWithName": "{0} var uppfært", + "PluginUninstalledWithName": "{0} var fjarlægt", + "PluginInstalledWithName": "{0} var sett upp", + "NotificationOptionTaskFailed": "Tímasett verkefni mistókst" }