From bbc08753878b7b8a37ed876385d2e6864349d00d Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 20 Oct 2019 16:08:40 +0200 Subject: [PATCH 01/62] 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 d22fc21774..438ca39ea7 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 8e5f5b5617..54a027dac6 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 0244c4a684..bbb3114ca7 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 31a661c5d9..b372ab55c2 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 87e951f25d..9a2a6dc5f5 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 10602fea76..75cb67fcc1 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 9c7f7dfcb1..c10b77a246 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 88e2a8fa69..1b0813280d 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 da0013f128..7b0cd40229 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 89b92c999e..c2350684b9 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 cad66a80fd..2dfe59088d 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 61329160ae..68cd3c0bae 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 f485204436..78ac95f85e 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 c1c6ffc2e2..8a3fdcbcbe 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 1340bd8ef7..caff20084d 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 b4a3026480..6e7351240b 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 2152243985..a12b2833f1 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 d61a07066c..8e9d110122 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 78f8590696..bd96059e32 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 a50da9b0a0..d435551023 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 454bdc4ae2..435a1e8dae 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 aff687f882..bef7eff064 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 2702dca8b6e7f31f64e644ec119edc09cb746bb1 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 26 Oct 2019 23:58:23 +0200 Subject: [PATCH 02/62] Enable nullable reference types for Jellyfin.Server --- Jellyfin.Server/Jellyfin.Server.csproj | 3 +-- Jellyfin.Server/Program.cs | 34 ++++++++++++++++++++------ Jellyfin.Server/StartupOptions.cs | 18 +++++++------- jellyfin.ruleset | 2 ++ 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj index efdb75f980..c834648a5f 100644 --- a/Jellyfin.Server/Jellyfin.Server.csproj +++ b/Jellyfin.Server/Jellyfin.Server.csproj @@ -9,9 +9,8 @@ - - latest true + enable diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index e8bd0cd309..887283d2a4 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Net; @@ -21,6 +22,7 @@ using MediaBrowser.Model.Globalization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Serilog; using Serilog.Extensions.Logging; using SQLitePCL; @@ -35,7 +37,7 @@ namespace Jellyfin.Server { private static readonly CancellationTokenSource _tokenSource = new CancellationTokenSource(); private static readonly ILoggerFactory _loggerFactory = new SerilogLoggerFactory(); - private static ILogger _logger; + private static ILogger _logger = NullLogger.Instance; private static bool _restartOnShutdown; /// @@ -86,6 +88,12 @@ namespace Jellyfin.Server { var stopWatch = new Stopwatch(); stopWatch.Start(); + + // Log all uncaught exception to std error + static void UnhandledExceptionToConsole(object sender, UnhandledExceptionEventArgs e) => + Console.Error.WriteLine("Unhandled Exception\n" + e.ExceptionObject.ToString()); + AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionToConsole; + ServerApplicationPaths appPaths = CreateApplicationPaths(options); // $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager @@ -97,6 +105,8 @@ namespace Jellyfin.Server _logger = _loggerFactory.CreateLogger("Main"); + // Log uncaught exceptions to the logging instead of std error + AppDomain.CurrentDomain.UnhandledException -= UnhandledExceptionToConsole; AppDomain.CurrentDomain.UnhandledException += (sender, e) => _logger.LogCritical((Exception)e.ExceptionObject, "Unhandled Exception"); @@ -129,7 +139,7 @@ namespace Jellyfin.Server _logger.LogInformation( "Jellyfin version: {Version}", - Assembly.GetEntryAssembly().GetName().Version.ToString(3)); + Assembly.GetEntryAssembly()!.GetName().Version!.ToString(3)); ApplicationHost.LogEnvironmentInfo(_logger, appPaths); @@ -361,16 +371,25 @@ namespace Jellyfin.Server private static async Task CreateConfiguration(IApplicationPaths appPaths) { + const string ResourcePath = "Jellyfin.Server.Resources.Configuration.logging.json"; string configPath = Path.Combine(appPaths.ConfigurationDirectoryPath, "logging.json"); if (!File.Exists(configPath)) { // For some reason the csproj name is used instead of the assembly name - using (Stream rscstr = typeof(Program).Assembly - .GetManifestResourceStream("Jellyfin.Server.Resources.Configuration.logging.json")) - using (Stream fstr = File.Open(configPath, FileMode.CreateNew)) + using (Stream? resource = typeof(Program).Assembly.GetManifestResourceStream(ResourcePath)) { - await rscstr.CopyToAsync(fstr).ConfigureAwait(false); + if (resource == null) + { + throw new InvalidOperationException( + string.Format( + CultureInfo.InvariantCulture, + "Invalid resource path: '{0}'", + ResourcePath)); + } + + using Stream dst = File.Open(configPath, FileMode.CreateNew); + await resource.CopyToAsync(dst).ConfigureAwait(false); } } @@ -433,7 +452,7 @@ namespace Jellyfin.Server { _logger.LogInformation("Starting new instance"); - string module = options.RestartPath; + var module = options.RestartPath; if (string.IsNullOrWhiteSpace(module)) { @@ -441,7 +460,6 @@ namespace Jellyfin.Server } string commandLineArgsString; - if (options.RestartArgs != null) { commandLineArgsString = options.RestartArgs ?? string.Empty; diff --git a/Jellyfin.Server/StartupOptions.cs b/Jellyfin.Server/StartupOptions.cs index bb0adaf630..1fb1c5af8e 100644 --- a/Jellyfin.Server/StartupOptions.cs +++ b/Jellyfin.Server/StartupOptions.cs @@ -13,39 +13,39 @@ namespace Jellyfin.Server /// /// The path to the data directory. [Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (database files, etc.).")] - public string DataDir { get; set; } + public string? DataDir { get; set; } /// /// Gets or sets the path to the web directory. /// /// The path to the web directory. [Option('w', "webdir", Required = false, HelpText = "Path to the Jellyfin web UI resources.")] - public string WebDir { get; set; } + public string? WebDir { get; set; } /// /// Gets or sets the path to the cache directory. /// /// The path to the cache directory. [Option('C', "cachedir", Required = false, HelpText = "Path to use for caching.")] - public string CacheDir { get; set; } + public string? CacheDir { get; set; } /// /// Gets or sets the path to the config directory. /// /// The path to the config directory. [Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pictures).")] - public string ConfigDir { get; set; } + public string? ConfigDir { get; set; } /// /// Gets or sets the path to the log directory. /// /// The path to the log directory. [Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")] - public string LogDir { get; set; } + public string? LogDir { get; set; } /// [Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg executable to use in place of default found in PATH.")] - public string FFmpegPath { get; set; } + public string? FFmpegPath { get; set; } /// [Option("service", Required = false, HelpText = "Run as headless service.")] @@ -57,14 +57,14 @@ namespace Jellyfin.Server /// [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")] - public string PackageName { get; set; } + public string? PackageName { get; set; } /// [Option("restartpath", Required = false, HelpText = "Path to restart script.")] - public string RestartPath { get; set; } + public string? RestartPath { get; set; } /// [Option("restartargs", Required = false, HelpText = "Arguments for restart script.")] - public string RestartArgs { get; set; } + public string? RestartArgs { get; set; } } } diff --git a/jellyfin.ruleset b/jellyfin.ruleset index e259131b05..2c3930a28a 100644 --- a/jellyfin.ruleset +++ b/jellyfin.ruleset @@ -6,6 +6,8 @@ + + From 1258a3766f053546a7c6075503aa5b2b010d9d6c Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 29 Oct 2019 17:49:41 +0100 Subject: [PATCH 03/62] Update Jellyfin.Server/Program.cs Co-Authored-By: dkanada --- Jellyfin.Server/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 887283d2a4..4e47922522 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -89,7 +89,7 @@ namespace Jellyfin.Server var stopWatch = new Stopwatch(); stopWatch.Start(); - // Log all uncaught exception to std error + // Log all uncaught exceptions to std error static void UnhandledExceptionToConsole(object sender, UnhandledExceptionEventArgs e) => Console.Error.WriteLine("Unhandled Exception\n" + e.ExceptionObject.ToString()); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionToConsole; From e5d57bd82f9a089b7c19ea357efd2b8b34fd418b Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Jul 2019 12:21:54 +0200 Subject: [PATCH 04/62] Move StartupWizard to ASP.NET Web Api --- .../ApplicationHost.cs | 15 +- .../Emby.Server.Implementations.csproj | 2 + Emby.Server.Implementations/MvcRoutePrefix.cs | 48 +++++++ Jellyfin.Api/Controllers/StartupController.cs | 88 ++++++++++++ Jellyfin.Api/Jellyfin.Api.csproj | 18 +++ .../Models/Startup/StartupConfiguration.cs | 9 ++ Jellyfin.Api/Models/Startup/StartupUser.cs | 8 ++ MediaBrowser.Api/StartupWizardService.cs | 135 ------------------ MediaBrowser.sln | 11 +- 9 files changed, 192 insertions(+), 142 deletions(-) create mode 100644 Emby.Server.Implementations/MvcRoutePrefix.cs create mode 100644 Jellyfin.Api/Controllers/StartupController.cs create mode 100644 Jellyfin.Api/Jellyfin.Api.csproj create mode 100644 Jellyfin.Api/Models/Startup/StartupConfiguration.cs create mode 100644 Jellyfin.Api/Models/Startup/StartupUser.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index fef461b9ac..a9c4e1fdc9 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -108,6 +108,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -611,8 +612,6 @@ namespace Emby.Server.Implementations await RegisterResources(serviceCollection).ConfigureAwait(false); - FindParts(); - string contentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath; if (string.IsNullOrEmpty(contentRoot)) { @@ -657,6 +656,14 @@ namespace Emby.Server.Implementations { services.AddResponseCompression(); services.AddHttpContextAccessor(); + services.AddMvc(opts => + { + opts.UseGeneralRoutePrefix("emby", "emby/emby", "api/v{version:apiVersion}"); + }) + .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) + .AddApplicationPart(Assembly.Load("Jellyfin.Api")); + services.AddApiVersioning(opt => opt.ReportApiVersions = true); + services.TryAdd(serviceCollection); }) .Configure(app => { @@ -666,10 +673,14 @@ namespace Emby.Server.Implementations // TODO app.UseMiddleware(); app.Use(ExecuteWebsocketHandlerAsync); + app.UseMvc(); app.Use(ExecuteHttpHandlerAsync); }) .Build(); + _serviceProvider = host.Services; + FindParts(); + try { await host.StartAsync().ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 45607dc098..23e35f77e1 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -3,6 +3,7 @@ + @@ -25,6 +26,7 @@ + diff --git a/Emby.Server.Implementations/MvcRoutePrefix.cs b/Emby.Server.Implementations/MvcRoutePrefix.cs new file mode 100644 index 0000000000..fb26ae09da --- /dev/null +++ b/Emby.Server.Implementations/MvcRoutePrefix.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ApplicationModels; + +namespace Emby.Server.Implementations +{ + public static class MvcRoutePrefix + { + public static void UseGeneralRoutePrefix(this MvcOptions opts, params string[] prefixes) + { + opts.Conventions.Insert(0, new RoutePrefixConvention(prefixes)); + } + + internal class RoutePrefixConvention : IApplicationModelConvention + { + private readonly AttributeRouteModel[] _routePrefixes; + + public RoutePrefixConvention(IEnumerable prefixes) + { + _routePrefixes = prefixes.Select(p => new AttributeRouteModel(new RouteAttribute(p))).ToArray(); + } + + public void Apply(ApplicationModel application) + { + foreach (var controller in application.Controllers) + { + if (controller.Selectors == null) + { + continue; + } + + var newSelectors = new List(); + foreach (var selector in controller.Selectors) + { + newSelectors.AddRange(_routePrefixes.Select(routePrefix => new SelectorModel(selector) + { + AttributeRouteModel = AttributeRouteModel.CombineAttributeRouteModel(routePrefix, selector.AttributeRouteModel) + })); + } + + controller.Selectors.Clear(); + newSelectors.ForEach(selector => controller.Selectors.Add(selector)); + } + } + } + } +} diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs new file mode 100644 index 0000000000..c17b534ebf --- /dev/null +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -0,0 +1,88 @@ +using System.Linq; +using System.Threading.Tasks; +using Jellyfin.Api.Models.Startup; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Library; +using Microsoft.AspNetCore.Mvc; + +namespace Jellyfin.Api.Controllers +{ + [ApiVersion("1")] + [Route("[controller]")] + public class StartupController : ControllerBase + { + private readonly IServerConfigurationManager _config; + private readonly IUserManager _userManager; + + public StartupController(IServerConfigurationManager config, IUserManager userManager) + { + _config = config; + _userManager = userManager; + } + + [HttpPost("Complete")] + public void Post() + { + _config.Configuration.IsStartupWizardCompleted = true; + _config.SetOptimalValues(); + _config.SaveConfiguration(); + } + + [HttpGet("Configuration")] + public StartupConfiguration Get() + { + var result = new StartupConfiguration + { + UICulture = _config.Configuration.UICulture, + MetadataCountryCode = _config.Configuration.MetadataCountryCode, + PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage + }; + + return result; + } + + [HttpPost("Configuration")] + public void UpdateInitial([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) + { + _config.Configuration.UICulture = uiCulture; + _config.Configuration.MetadataCountryCode = metadataCountryCode; + _config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage; + _config.SaveConfiguration(); + } + + [HttpPost("RemoteAccess")] + public void Post([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) + { + _config.Configuration.EnableRemoteAccess = enableRemoteAccess; + _config.Configuration.EnableUPnP = enableAutomaticPortMapping; + _config.SaveConfiguration(); + } + + [HttpGet("User")] + public StartupUser GetUser() + { + var user = _userManager.Users.First(); + + return new StartupUser + { + Name = user.Name, + Password = user.Password + }; + } + + [HttpPost("User")] + public async Task Post([FromForm] StartupUser startupUser) + { + var user = _userManager.Users.First(); + + user.Name = startupUser.Name; + + _userManager.UpdateUser(user); + + if (!string.IsNullOrEmpty(startupUser.Password)) + { + await _userManager.ChangePassword(user, startupUser.Password).ConfigureAwait(false); + } + } + } +} diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj new file mode 100644 index 0000000000..7a7e49e302 --- /dev/null +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.0 + Library + + + + + + + + + + + + + diff --git a/Jellyfin.Api/Models/Startup/StartupConfiguration.cs b/Jellyfin.Api/Models/Startup/StartupConfiguration.cs new file mode 100644 index 0000000000..08dd59a177 --- /dev/null +++ b/Jellyfin.Api/Models/Startup/StartupConfiguration.cs @@ -0,0 +1,9 @@ +namespace Jellyfin.Api.Models.Startup +{ + public class StartupConfiguration + { + public string UICulture { get; set; } + public string MetadataCountryCode { get; set; } + public string PreferredMetadataLanguage { get; set; } + } +} diff --git a/Jellyfin.Api/Models/Startup/StartupUser.cs b/Jellyfin.Api/Models/Startup/StartupUser.cs new file mode 100644 index 0000000000..93a09e865b --- /dev/null +++ b/Jellyfin.Api/Models/Startup/StartupUser.cs @@ -0,0 +1,8 @@ +namespace Jellyfin.Api.Models.Startup +{ + public class StartupUser + { + public string Name { get; set; } + public string Password { get; set; } + } +} diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 3a9eb7a55e..e69de29bb2 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -1,135 +0,0 @@ -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; - -namespace MediaBrowser.Api -{ - [Route("/Startup/Complete", "POST", Summary = "Reports that the startup wizard has been completed", IsHidden = true)] - public class ReportStartupWizardComplete : IReturnVoid - { - } - - [Route("/Startup/Configuration", "GET", Summary = "Gets initial server configuration", IsHidden = true)] - public class GetStartupConfiguration : IReturn - { - } - - [Route("/Startup/Configuration", "POST", Summary = "Updates initial server configuration", IsHidden = true)] - public class UpdateStartupConfiguration : StartupConfiguration, IReturnVoid - { - } - - [Route("/Startup/RemoteAccess", "POST", Summary = "Updates initial server configuration", IsHidden = true)] - public class UpdateRemoteAccessConfiguration : IReturnVoid - { - public bool EnableRemoteAccess { get; set; } - public bool EnableAutomaticPortMapping { get; set; } - } - - [Route("/Startup/User", "GET", Summary = "Gets initial user info", IsHidden = true)] - public class GetStartupUser : IReturn - { - } - - [Route("/Startup/User", "POST", Summary = "Updates initial user info", IsHidden = true)] - public class UpdateStartupUser : StartupUser - { - } - - [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) - { - _config = config; - _appHost = appHost; - _userManager = userManager; - _mediaEncoder = mediaEncoder; - _httpClient = httpClient; - } - - public void Post(ReportStartupWizardComplete request) - { - _config.Configuration.IsStartupWizardCompleted = true; - _config.SetOptimalValues(); - _config.SaveConfiguration(); - } - - public object Get(GetStartupConfiguration request) - { - var result = new StartupConfiguration - { - UICulture = _config.Configuration.UICulture, - MetadataCountryCode = _config.Configuration.MetadataCountryCode, - PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage - }; - - return result; - } - - public void Post(UpdateStartupConfiguration request) - { - _config.Configuration.UICulture = request.UICulture; - _config.Configuration.MetadataCountryCode = request.MetadataCountryCode; - _config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; - _config.SaveConfiguration(); - } - - public void Post(UpdateRemoteAccessConfiguration request) - { - _config.Configuration.EnableRemoteAccess = request.EnableRemoteAccess; - _config.Configuration.EnableUPnP = request.EnableAutomaticPortMapping; - _config.SaveConfiguration(); - } - - public object Get(GetStartupUser request) - { - var user = _userManager.Users.First(); - - return new StartupUser - { - Name = user.Name, - Password = user.Password - }; - } - - public async Task Post(UpdateStartupUser request) - { - var user = _userManager.Users.First(); - - user.Name = request.Name; - - _userManager.UpdateUser(user); - - if (!string.IsNullOrEmpty(request.Password)) - { - await _userManager.ChangePassword(user, request.Password).ConfigureAwait(false); - } - } - } - - public class StartupConfiguration - { - public string UICulture { get; set; } - public string MetadataCountryCode { get; set; } - public string PreferredMetadataLanguage { get; set; } - } - - public class StartupUser - { - public string Name { get; set; } - public string Password { get; set; } - } -} diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 27c8c1668f..58bfb55f6f 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.3 @@ -51,6 +50,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Drawing.Skia", "Jellyfin.Drawing.Skia\Jellyfin.Drawing.Skia.csproj", "{154872D9-6C12-4007-96E3-8F70A58386CE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Api", "Jellyfin.Api\Jellyfin.Api.csproj", "{DFBEFB4C-DA19-4143-98B7-27320C7F7163}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Common.Tests", "tests\Jellyfin.Common.Tests\Jellyfin.Common.Tests.csproj", "{DF194677-DFD3-42AF-9F75-D44D5A416478}" @@ -89,10 +90,6 @@ Global {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|Any CPU.Build.0 = Debug|Any CPU {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.ActiveCfg = Release|Any CPU {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.Build.0 = Release|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.Build.0 = Release|Any CPU {23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.Build.0 = Debug|Any CPU {23499896-B135-4527-8574-C26E926EA99E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -153,6 +150,10 @@ Global {154872D9-6C12-4007-96E3-8F70A58386CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {154872D9-6C12-4007-96E3-8F70A58386CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {154872D9-6C12-4007-96E3-8F70A58386CE}.Release|Any CPU.Build.0 = Release|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Release|Any CPU.Build.0 = Release|Any CPU {DF194677-DFD3-42AF-9F75-D44D5A416478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DF194677-DFD3-42AF-9F75-D44D5A416478}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF194677-DFD3-42AF-9F75-D44D5A416478}.Release|Any CPU.ActiveCfg = Release|Any CPU From c011fa2ea80a5f7f994649e6257bccf572f299e1 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Jul 2019 18:26:23 +0200 Subject: [PATCH 05/62] Remove old instantiation of serviceProvider in app host --- Emby.Server.Implementations/ApplicationHost.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index a9c4e1fdc9..11ee6d2d20 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -663,6 +663,7 @@ namespace Emby.Server.Implementations .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddApplicationPart(Assembly.Load("Jellyfin.Api")); services.AddApiVersioning(opt => opt.ReportApiVersions = true); + // Merge the external ServiceCollection into ASP.NET DI services.TryAdd(serviceCollection); }) .Configure(app => @@ -929,8 +930,6 @@ namespace Emby.Server.Implementations ((UserDataManager)UserDataManager).Repository = userDataRepo; ItemRepository.Initialize(userDataRepo, UserManager); ((LibraryManager)LibraryManager).ItemRepository = ItemRepository; - - _serviceProvider = serviceCollection.BuildServiceProvider(); } public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths) From 05b7e2280843f25e48c2300b135f171aee0a54ea Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Jul 2019 20:17:00 +0200 Subject: [PATCH 06/62] Add SwaggerUI --- .../ApplicationHost.cs | 27 +++++++++++++++++++ .../Emby.Server.Implementations.csproj | 4 ++- Jellyfin.Api/Controllers/StartupController.cs | 5 ++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 11ee6d2d20..3d2d61225e 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -113,7 +113,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; using ServiceStack; +using Swashbuckle.AspNetCore.SwaggerGen; using OperatingSystem = MediaBrowser.Common.System.OperatingSystem; namespace Emby.Server.Implementations @@ -663,11 +665,36 @@ namespace Emby.Server.Implementations .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddApplicationPart(Assembly.Load("Jellyfin.Api")); services.AddApiVersioning(opt => opt.ReportApiVersions = true); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); + c.DocInclusionPredicate((docName, apiDesc) => + { + if (!apiDesc.TryGetMethodInfo(out var methodInfo)) + { + return false; + } + + // A bit of a hack to make Swagger pick the versioned endpoints instead of the legacy emby endpoints + return methodInfo.DeclaringType?.BaseType == typeof(ControllerBase) && + apiDesc.RelativePath.Contains("api/v"); + }); + }); + // Merge the external ServiceCollection into ASP.NET DI services.TryAdd(serviceCollection); }) .Configure(app => { + app.UseSwagger(); + + // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), + // specifying the Swagger JSON endpoint. + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1"); + }); + app.UseWebSockets(); app.UseResponseCompression(); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 23e35f77e1..26301b379e 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -1,4 +1,4 @@ - + @@ -21,6 +21,7 @@ + @@ -37,6 +38,7 @@ + diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index c17b534ebf..45e4cd5ac8 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api.Controllers { [ApiVersion("1")] - [Route("[controller]")] public class StartupController : ControllerBase { private readonly IServerConfigurationManager _config; @@ -21,7 +20,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("Complete")] - public void Post() + public void CompleteWizard() { _config.Configuration.IsStartupWizardCompleted = true; _config.SetOptimalValues(); @@ -71,7 +70,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("User")] - public async Task Post([FromForm] StartupUser startupUser) + public async Task UpdateUser([FromForm] StartupUser startupUser) { var user = _userManager.Users.First(); From 3f651de24c76f9980fac690e51fa93b3d1163f72 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 16:31:02 +0100 Subject: [PATCH 07/62] Add authentication and remove versioning --- .../ApplicationHost.cs | 58 ++++++++++++++----- .../Emby.Server.Implementations.csproj | 5 +- .../HttpServer/Security/AuthService.cs | 17 +++++- Emby.Server.Implementations/MvcRoutePrefix.cs | 2 +- .../Auth/CustomAuthenticationHandler.cs | 53 +++++++++++++++++ .../FirstTimeSetupOrElevatedHandler.cs | 35 +++++++++++ .../FirstTimeSetupOrElevatedRequirement.cs | 8 +++ .../RequiresElevationHandler.cs | 18 ++++++ .../RequiresElevationRequirement.cs | 9 +++ Jellyfin.Api/BaseJellyfinApiController.cs | 11 ++++ Jellyfin.Api/Controllers/StartupController.cs | 25 ++++---- Jellyfin.Api/Jellyfin.Api.csproj | 34 +++++------ ...guration.cs => StartupConfigurationDto.cs} | 2 +- .../{StartupUser.cs => StartupUserDto.cs} | 2 +- MediaBrowser.Controller/Net/IAuthService.cs | 3 + 15 files changed, 232 insertions(+), 50 deletions(-) create mode 100644 Jellyfin.Api/Auth/CustomAuthenticationHandler.cs create mode 100644 Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs create mode 100644 Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs create mode 100644 Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs create mode 100644 Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs create mode 100644 Jellyfin.Api/BaseJellyfinApiController.cs rename Jellyfin.Api/Models/Startup/{StartupConfiguration.cs => StartupConfigurationDto.cs} (84%) rename Jellyfin.Api/Models/Startup/{StartupUser.cs => StartupUserDto.cs} (81%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3d2d61225e..9227ef61ba 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -47,6 +47,10 @@ using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; +using Jellyfin.Api.Auth; +using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; +using Jellyfin.Api.Auth.RequiresElevationPolicy; +using Jellyfin.Api.Controllers; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -104,11 +108,14 @@ using MediaBrowser.Providers.Subtitles; using MediaBrowser.Providers.TV.TheTVDB; using MediaBrowser.WebDashboard.Api; using MediaBrowser.XbmcMetadata.Providers; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -660,25 +667,45 @@ namespace Emby.Server.Implementations services.AddHttpContextAccessor(); services.AddMvc(opts => { - opts.UseGeneralRoutePrefix("emby", "emby/emby", "api/v{version:apiVersion}"); + var policy = new AuthorizationPolicyBuilder() + .RequireAuthenticatedUser() + .Build(); + opts.Filters.Add(new AuthorizeFilter(policy)); + opts.EnableEndpointRouting = false; + opts.UseGeneralRoutePrefix(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .AddApplicationPart(Assembly.Load("Jellyfin.Api")); - services.AddApiVersioning(opt => opt.ReportApiVersions = true); + .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) // Clear app parts to avoid other assemblies being picked up + .AddApplicationPart(typeof(StartupController).Assembly) + .AddControllersAsServices(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); - c.DocInclusionPredicate((docName, apiDesc) => - { - if (!apiDesc.TryGetMethodInfo(out var methodInfo)) - { - return false; - } + }); - // A bit of a hack to make Swagger pick the versioned endpoints instead of the legacy emby endpoints - return methodInfo.DeclaringType?.BaseType == typeof(ControllerBase) && - apiDesc.RelativePath.Contains("api/v"); - }); + services.AddSingleton(); + services.AddSingleton(); + + // configure custom legacy authentication + services.AddAuthentication("CustomAuthentication") + .AddScheme("CustomAuthentication", null); + + services.AddAuthorizationCore(options => + { + options.AddPolicy( + "RequiresElevation", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new RequiresElevationRequirement()); + }); + options.AddPolicy( + "FirstTimeSetupOrElevated", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); + }); }); // Merge the external ServiceCollection into ASP.NET DI @@ -686,6 +713,7 @@ namespace Emby.Server.Implementations }) .Configure(app => { + app.UseDeveloperExceptionPage(); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), @@ -698,9 +726,9 @@ namespace Emby.Server.Implementations app.UseWebSockets(); app.UseResponseCompression(); - // TODO app.UseMiddleware(); app.Use(ExecuteWebsocketHandlerAsync); + //app.UseAuthentication(); app.UseMvc(); app.Use(ExecuteHttpHandlerAsync); }) @@ -938,7 +966,7 @@ namespace Emby.Server.Implementations serviceCollection.AddSingleton(authContext); serviceCollection.AddSingleton(new SessionContext(UserManager, authContext, SessionManager)); - AuthService = new AuthService(authContext, ServerConfigurationManager, SessionManager, NetworkManager); + AuthService = new AuthService(LoggerFactory, authContext, ServerConfigurationManager, SessionManager, NetworkManager); serviceCollection.AddSingleton(AuthService); SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 26301b379e..e7164342c3 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -21,6 +21,9 @@ + + + @@ -38,7 +41,7 @@ - + diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index 93a61fe67a..81dab83d5e 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Emby.Server.Implementations.SocketSharp; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; @@ -7,22 +8,27 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.HttpServer.Security { public class AuthService : IAuthService { + private readonly ILogger _logger; private readonly IAuthorizationContext _authorizationContext; private readonly ISessionManager _sessionManager; private readonly IServerConfigurationManager _config; private readonly INetworkManager _networkManager; public AuthService( + ILoggerFactory loggerFactory, IAuthorizationContext authorizationContext, IServerConfigurationManager config, ISessionManager sessionManager, INetworkManager networkManager) { + _logger = loggerFactory.CreateLogger(); _authorizationContext = authorizationContext; _config = config; _sessionManager = sessionManager; @@ -34,7 +40,14 @@ namespace Emby.Server.Implementations.HttpServer.Security ValidateUser(request, authAttribtues); } - private void ValidateUser(IRequest request, IAuthenticationAttributes authAttribtues) + public User Authenticate(HttpRequest request, IAuthenticationAttributes authAttributes) + { + var req = new WebSocketSharpRequest(request, null, request.Path, _logger); + var user = ValidateUser(req, authAttributes); + return user; + } + + private User ValidateUser(IRequest request, IAuthenticationAttributes authAttribtues) { // This code is executed before the service var auth = _authorizationContext.GetAuthorizationInfo(request); @@ -81,6 +94,8 @@ namespace Emby.Server.Implementations.HttpServer.Security request.RemoteIp, user); } + + return user; } private void ValidateUserAccess( diff --git a/Emby.Server.Implementations/MvcRoutePrefix.cs b/Emby.Server.Implementations/MvcRoutePrefix.cs index fb26ae09da..974a2a8852 100644 --- a/Emby.Server.Implementations/MvcRoutePrefix.cs +++ b/Emby.Server.Implementations/MvcRoutePrefix.cs @@ -12,7 +12,7 @@ namespace Emby.Server.Implementations opts.Conventions.Insert(0, new RoutePrefixConvention(prefixes)); } - internal class RoutePrefixConvention : IApplicationModelConvention + private class RoutePrefixConvention : IApplicationModelConvention { private readonly AttributeRouteModel[] _routePrefixes; diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs new file mode 100644 index 0000000000..bb6192b03d --- /dev/null +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -0,0 +1,53 @@ +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using MediaBrowser.Controller.Net; +using Microsoft.AspNetCore.Authentication; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Jellyfin.Api.Auth +{ + public class CustomAuthenticationHandler : AuthenticationHandler + { + private readonly IAuthService _authService; + + public CustomAuthenticationHandler( + IAuthService authService, + IOptionsMonitor options, + ILoggerFactory logger, + UrlEncoder encoder, + ISystemClock clock) : base(options, logger, encoder, clock) + { + _authService = authService; + } + + protected override Task HandleAuthenticateAsync() + { + var authenticatedAttribute = new AuthenticatedAttribute(); + try + { + var user = _authService.Authenticate(Request, authenticatedAttribute); + if (user == null) + { + return Task.FromResult(AuthenticateResult.Fail("Invalid user")); + } + + var claims = new[] + { + new Claim(ClaimTypes.Name, user.Name), + new Claim(ClaimTypes.Role, user.Policy.IsAdministrator ? "Administrator" : "User"), + }; + var identity = new ClaimsIdentity(claims, Scheme.Name); + var principal = new ClaimsPrincipal(identity); + var ticket = new AuthenticationTicket(principal, Scheme.Name); + + return Task.FromResult(AuthenticateResult.Success(ticket)); + } + catch (SecurityException ex) + { + return Task.FromResult(AuthenticateResult.Fail(ex)); + } + } + } +} diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs new file mode 100644 index 0000000000..73925cd616 --- /dev/null +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -0,0 +1,35 @@ +using System.Threading.Tasks; +using MediaBrowser.Common.Configuration; +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy +{ + public class FirstTimeSetupOrElevatedHandler : AuthorizationHandler + { + private readonly IConfigurationManager _configurationManager; + + public FirstTimeSetupOrElevatedHandler(IConfigurationManager configurationManager) + { + _configurationManager = configurationManager; + } + + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FirstTimeSetupOrElevatedRequirement firstTimeSetupOrElevatedRequirement) + { + if (!_configurationManager.CommonConfiguration.IsStartupWizardCompleted) + { + context.Succeed(firstTimeSetupOrElevatedRequirement); + } + else if (context.User.IsInRole("Administrator")) + { + // TODO user role enum + context.Succeed(firstTimeSetupOrElevatedRequirement); + } + else + { + context.Fail(); + } + + return Task.CompletedTask; + } + } +} diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs new file mode 100644 index 0000000000..42436c870d --- /dev/null +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy +{ + public class FirstTimeSetupOrElevatedRequirement : IAuthorizationRequirement + { + } +} diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs new file mode 100644 index 0000000000..6948274582 --- /dev/null +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.RequiresElevationPolicy +{ + public class RequiresElevationHandler : AuthorizationHandler + { + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) + { + if (context.User.IsInRole("Administrator")) + { + context.Succeed(requirement); + } + + return Task.CompletedTask; + } + } +} diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs new file mode 100644 index 0000000000..dd51cd3c20 --- /dev/null +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.RequiresElevationPolicy +{ + public class RequiresElevationRequirement : IAuthorizationRequirement + { + + } +} diff --git a/Jellyfin.Api/BaseJellyfinApiController.cs b/Jellyfin.Api/BaseJellyfinApiController.cs new file mode 100644 index 0000000000..796a8039af --- /dev/null +++ b/Jellyfin.Api/BaseJellyfinApiController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Jellyfin.Api +{ + [ApiController] + [Route("[controller]")] + public class BaseJellyfinApiController : ControllerBase + { + + } +} diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 45e4cd5ac8..fb61b8d0b3 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -3,12 +3,13 @@ using System.Threading.Tasks; using Jellyfin.Api.Models.Startup; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api.Controllers { - [ApiVersion("1")] - public class StartupController : ControllerBase + [Authorize(Policy = "FirstTimeSetupOrElevated")] + public class StartupController : BaseJellyfinApiController { private readonly IServerConfigurationManager _config; private readonly IUserManager _userManager; @@ -28,9 +29,9 @@ namespace Jellyfin.Api.Controllers } [HttpGet("Configuration")] - public StartupConfiguration Get() + public StartupConfigurationDto GetStartupConfiguration() { - var result = new StartupConfiguration + var result = new StartupConfigurationDto { UICulture = _config.Configuration.UICulture, MetadataCountryCode = _config.Configuration.MetadataCountryCode, @@ -41,7 +42,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("Configuration")] - public void UpdateInitial([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) + public void UpdateInitialConfiguration([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) { _config.Configuration.UICulture = uiCulture; _config.Configuration.MetadataCountryCode = metadataCountryCode; @@ -50,7 +51,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("RemoteAccess")] - public void Post([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) + public void SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) { _config.Configuration.EnableRemoteAccess = enableRemoteAccess; _config.Configuration.EnableUPnP = enableAutomaticPortMapping; @@ -58,11 +59,11 @@ namespace Jellyfin.Api.Controllers } [HttpGet("User")] - public StartupUser GetUser() + public StartupUserDto GetUser() { var user = _userManager.Users.First(); - return new StartupUser + return new StartupUserDto { Name = user.Name, Password = user.Password @@ -70,17 +71,17 @@ namespace Jellyfin.Api.Controllers } [HttpPost("User")] - public async Task UpdateUser([FromForm] StartupUser startupUser) + public async Task UpdateUser([FromForm] StartupUserDto startupUserDto) { var user = _userManager.Users.First(); - user.Name = startupUser.Name; + user.Name = startupUserDto.Name; _userManager.UpdateUser(user); - if (!string.IsNullOrEmpty(startupUser.Password)) + if (!string.IsNullOrEmpty(startupUserDto.Password)) { - await _userManager.ChangePassword(user, startupUser.Password).ConfigureAwait(false); + await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false); } } } diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 7a7e49e302..647004cb68 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -1,18 +1,16 @@ - - - - netstandard2.0 - Library - - - - - - - - - - - - - + + + + netstandard2.1 + + + + + + + + + + + + diff --git a/Jellyfin.Api/Models/Startup/StartupConfiguration.cs b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs similarity index 84% rename from Jellyfin.Api/Models/Startup/StartupConfiguration.cs rename to Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs index 08dd59a177..769d2e1bb6 100644 --- a/Jellyfin.Api/Models/Startup/StartupConfiguration.cs +++ b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs @@ -1,6 +1,6 @@ namespace Jellyfin.Api.Models.Startup { - public class StartupConfiguration + public class StartupConfigurationDto { public string UICulture { get; set; } public string MetadataCountryCode { get; set; } diff --git a/Jellyfin.Api/Models/Startup/StartupUser.cs b/Jellyfin.Api/Models/Startup/StartupUserDto.cs similarity index 81% rename from Jellyfin.Api/Models/Startup/StartupUser.cs rename to Jellyfin.Api/Models/Startup/StartupUserDto.cs index 93a09e865b..c7c2e8cb04 100644 --- a/Jellyfin.Api/Models/Startup/StartupUser.cs +++ b/Jellyfin.Api/Models/Startup/StartupUserDto.cs @@ -1,6 +1,6 @@ namespace Jellyfin.Api.Models.Startup { - public class StartupUser + public class StartupUserDto { public string Name { get; set; } public string Password { get; set; } diff --git a/MediaBrowser.Controller/Net/IAuthService.cs b/MediaBrowser.Controller/Net/IAuthService.cs index 142f1d91c3..4c9120e0c9 100644 --- a/MediaBrowser.Controller/Net/IAuthService.cs +++ b/MediaBrowser.Controller/Net/IAuthService.cs @@ -1,9 +1,12 @@ +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; namespace MediaBrowser.Controller.Net { public interface IAuthService { void Authenticate(IRequest request, IAuthenticationAttributes authAttribtues); + User Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtues); } } From 706739dbe6c3f22584cf18115b161a9c1882093c Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 19:43:30 +0100 Subject: [PATCH 08/62] Move API stuff to the api project --- .../ApplicationHost.cs | 69 +++--------------- .../Emby.Server.Implementations.csproj | 5 -- .../ApiApplicationBuilderExtensions.cs | 19 +++++ .../ApiServiceCollectionExtensions.cs | 72 +++++++++++++++++++ Jellyfin.Api/Jellyfin.Api.csproj | 2 + .../MvcRoutePrefix.cs | 0 6 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs create mode 100644 Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs rename {Emby.Server.Implementations => Jellyfin.Api}/MvcRoutePrefix.cs (100%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 9227ef61ba..c6cdd4786b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -47,10 +47,7 @@ using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; -using Jellyfin.Api.Auth; -using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; -using Jellyfin.Api.Auth.RequiresElevationPolicy; -using Jellyfin.Api.Controllers; +using Jellyfin.Api.Extensions; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -92,7 +89,6 @@ using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Events; -using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; @@ -108,21 +104,15 @@ using MediaBrowser.Providers.Subtitles; using MediaBrowser.Providers.TV.TheTVDB; using MediaBrowser.WebDashboard.Api; using MediaBrowser.XbmcMetadata.Providers; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; -using ServiceStack; -using Swashbuckle.AspNetCore.SwaggerGen; using OperatingSystem = MediaBrowser.Common.System.OperatingSystem; namespace Emby.Server.Implementations @@ -665,70 +655,29 @@ namespace Emby.Server.Implementations { services.AddResponseCompression(); services.AddHttpContextAccessor(); - services.AddMvc(opts => - { - var policy = new AuthorizationPolicyBuilder() - .RequireAuthenticatedUser() - .Build(); - opts.Filters.Add(new AuthorizeFilter(policy)); - opts.EnableEndpointRouting = false; - opts.UseGeneralRoutePrefix(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) // Clear app parts to avoid other assemblies being picked up - .AddApplicationPart(typeof(StartupController).Assembly) - .AddControllersAsServices(); - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); - }); + services.AddJellyfinApi(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); - services.AddSingleton(); - services.AddSingleton(); + services.AddJellyfinApiSwagger(); // configure custom legacy authentication - services.AddAuthentication("CustomAuthentication") - .AddScheme("CustomAuthentication", null); + services.AddCustomAuthentication(); - services.AddAuthorizationCore(options => - { - options.AddPolicy( - "RequiresElevation", - policy => - { - policy.AddAuthenticationSchemes("CustomAuthentication"); - policy.AddRequirements(new RequiresElevationRequirement()); - }); - options.AddPolicy( - "FirstTimeSetupOrElevated", - policy => - { - policy.AddAuthenticationSchemes("CustomAuthentication"); - policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); - }); - }); + services.AddJellyfinApiAuthorization(); // Merge the external ServiceCollection into ASP.NET DI services.TryAdd(serviceCollection); }) .Configure(app => { - app.UseDeveloperExceptionPage(); - app.UseSwagger(); - - // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), - // specifying the Swagger JSON endpoint. - app.UseSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1"); - }); - app.UseWebSockets(); app.UseResponseCompression(); + // TODO app.UseMiddleware(); app.Use(ExecuteWebsocketHandlerAsync); - //app.UseAuthentication(); + + // TODO use when old API is removed: app.UseAuthentication(); + app.UseJellyfinApiSwagger(); app.UseMvc(); app.Use(ExecuteHttpHandlerAsync); }) diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index e7164342c3..6fc48a2e19 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -21,16 +21,12 @@ - - - - @@ -41,7 +37,6 @@ - diff --git a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs new file mode 100644 index 0000000000..18442bf272 --- /dev/null +++ b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Builder; + +namespace Jellyfin.Api.Extensions +{ + public static class ApiApplicationBuilderExtensions + { + public static IApplicationBuilder UseJellyfinApiSwagger(this IApplicationBuilder applicationBuilder) + { + applicationBuilder.UseSwagger(); + + // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), + // specifying the Swagger JSON endpoint. + return applicationBuilder.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1"); + }); + } + } +} diff --git a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs new file mode 100644 index 0000000000..1c682f8e43 --- /dev/null +++ b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs @@ -0,0 +1,72 @@ +using Emby.Server.Implementations; +using Jellyfin.Api.Auth; +using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; +using Jellyfin.Api.Auth.RequiresElevationPolicy; +using Jellyfin.Api.Controllers; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; + +namespace Jellyfin.Api.Extensions +{ + public static class ApiServiceCollectionExtensions + { + public static IServiceCollection AddJellyfinApiAuthorization(this IServiceCollection serviceCollection) + { + serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); + return serviceCollection.AddAuthorizationCore(options => + { + options.AddPolicy( + "RequiresElevation", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new RequiresElevationRequirement()); + }); + options.AddPolicy( + "FirstTimeSetupOrElevated", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); + }); + }); + } + + public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection) + { + return serviceCollection.AddAuthentication("CustomAuthentication") + .AddScheme("CustomAuthentication", null); + } + + public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl) + { + return serviceCollection.AddMvc(opts => + { + var policy = new AuthorizationPolicyBuilder() + .RequireAuthenticatedUser() + .Build(); + opts.Filters.Add(new AuthorizeFilter(policy)); + opts.EnableEndpointRouting = false; + opts.UseGeneralRoutePrefix(baseUrl); + }) + .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) + // Clear app parts to avoid other assemblies being picked up + .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) + .AddApplicationPart(typeof(StartupController).Assembly) + .AddControllersAsServices(); + } + + public static IServiceCollection AddJellyfinApiSwagger(this IServiceCollection serviceCollection) + { + return serviceCollection.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); + }); + } + } +} diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 647004cb68..d77861cc4a 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -6,7 +6,9 @@ + + diff --git a/Emby.Server.Implementations/MvcRoutePrefix.cs b/Jellyfin.Api/MvcRoutePrefix.cs similarity index 100% rename from Emby.Server.Implementations/MvcRoutePrefix.cs rename to Jellyfin.Api/MvcRoutePrefix.cs From c9669a0d21f37fe06a8838c001a6f93505ba549b Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 19:59:45 +0100 Subject: [PATCH 09/62] Split a long line --- Jellyfin.Api/Controllers/StartupController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index fb61b8d0b3..271745e057 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -42,7 +42,10 @@ namespace Jellyfin.Api.Controllers } [HttpPost("Configuration")] - public void UpdateInitialConfiguration([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) + public void UpdateInitialConfiguration( + [FromForm] string uiCulture, + [FromForm] string metadataCountryCode, + [FromForm] string preferredMetadataLanguage) { _config.Configuration.UICulture = uiCulture; _config.Configuration.MetadataCountryCode = metadataCountryCode; From c2cdbc909ba8371261bb88b5dd313262be755fa3 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 20:31:17 +0100 Subject: [PATCH 10/62] Add style rules and fix it all --- .../Auth/CustomAuthenticationHandler.cs | 17 ++++++++- .../FirstTimeSetupOrElevatedHandler.cs | 14 +++++-- .../FirstTimeSetupOrElevatedRequirement.cs | 3 ++ .../RequiresElevationHandler.cs | 7 +++- .../RequiresElevationRequirement.cs | 4 +- Jellyfin.Api/BaseJellyfinApiController.cs | 4 +- Jellyfin.Api/Controllers/StartupController.cs | 37 ++++++++++++++++++- Jellyfin.Api/Enums/UserRole.cs | 23 ++++++++++++ .../ApiApplicationBuilderExtensions.cs | 8 ++++ .../ApiServiceCollectionExtensions.cs | 26 ++++++++++++- Jellyfin.Api/Jellyfin.Api.csproj | 14 +++++++ .../Models/Startup/StartupConfigurationDto.cs | 14 +++++++ Jellyfin.Api/Models/Startup/StartupUserDto.cs | 10 +++++ Jellyfin.Api/MvcRoutePrefix.cs | 10 ++++- 14 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 Jellyfin.Api/Enums/UserRole.cs diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index bb6192b03d..a753d60838 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -1,6 +1,7 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Jellyfin.Api.Enums; using MediaBrowser.Controller.Net; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.Logging; @@ -8,10 +9,21 @@ using Microsoft.Extensions.Options; namespace Jellyfin.Api.Auth { + /// + /// Custom authentication handler wrapping the legacy authentication. + /// public class CustomAuthenticationHandler : AuthenticationHandler { private readonly IAuthService _authService; + /// + /// Initializes a new instance of the class. + /// + /// The jellyfin authentication service. + /// Options monitor. + /// The logger. + /// The url encoder. + /// The system clock. public CustomAuthenticationHandler( IAuthService authService, IOptionsMonitor options, @@ -22,6 +34,7 @@ namespace Jellyfin.Api.Auth _authService = authService; } + /// protected override Task HandleAuthenticateAsync() { var authenticatedAttribute = new AuthenticatedAttribute(); @@ -36,7 +49,9 @@ namespace Jellyfin.Api.Auth var claims = new[] { new Claim(ClaimTypes.Name, user.Name), - new Claim(ClaimTypes.Role, user.Policy.IsAdministrator ? "Administrator" : "User"), + new Claim( + ClaimTypes.Role, + value: user.Policy.IsAdministrator ? UserRole.Administrator.ToString() : UserRole.User.ToString()) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs index 73925cd616..f07e568dea 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -1,27 +1,35 @@ using System.Threading.Tasks; +using Jellyfin.Api.Enums; using MediaBrowser.Common.Configuration; using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { + /// + /// Authorization handler for requiring first time setup or elevated privileges. + /// public class FirstTimeSetupOrElevatedHandler : AuthorizationHandler { private readonly IConfigurationManager _configurationManager; + /// + /// Initializes a new instance of the class. + /// + /// The jellyfin configuration manager. public FirstTimeSetupOrElevatedHandler(IConfigurationManager configurationManager) { _configurationManager = configurationManager; } - protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FirstTimeSetupOrElevatedRequirement firstTimeSetupOrElevatedRequirement) + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FirstTimeSetupOrElevatedRequirement firstTimeSetupOrElevatedRequirement) { if (!_configurationManager.CommonConfiguration.IsStartupWizardCompleted) { context.Succeed(firstTimeSetupOrElevatedRequirement); } - else if (context.User.IsInRole("Administrator")) + else if (context.User.IsInRole(UserRole.Administrator.ToString())) { - // TODO user role enum context.Succeed(firstTimeSetupOrElevatedRequirement); } else diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs index 42436c870d..a590155420 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs @@ -2,6 +2,9 @@ using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { + /// + /// The authorization requirement, requiring first time setup or elevated privileges, for the authorization handler. + /// public class FirstTimeSetupOrElevatedRequirement : IAuthorizationRequirement { } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs index 6948274582..8674f3e262 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -1,13 +1,18 @@ using System.Threading.Tasks; +using Jellyfin.Api.Enums; using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.RequiresElevationPolicy { + /// + /// Authorization handler for requiring elevated privileges. + /// public class RequiresElevationHandler : AuthorizationHandler { + /// protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) { - if (context.User.IsInRole("Administrator")) + if (context.User.IsInRole(UserRole.Administrator.ToString())) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs index dd51cd3c20..cfff1cc0c5 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs @@ -2,8 +2,10 @@ using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.RequiresElevationPolicy { + /// + /// The authorization requirement for requiring elevated privileges in the authorization handler. + /// public class RequiresElevationRequirement : IAuthorizationRequirement { - } } diff --git a/Jellyfin.Api/BaseJellyfinApiController.cs b/Jellyfin.Api/BaseJellyfinApiController.cs index 796a8039af..1f4508e6cb 100644 --- a/Jellyfin.Api/BaseJellyfinApiController.cs +++ b/Jellyfin.Api/BaseJellyfinApiController.cs @@ -2,10 +2,12 @@ using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api { + /// + /// Base api controller for the API setting a default route. + /// [ApiController] [Route("[controller]")] public class BaseJellyfinApiController : ControllerBase { - } } diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 271745e057..0e7d17a27f 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -8,18 +8,29 @@ using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api.Controllers { + /// + /// The startup wizard controller. + /// [Authorize(Policy = "FirstTimeSetupOrElevated")] public class StartupController : BaseJellyfinApiController { private readonly IServerConfigurationManager _config; private readonly IUserManager _userManager; + /// + /// Initializes a new instance of the class. + /// + /// The server configuration manager. + /// The user manager. public StartupController(IServerConfigurationManager config, IUserManager userManager) { _config = config; _userManager = userManager; } + /// + /// Api endpoint for completing the startup wizard. + /// [HttpPost("Complete")] public void CompleteWizard() { @@ -28,6 +39,10 @@ namespace Jellyfin.Api.Controllers _config.SaveConfiguration(); } + /// + /// Endpoint for getting the initial startup wizard configuration. + /// + /// The initial startup wizard configuration. [HttpGet("Configuration")] public StartupConfigurationDto GetStartupConfiguration() { @@ -41,6 +56,12 @@ namespace Jellyfin.Api.Controllers return result; } + /// + /// Endpoint for updating the initial startup wizard configuration. + /// + /// The UI language culture. + /// The metadata country code. + /// The preferred language for metadata. [HttpPost("Configuration")] public void UpdateInitialConfiguration( [FromForm] string uiCulture, @@ -53,6 +74,11 @@ namespace Jellyfin.Api.Controllers _config.SaveConfiguration(); } + /// + /// Endpoint for (dis)allowing remote access and UPnP. + /// + /// Enable remote access. + /// Enable UPnP. [HttpPost("RemoteAccess")] public void SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) { @@ -61,8 +87,12 @@ namespace Jellyfin.Api.Controllers _config.SaveConfiguration(); } + /// + /// Endpoint for returning the first user. + /// + /// The first user. [HttpGet("User")] - public StartupUserDto GetUser() + public StartupUserDto GetFirstUser() { var user = _userManager.Users.First(); @@ -73,6 +103,11 @@ namespace Jellyfin.Api.Controllers }; } + /// + /// Endpoint for updating the user name and password. + /// + /// The DTO containing username and password. + /// The async task. [HttpPost("User")] public async Task UpdateUser([FromForm] StartupUserDto startupUserDto) { diff --git a/Jellyfin.Api/Enums/UserRole.cs b/Jellyfin.Api/Enums/UserRole.cs new file mode 100644 index 0000000000..05826d9f41 --- /dev/null +++ b/Jellyfin.Api/Enums/UserRole.cs @@ -0,0 +1,23 @@ +namespace Jellyfin.Api.Enums +{ + /// + /// Enum for user roles used in the authentication and authorization for the API. + /// + public enum UserRole + { + /// + /// Guest user. + /// + Guest = 0, + + /// + /// Regular user with no special privileges. + /// + User = 1, + + /// + /// Administrator user with elevated privileges. + /// + Administrator = 2 + } +} diff --git a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs index 18442bf272..f70466ebec 100644 --- a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs +++ b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs @@ -2,8 +2,16 @@ using Microsoft.AspNetCore.Builder; namespace Jellyfin.Api.Extensions { + /// + /// Extensions for adding API specific functionality to the application pipeline. + /// public static class ApiApplicationBuilderExtensions { + /// + /// Adds swagger and swagger UI to the application pipeline. + /// + /// The application builder. + /// The updated application builder. public static IApplicationBuilder UseJellyfinApiSwagger(this IApplicationBuilder applicationBuilder) { applicationBuilder.UseSwagger(); diff --git a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs index 1c682f8e43..38f5f6d390 100644 --- a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs @@ -1,4 +1,3 @@ -using Emby.Server.Implementations; using Jellyfin.Api.Auth; using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; using Jellyfin.Api.Auth.RequiresElevationPolicy; @@ -12,8 +11,16 @@ using Microsoft.OpenApi.Models; namespace Jellyfin.Api.Extensions { + /// + /// API specific extensions for the service collection. + /// public static class ApiServiceCollectionExtensions { + /// + /// Adds jellyfin API authorization policies to the DI container. + /// + /// The service collection. + /// The updated service collection. public static IServiceCollection AddJellyfinApiAuthorization(this IServiceCollection serviceCollection) { serviceCollection.AddSingleton(); @@ -37,12 +44,23 @@ namespace Jellyfin.Api.Extensions }); } + /// + /// Adds custom legacy authentication to the service collection. + /// + /// The service collection. + /// The updated service collection. public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection) { return serviceCollection.AddAuthentication("CustomAuthentication") .AddScheme("CustomAuthentication", null); } + /// + /// Extension method for adding the jellyfin API to the service collection. + /// + /// The service collection. + /// The base url for the API. + /// The MVC builder. public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl) { return serviceCollection.AddMvc(opts => @@ -55,12 +73,18 @@ namespace Jellyfin.Api.Extensions opts.UseGeneralRoutePrefix(baseUrl); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) + // Clear app parts to avoid other assemblies being picked up .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) .AddApplicationPart(typeof(StartupController).Assembly) .AddControllersAsServices(); } + /// + /// Adds Swagger to the service collection. + /// + /// The service collection. + /// The updated service collection. public static IServiceCollection AddJellyfinApiSwagger(this IServiceCollection serviceCollection) { return serviceCollection.AddSwaggerGen(c => diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index d77861cc4a..1cc23c07b4 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -2,6 +2,8 @@ netstandard2.1 + true + true @@ -15,4 +17,16 @@ + + + + + + + + + + ../jellyfin.ruleset + + diff --git a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs index 769d2e1bb6..dac15e412c 100644 --- a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs +++ b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs @@ -1,9 +1,23 @@ namespace Jellyfin.Api.Models.Startup { + /// + /// The startup configuration DTO. + /// public class StartupConfigurationDto { + /// + /// Gets or sets UI language culture. + /// public string UICulture { get; set; } + + /// + /// Gets or sets the metadata country code. + /// public string MetadataCountryCode { get; set; } + + /// + /// Gets or sets the preferred language for the metadata. + /// public string PreferredMetadataLanguage { get; set; } } } diff --git a/Jellyfin.Api/Models/Startup/StartupUserDto.cs b/Jellyfin.Api/Models/Startup/StartupUserDto.cs index c7c2e8cb04..7e890d76a0 100644 --- a/Jellyfin.Api/Models/Startup/StartupUserDto.cs +++ b/Jellyfin.Api/Models/Startup/StartupUserDto.cs @@ -1,8 +1,18 @@ namespace Jellyfin.Api.Models.Startup { + /// + /// The startup user DTO. + /// public class StartupUserDto { + /// + /// Gets or sets the username. + /// public string Name { get; set; } + + /// + /// Gets or sets the user's password. + /// public string Password { get; set; } } } diff --git a/Jellyfin.Api/MvcRoutePrefix.cs b/Jellyfin.Api/MvcRoutePrefix.cs index 974a2a8852..e009730947 100644 --- a/Jellyfin.Api/MvcRoutePrefix.cs +++ b/Jellyfin.Api/MvcRoutePrefix.cs @@ -3,10 +3,18 @@ using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; -namespace Emby.Server.Implementations +namespace Jellyfin.Api { + /// + /// Route prefixing for ASP.NET MVC. + /// public static class MvcRoutePrefix { + /// + /// Adds route prefixes to the MVC conventions. + /// + /// The MVC options. + /// The list of prefixes. public static void UseGeneralRoutePrefix(this MvcOptions opts, params string[] prefixes) { opts.Conventions.Insert(0, new RoutePrefixConvention(prefixes)); From 111b46599a66e81a8449e777cccc516c06b7548d Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 20:46:01 +0100 Subject: [PATCH 11/62] Remove unused reference --- Emby.Server.Implementations/Emby.Server.Implementations.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 6fc48a2e19..9f524a4afd 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -21,7 +21,6 @@ - From dbda76e84252d11c31d4d3f07d5e810ac2096d81 Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 24 Nov 2019 21:27:43 +0900 Subject: [PATCH 12/62] Update readme --- README.md | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 07d49fc517..268b28db7f 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ ---

-Logo banner +Logo Banner

GPL 2.0 License Current Release -Translation status -Azure DevOps builds +Translation Status +Azure Builds Docker Pull Count
Donate -Submit and vote on feature requests +Submit Feature Requests Discuss on our Forum Chat on Matrix Join our Subreddit @@ -23,23 +23,22 @@ Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. It is an alternative to the proprietary Emby and Plex, to provide media from a dedicated server to end-user devices via multiple apps. Jellyfin is descended from Emby's 3.5.2 release and ported to the .NET Core framework to enable full cross-platform support. There are no strings attached, no premium licenses or features, and no hidden agendas: just a team who want to build something better and work together to achieve it. We welcome anyone who is interested in joining us in our quest! -For further details, please see [our documentation page](https://docs.jellyfin.org/). To receive the latest updates, get help with Jellyfin, and join the community, please visit [one of our communication channels on Matrix/Riot or social media](https://docs.jellyfin.org/general/getting-help.html). +For further details, please see [our documentation page](https://docs.jellyfin.org/). To receive the latest updates, get help with Jellyfin, and join the community, please visit [one of our communication channels](https://docs.jellyfin.org/general/getting-help.html). For more information about the project, please see our [about page](https://docs.jellyfin.org/general/about.html). -For more information about the project, please see our [about page](https://docs.jellyfin.org/general/about.html). +Want to get started?
+Choose from Prebuilt Packages or Build from Source, then see our quick start guide.
-

-Want to get started? -Choose from Prebuilt Packages or Build from Source, then see our quick start guide. -

-

-Want to contribute? -Check out our documentation for guidelines. -

-

-New idea or improvement? -Check out our feature request hub. -

-

-Something not working right? -Open an Issue. -

+Something not working right?
+Open an Issue on GitHub.
+ +Want to contribute?
+Check out our documentation for guidelines.
+ +New idea or improvement?
+Check out our feature request hub.
+ +Most of the translations can be found in the web client but we have several other clients that have missing strings. Translations can be improved very easily from our Weblate instance linked above. Look through the following graphic to see if your native language could use some work! + + +Detailed Translation Status + From 27e3cf15588f8ab8fe19aa611d79fa2ccd8ecda8 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 24 Nov 2019 15:27:58 +0100 Subject: [PATCH 13/62] Move appbuilder and service collection to Jellyfin.Server --- .../ApplicationHost.cs | 110 +++--------------- .../HttpServer/HttpListenerHost.cs | 3 +- .../Session/SessionWebSocketListener.cs | 4 +- Jellyfin.Api/Controllers/StartupController.cs | 2 +- .../StartupConfigurationDto.cs | 2 +- .../StartupUserDto.cs | 2 +- .../ApiApplicationBuilderExtensions.cs | 2 +- .../ApiServiceCollectionExtensions.cs | 11 +- Jellyfin.Server/Jellyfin.Server.csproj | 4 + Jellyfin.Server/Program.cs | 70 ++++++++++- Jellyfin.Server/Startup.cs | 81 +++++++++++++ .../IServerApplicationHost.cs | 5 + 12 files changed, 184 insertions(+), 112 deletions(-) rename Jellyfin.Api/Models/{Startup => StartupDtos}/StartupConfigurationDto.cs (93%) rename Jellyfin.Api/Models/{Startup => StartupDtos}/StartupUserDto.cs (89%) rename {Jellyfin.Api => Jellyfin.Server}/Extensions/ApiApplicationBuilderExtensions.cs (96%) rename {Jellyfin.Api => Jellyfin.Server}/Extensions/ApiServiceCollectionExtensions.cs (89%) create mode 100644 Jellyfin.Server/Startup.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index c6cdd4786b..3b9ea41219 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -47,7 +47,6 @@ using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; -using Jellyfin.Api.Extensions; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -232,7 +231,7 @@ namespace Emby.Server.Implementations } } - protected IServiceProvider _serviceProvider; + public IServiceProvider ServiceProvider; /// /// Gets the server configuration manager. @@ -461,7 +460,7 @@ namespace Emby.Server.Implementations /// The type. /// System.Object. public object CreateInstance(Type type) - => ActivatorUtilities.CreateInstance(_serviceProvider, type); + => ActivatorUtilities.CreateInstance(ServiceProvider, type); /// /// Creates an instance of type and resolves all constructor dependencies @@ -469,7 +468,7 @@ namespace Emby.Server.Implementations /// /// The type. /// T. public T CreateInstance() - => ActivatorUtilities.CreateInstance(_serviceProvider); + => ActivatorUtilities.CreateInstance(ServiceProvider); /// /// Creates the instance safe. @@ -481,7 +480,7 @@ namespace Emby.Server.Implementations try { Logger.LogDebug("Creating instance of {Type}", type); - return ActivatorUtilities.CreateInstance(_serviceProvider, type); + return ActivatorUtilities.CreateInstance(ServiceProvider, type); } catch (Exception ex) { @@ -495,7 +494,7 @@ namespace Emby.Server.Implementations /// /// The type /// ``0. - public T Resolve() => _serviceProvider.GetService(); + public T Resolve() => ServiceProvider.GetService(); /// /// Gets the export types. @@ -611,93 +610,14 @@ namespace Emby.Server.Implementations await RegisterResources(serviceCollection).ConfigureAwait(false); - string contentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath; - if (string.IsNullOrEmpty(contentRoot)) + ContentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath; + if (string.IsNullOrEmpty(ContentRoot)) { - contentRoot = ServerConfigurationManager.ApplicationPaths.WebPath; - } - - var host = new WebHostBuilder() - .UseKestrel(options => - { - var addresses = ServerConfigurationManager - .Configuration - .LocalNetworkAddresses - .Select(NormalizeConfiguredLocalAddress) - .Where(i => i != null) - .ToList(); - if (addresses.Any()) - { - foreach (var address in addresses) - { - Logger.LogInformation("Kestrel listening on {ipaddr}", address); - options.Listen(address, HttpPort); - - if (EnableHttps && Certificate != null) - { - options.Listen(address, HttpsPort, listenOptions => listenOptions.UseHttps(Certificate)); - } - } - } - else - { - Logger.LogInformation("Kestrel listening on all interfaces"); - options.ListenAnyIP(HttpPort); - - if (EnableHttps && Certificate != null) - { - options.ListenAnyIP(HttpsPort, listenOptions => listenOptions.UseHttps(Certificate)); - } - } - }) - .UseContentRoot(contentRoot) - .ConfigureServices(services => - { - services.AddResponseCompression(); - services.AddHttpContextAccessor(); - services.AddJellyfinApi(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); - - services.AddJellyfinApiSwagger(); - - // configure custom legacy authentication - services.AddCustomAuthentication(); - - services.AddJellyfinApiAuthorization(); - - // Merge the external ServiceCollection into ASP.NET DI - services.TryAdd(serviceCollection); - }) - .Configure(app => - { - app.UseWebSockets(); - - app.UseResponseCompression(); - - // TODO app.UseMiddleware(); - app.Use(ExecuteWebsocketHandlerAsync); - - // TODO use when old API is removed: app.UseAuthentication(); - app.UseJellyfinApiSwagger(); - app.UseMvc(); - app.Use(ExecuteHttpHandlerAsync); - }) - .Build(); - - _serviceProvider = host.Services; - FindParts(); - - try - { - await host.StartAsync().ConfigureAwait(false); - } - catch - { - Logger.LogError("Kestrel failed to start! This is most likely due to an invalid address or port bind - correct your bind configuration in system.xml and try again."); - throw; + ContentRoot = ServerConfigurationManager.ApplicationPaths.WebPath; } } - private async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func next) + public async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func next) { if (!context.WebSockets.IsWebSocketRequest) { @@ -708,7 +628,7 @@ namespace Emby.Server.Implementations await HttpServer.ProcessWebSocketRequest(context).ConfigureAwait(false); } - private async Task ExecuteHttpHandlerAsync(HttpContext context, Func next) + public async Task ExecuteHttpHandlerAsync(HttpContext context, Func next) { if (context.WebSockets.IsWebSocketRequest) { @@ -1090,9 +1010,9 @@ namespace Emby.Server.Implementations /// /// Finds the parts. /// - protected void FindParts() + public void FindParts() { - InstallationManager = _serviceProvider.GetService(); + InstallationManager = ServiceProvider.GetService(); InstallationManager.PluginInstalled += PluginInstalled; if (!ServerConfigurationManager.Configuration.IsPortAuthorized) @@ -1221,7 +1141,7 @@ namespace Emby.Server.Implementations private CertificateInfo CertificateInfo { get; set; } - protected X509Certificate2 Certificate { get; private set; } + public X509Certificate2 Certificate { get; private set; } private IEnumerable GetUrlPrefixes() { @@ -1605,7 +1525,7 @@ namespace Emby.Server.Implementations return resultList; } - private IPAddress NormalizeConfiguredLocalAddress(string address) + public IPAddress NormalizeConfiguredLocalAddress(string address) { var index = address.Trim('/').IndexOf('/'); @@ -1685,6 +1605,8 @@ namespace Emby.Server.Implementations public int HttpsPort { get; private set; } + public string ContentRoot { get; private set; } + /// /// Shuts down. /// diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index dc1a56e271..6dd016f8a2 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -18,7 +18,6 @@ using MediaBrowser.Model.Events; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -164,7 +163,7 @@ namespace Emby.Server.Implementations.HttpServer { OnReceive = ProcessWebSocketMessageReceived, Url = e.Url, - QueryString = e.QueryString ?? new QueryCollection() + QueryString = e.QueryString }; connection.Closed += OnConnectionClosed; diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs index 63ec757626..930f2d35d3 100644 --- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs @@ -4,7 +4,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Events; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -67,7 +66,7 @@ namespace Emby.Server.Implementations.Session { if (queryString == null) { - throw new ArgumentNullException(nameof(queryString)); + return null; } var token = queryString["api_key"]; @@ -75,6 +74,7 @@ namespace Emby.Server.Implementations.Session { return null; } + var deviceId = queryString["deviceId"]; return _sessionManager.GetSessionByAuthenticationToken(token, deviceId, remoteEndpoint); } diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 0e7d17a27f..50f3dc83cf 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -1,6 +1,6 @@ using System.Linq; using System.Threading.Tasks; -using Jellyfin.Api.Models.Startup; +using Jellyfin.Api.Models.StartupDtos; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using Microsoft.AspNetCore.Authorization; diff --git a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs b/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs similarity index 93% rename from Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs rename to Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs index dac15e412c..d048dad0a1 100644 --- a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs +++ b/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs @@ -1,4 +1,4 @@ -namespace Jellyfin.Api.Models.Startup +namespace Jellyfin.Api.Models.StartupDtos { /// /// The startup configuration DTO. diff --git a/Jellyfin.Api/Models/Startup/StartupUserDto.cs b/Jellyfin.Api/Models/StartupDtos/StartupUserDto.cs similarity index 89% rename from Jellyfin.Api/Models/Startup/StartupUserDto.cs rename to Jellyfin.Api/Models/StartupDtos/StartupUserDto.cs index 7e890d76a0..3a9348037a 100644 --- a/Jellyfin.Api/Models/Startup/StartupUserDto.cs +++ b/Jellyfin.Api/Models/StartupDtos/StartupUserDto.cs @@ -1,4 +1,4 @@ -namespace Jellyfin.Api.Models.Startup +namespace Jellyfin.Api.Models.StartupDtos { /// /// The startup user DTO. diff --git a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs similarity index 96% rename from Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs rename to Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs index f70466ebec..db06eb4552 100644 --- a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Builder; -namespace Jellyfin.Api.Extensions +namespace Jellyfin.Server.Extensions { /// /// Extensions for adding API specific functionality to the application pipeline. diff --git a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs similarity index 89% rename from Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs rename to Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index 38f5f6d390..e5a8937e87 100644 --- a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs @@ -1,15 +1,14 @@ +using Jellyfin.Api; using Jellyfin.Api.Auth; using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; using Jellyfin.Api.Auth.RequiresElevationPolicy; using Jellyfin.Api.Controllers; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; -namespace Jellyfin.Api.Extensions +namespace Jellyfin.Server.Extensions { /// /// API specific extensions for the service collection. @@ -65,14 +64,8 @@ namespace Jellyfin.Api.Extensions { return serviceCollection.AddMvc(opts => { - var policy = new AuthorizationPolicyBuilder() - .RequireAuthenticatedUser() - .Build(); - opts.Filters.Add(new AuthorizeFilter(policy)); - opts.EnableEndpointRouting = false; opts.UseGeneralRoutePrefix(baseUrl); }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) // Clear app parts to avoid other assemblies being picked up .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj index 4238d7fe3e..dc784becfb 100644 --- a/Jellyfin.Server/Jellyfin.Server.csproj +++ b/Jellyfin.Server/Jellyfin.Server.csproj @@ -20,6 +20,10 @@ + + + + diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index e8bd0cd309..998f1125f5 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -18,8 +18,10 @@ using Jellyfin.Drawing.Skia; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Model.Globalization; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Serilog; using Serilog.Extensions.Logging; @@ -164,7 +166,24 @@ namespace Jellyfin.Server appConfig); try { - await appHost.InitAsync(new ServiceCollection()).ConfigureAwait(false); + ServiceCollection serviceCollection = new ServiceCollection(); + await appHost.InitAsync(serviceCollection).ConfigureAwait(false); + + var host = CreateWebHostBuilder(appHost, serviceCollection).Build(); + + // A bit hacky to re-use service provider since ASP.NET doesn't allow a custom service collection. + appHost.ServiceProvider = host.Services; + appHost.FindParts(); + + try + { + await host.StartAsync().ConfigureAwait(false); + } + catch + { + _logger.LogError("Kestrel failed to start! This is most likely due to an invalid address or port bind - correct your bind configuration in system.xml and try again."); + throw; + } appHost.ImageProcessor.ImageEncoder = GetImageEncoder(appPaths, appHost.LocalizationManager); @@ -196,6 +215,55 @@ namespace Jellyfin.Server } } + private static IWebHostBuilder CreateWebHostBuilder(ApplicationHost appHost, IServiceCollection serviceCollection) + { + return new WebHostBuilder() + .UseKestrel(options => + { + var addresses = appHost.ServerConfigurationManager + .Configuration + .LocalNetworkAddresses + .Select(appHost.NormalizeConfiguredLocalAddress) + .Where(i => i != null) + .ToList(); + if (addresses.Any()) + { + foreach (var address in addresses) + { + _logger.LogInformation("Kestrel listening on {ipaddr}", address); + options.Listen(address, appHost.HttpPort); + + if (appHost.EnableHttps && appHost.Certificate != null) + { + options.Listen( + address, + appHost.HttpsPort, + listenOptions => listenOptions.UseHttps(appHost.Certificate)); + } + } + } + else + { + _logger.LogInformation("Kestrel listening on all interfaces"); + options.ListenAnyIP(appHost.HttpPort); + + if (appHost.EnableHttps && appHost.Certificate != null) + { + options.ListenAnyIP( + appHost.HttpsPort, + listenOptions => listenOptions.UseHttps(appHost.Certificate)); + } + } + }) + .UseContentRoot(appHost.ContentRoot) + .ConfigureServices(services => + { + // Merge the external ServiceCollection into ASP.NET DI + services.TryAdd(serviceCollection); + }) + .UseStartup(); + } + /// /// Create the data, config and log paths from the variety of inputs(command line args, /// environment variables) or decide on what default to use. For Windows it's %AppPath% diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs new file mode 100644 index 0000000000..3ee5fb8b50 --- /dev/null +++ b/Jellyfin.Server/Startup.cs @@ -0,0 +1,81 @@ +using Jellyfin.Server.Extensions; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Jellyfin.Server +{ + /// + /// Startup configuration for the Kestrel webhost. + /// + public class Startup + { + private readonly IServerConfigurationManager _serverConfigurationManager; + + /// + /// Initializes a new instance of the class. + /// + /// The server configuration manager. + public Startup(IServerConfigurationManager serverConfigurationManager) + { + _serverConfigurationManager = serverConfigurationManager; + } + + /// + /// Configures the service collection for the webhost. + /// + /// The service collection. + public void ConfigureServices(IServiceCollection services) + { + services.AddResponseCompression(); + services.AddHttpContextAccessor(); + services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/')); + + services.AddJellyfinApiSwagger(); + + // configure custom legacy authentication + services.AddCustomAuthentication(); + + services.AddJellyfinApiAuthorization(); + } + + /// + /// Configures the app builder for the webhost. + /// + /// The application builder. + /// The webhost environment. + /// The server application host. + public void Configure( + IApplicationBuilder app, + IWebHostEnvironment env, + IServerApplicationHost serverApplicationHost) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseWebSockets(); + + app.UseResponseCompression(); + + // TODO app.UseMiddleware(); + app.Use(serverApplicationHost.ExecuteWebsocketHandlerAsync); + + // TODO use when old API is removed: app.UseAuthentication(); + app.UseJellyfinApiSwagger(); + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + app.Use(serverApplicationHost.ExecuteHttpHandlerAsync); + } + } +} diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 61b2c15ae2..b3c56bdd5f 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common; using MediaBrowser.Model.System; +using Microsoft.AspNetCore.Http; namespace MediaBrowser.Controller { @@ -87,5 +88,9 @@ namespace MediaBrowser.Controller string ExpandVirtualPath(string path); string ReverseVirtualPath(string path); + + Task ExecuteHttpHandlerAsync(HttpContext context, Func next); + + Task ExecuteWebsocketHandlerAsync(HttpContext context, Func next); } } From 6a6bfa6da9ac4b2c54d0eba88e3d30c4147a2379 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 24 Nov 2019 17:08:28 +0100 Subject: [PATCH 14/62] Fix possible nullref when updating packages --- .../Emby.Server.Implementations.csproj | 1 + .../ScheduledTasks/Tasks/PluginUpdateTask.cs | 4 +++- .../Updates/InstallationManager.cs | 18 +++++++++++------- .../Updates/IInstallationManager.cs | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 214ea5aff9..385664737d 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -36,6 +36,7 @@ + diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs index fe8deae595..909fffb1ff 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs @@ -52,7 +52,9 @@ namespace Emby.Server.Implementations.ScheduledTasks { progress.Report(0); - var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(cancellationToken).ConfigureAwait(false)).ToList(); + var packagesToInstall = await _installationManager.GetAvailablePluginUpdates(cancellationToken) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); progress.Report(10); diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 1c54022682..09a5a0dca8 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.Updates // Package not found. if (package == null) { - return null; + return Enumerable.Empty(); } return GetCompatibleVersions( @@ -190,19 +190,23 @@ namespace Emby.Server.Implementations.Updates } /// - public async Task> GetAvailablePluginUpdates(CancellationToken cancellationToken = default) + public async IAsyncEnumerable GetAvailablePluginUpdates(CancellationToken cancellationToken = default) { var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false); var systemUpdateLevel = _applicationHost.SystemUpdateLevel; // Figure out what needs to be installed - return _applicationHost.Plugins.Select(x => + foreach (var plugin in _applicationHost.Plugins) { - var compatibleversions = GetCompatibleVersions(catalog, x.Name, x.Id, x.Version, systemUpdateLevel); - return compatibleversions.FirstOrDefault(y => y.Version > x.Version); - }).Where(x => x != null) - .Where(x => !CompletedInstallations.Any(y => string.Equals(y.AssemblyGuid, x.guid, StringComparison.OrdinalIgnoreCase))); + var compatibleversions = GetCompatibleVersions(catalog, plugin.Name, plugin.Id, plugin.Version, systemUpdateLevel); + var version = compatibleversions.FirstOrDefault(y => y.Version > plugin.Version); + if (version != null + && !CompletedInstallations.Any(x => string.Equals(x.AssemblyGuid, version.guid, StringComparison.OrdinalIgnoreCase))) + { + yield return version; + } + } } /// diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs index 524d8f3c69..e49812f150 100644 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ b/MediaBrowser.Common/Updates/IInstallationManager.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Common.Updates /// /// The cancellation token. /// The available plugin updates. - Task> GetAvailablePluginUpdates(CancellationToken cancellationToken = default); + IAsyncEnumerable GetAvailablePluginUpdates(CancellationToken cancellationToken = default); /// /// Installs the package. From 2af5922af06c865d676e817112ef76a92a23e1b6 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 24 Nov 2019 18:25:43 +0100 Subject: [PATCH 15/62] Fix review comments --- Emby.Server.Implementations/ApplicationHost.cs | 7 +++++-- .../HttpServer/Security/AuthService.cs | 4 ++-- Jellyfin.Api/Auth/CustomAuthenticationHandler.cs | 4 ++-- .../FirstTimeSetupOrElevatedHandler.cs | 4 ++-- .../RequiresElevationHandler.cs | 4 ++-- Jellyfin.Api/{Enums => Constants}/UserRole.cs | 12 ++++++------ Jellyfin.Api/Jellyfin.Api.csproj | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) rename Jellyfin.Api/{Enums => Constants}/UserRole.cs (51%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3b9ea41219..4fd08258af 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -231,7 +231,10 @@ namespace Emby.Server.Implementations } } - public IServiceProvider ServiceProvider; + /// + /// Gets or sets the service provider. + /// + public IServiceProvider ServiceProvider { get; set; } /// /// Gets the server configuration manager. @@ -835,7 +838,7 @@ namespace Emby.Server.Implementations serviceCollection.AddSingleton(authContext); serviceCollection.AddSingleton(new SessionContext(UserManager, authContext, SessionManager)); - AuthService = new AuthService(LoggerFactory, authContext, ServerConfigurationManager, SessionManager, NetworkManager); + AuthService = new AuthService(LoggerFactory.CreateLogger(), authContext, ServerConfigurationManager, SessionManager, NetworkManager); serviceCollection.AddSingleton(AuthService); SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory); diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index 81dab83d5e..594f464989 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -22,13 +22,13 @@ namespace Emby.Server.Implementations.HttpServer.Security private readonly INetworkManager _networkManager; public AuthService( - ILoggerFactory loggerFactory, + ILogger logger, IAuthorizationContext authorizationContext, IServerConfigurationManager config, ISessionManager sessionManager, INetworkManager networkManager) { - _logger = loggerFactory.CreateLogger(); + _logger = logger; _authorizationContext = authorizationContext; _config = config; _sessionManager = sessionManager; diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index a753d60838..6ca992c61b 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -1,7 +1,7 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Jellyfin.Api.Enums; +using Jellyfin.Api.Constants; using MediaBrowser.Controller.Net; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.Logging; @@ -51,7 +51,7 @@ namespace Jellyfin.Api.Auth new Claim(ClaimTypes.Name, user.Name), new Claim( ClaimTypes.Role, - value: user.Policy.IsAdministrator ? UserRole.Administrator.ToString() : UserRole.User.ToString()) + value: user.Policy.IsAdministrator ? UserRole.Administrator : UserRole.User) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs index f07e568dea..2450e7bc73 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Jellyfin.Api.Enums; +using Jellyfin.Api.Constants; using MediaBrowser.Common.Configuration; using Microsoft.AspNetCore.Authorization; @@ -28,7 +28,7 @@ namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { context.Succeed(firstTimeSetupOrElevatedRequirement); } - else if (context.User.IsInRole(UserRole.Administrator.ToString())) + else if (context.User.IsInRole(UserRole.Administrator)) { context.Succeed(firstTimeSetupOrElevatedRequirement); } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs index 8674f3e262..108c29a2cc 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Jellyfin.Api.Enums; +using Jellyfin.Api.Constants; using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.RequiresElevationPolicy @@ -12,7 +12,7 @@ namespace Jellyfin.Api.Auth.RequiresElevationPolicy /// protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) { - if (context.User.IsInRole(UserRole.Administrator.ToString())) + if (context.User.IsInRole(UserRole.Administrator)) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Enums/UserRole.cs b/Jellyfin.Api/Constants/UserRole.cs similarity index 51% rename from Jellyfin.Api/Enums/UserRole.cs rename to Jellyfin.Api/Constants/UserRole.cs index 05826d9f41..b1da615575 100644 --- a/Jellyfin.Api/Enums/UserRole.cs +++ b/Jellyfin.Api/Constants/UserRole.cs @@ -1,23 +1,23 @@ -namespace Jellyfin.Api.Enums +namespace Jellyfin.Api.Constants { /// - /// Enum for user roles used in the authentication and authorization for the API. + /// Constants for user roles used in the authentication and authorization for the API. /// - public enum UserRole + public static class UserRole { /// /// Guest user. /// - Guest = 0, + public const string Guest = "Guest"; /// /// Regular user with no special privileges. /// - User = 1, + public const string User = "User"; /// /// Administrator user with elevated privileges. /// - Administrator = 2 + public const string Administrator = "Administrator"; } } diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 1cc23c07b4..6ad97b60f3 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -19,7 +19,7 @@ - + From 47a4f2f387825d9c249c53b3796a43e3eac52b58 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 24 Nov 2019 19:25:46 +0100 Subject: [PATCH 16/62] Fix more review comments --- .../ApplicationHost.cs | 21 +++++++++++++------ .../Auth/CustomAuthenticationHandler.cs | 2 +- .../FirstTimeSetupOrElevatedHandler.cs | 2 +- .../RequiresElevationHandler.cs | 2 +- .../Constants/AuthenticationSchemes.cs | 13 ++++++++++++ Jellyfin.Api/Constants/Policies.cs | 18 ++++++++++++++++ .../Constants/{UserRole.cs => UserRoles.cs} | 2 +- Jellyfin.Api/Controllers/StartupController.cs | 3 ++- Jellyfin.Api/Jellyfin.Api.csproj | 6 +++--- .../ApiServiceCollectionExtensions.cs | 13 ++++++------ 10 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 Jellyfin.Api/Constants/AuthenticationSchemes.cs create mode 100644 Jellyfin.Api/Constants/Policies.cs rename Jellyfin.Api/Constants/{UserRole.cs => UserRoles.cs} (94%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 4fd08258af..c5f8b58c44 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -236,6 +236,21 @@ namespace Emby.Server.Implementations /// public IServiceProvider ServiceProvider { get; set; } + /// + /// Gets the http port for the webhost. + /// + public int HttpPort { get; private set; } + + /// + /// Gets the https port for the webhost. + /// + public int HttpsPort { get; private set; } + + /// + /// Gets the content root for the webhost. + /// + public string ContentRoot { get; private set; } + /// /// Gets the server configuration manager. /// @@ -1604,12 +1619,6 @@ namespace Emby.Server.Implementations ? Environment.MachineName : ServerConfigurationManager.Configuration.ServerName; - public int HttpPort { get; private set; } - - public int HttpsPort { get; private set; } - - public string ContentRoot { get; private set; } - /// /// Shuts down. /// diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index 6ca992c61b..26f7d9d2dd 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -51,7 +51,7 @@ namespace Jellyfin.Api.Auth new Claim(ClaimTypes.Name, user.Name), new Claim( ClaimTypes.Role, - value: user.Policy.IsAdministrator ? UserRole.Administrator : UserRole.User) + value: user.Policy.IsAdministrator ? UserRoles.Administrator : UserRoles.User) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs index 2450e7bc73..34aa5d12c8 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -28,7 +28,7 @@ namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { context.Succeed(firstTimeSetupOrElevatedRequirement); } - else if (context.User.IsInRole(UserRole.Administrator)) + else if (context.User.IsInRole(UserRoles.Administrator)) { context.Succeed(firstTimeSetupOrElevatedRequirement); } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs index 108c29a2cc..2d3bb1aa48 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -12,7 +12,7 @@ namespace Jellyfin.Api.Auth.RequiresElevationPolicy /// protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) { - if (context.User.IsInRole(UserRole.Administrator)) + if (context.User.IsInRole(UserRoles.Administrator)) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Constants/AuthenticationSchemes.cs b/Jellyfin.Api/Constants/AuthenticationSchemes.cs new file mode 100644 index 0000000000..bac3379e71 --- /dev/null +++ b/Jellyfin.Api/Constants/AuthenticationSchemes.cs @@ -0,0 +1,13 @@ +namespace Jellyfin.Api.Constants +{ + /// + /// Authentication schemes for user authentication in the API. + /// + public static class AuthenticationSchemes + { + /// + /// Scheme name for the custom legacy authentication. + /// + public const string CustomAuthentication = "CustomAuthentication"; + } +} diff --git a/Jellyfin.Api/Constants/Policies.cs b/Jellyfin.Api/Constants/Policies.cs new file mode 100644 index 0000000000..e2b383f75d --- /dev/null +++ b/Jellyfin.Api/Constants/Policies.cs @@ -0,0 +1,18 @@ +namespace Jellyfin.Api.Constants +{ + /// + /// Policies for the API authorization. + /// + public static class Policies + { + /// + /// Policy name for requiring first time setup or elevated privileges. + /// + public const string FirstTimeSetupOrElevated = "FirstTimeOrElevated"; + + /// + /// Policy name for requiring elevated privileges. + /// + public const string RequiresElevation = "RequiresElevation"; + } +} diff --git a/Jellyfin.Api/Constants/UserRole.cs b/Jellyfin.Api/Constants/UserRoles.cs similarity index 94% rename from Jellyfin.Api/Constants/UserRole.cs rename to Jellyfin.Api/Constants/UserRoles.cs index b1da615575..d9a536e7d7 100644 --- a/Jellyfin.Api/Constants/UserRole.cs +++ b/Jellyfin.Api/Constants/UserRoles.cs @@ -3,7 +3,7 @@ namespace Jellyfin.Api.Constants /// /// Constants for user roles used in the authentication and authorization for the API. /// - public static class UserRole + public static class UserRoles { /// /// Guest user. diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 50f3dc83cf..1014c8c56b 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using Jellyfin.Api.Constants; using Jellyfin.Api.Models.StartupDtos; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; @@ -11,7 +12,7 @@ namespace Jellyfin.Api.Controllers /// /// The startup wizard controller. /// - [Authorize(Policy = "FirstTimeSetupOrElevated")] + [Authorize(Policy = Policies.FirstTimeSetupOrElevated)] public class StartupController : BaseJellyfinApiController { private readonly IServerConfigurationManager _config; diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 6ad97b60f3..a2818b45da 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -20,9 +20,9 @@ - - - + + + diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index e5a8937e87..dd4f9cd238 100644 --- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using Jellyfin.Api; using Jellyfin.Api.Auth; using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; using Jellyfin.Api.Auth.RequiresElevationPolicy; +using Jellyfin.Api.Constants; using Jellyfin.Api.Controllers; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; @@ -27,17 +28,17 @@ namespace Jellyfin.Server.Extensions return serviceCollection.AddAuthorizationCore(options => { options.AddPolicy( - "RequiresElevation", + Policies.RequiresElevation, policy => { - policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddAuthenticationSchemes(AuthenticationSchemes.CustomAuthentication); policy.AddRequirements(new RequiresElevationRequirement()); }); options.AddPolicy( - "FirstTimeSetupOrElevated", + Policies.FirstTimeSetupOrElevated, policy => { - policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddAuthenticationSchemes(AuthenticationSchemes.CustomAuthentication); policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); }); }); @@ -50,8 +51,8 @@ namespace Jellyfin.Server.Extensions /// The updated service collection. public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection) { - return serviceCollection.AddAuthentication("CustomAuthentication") - .AddScheme("CustomAuthentication", null); + return serviceCollection.AddAuthentication(AuthenticationSchemes.CustomAuthentication) + .AddScheme(AuthenticationSchemes.CustomAuthentication, null); } /// From f12c9bf3b0d1ad4c6bdcafc1ac97cee191a517fc Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 24 Nov 2019 23:01:18 +0100 Subject: [PATCH 17/62] Added tag building support to Windows Web build. --- .ci/azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index c829da98af..13cc67528f 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -200,8 +200,8 @@ jobs: persistCredentials: true - task: CmdLine@2 - displayName: "Check out web" - condition: and(succeeded(), or(contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion')) + displayName: "Check out web (master, release or tag)" + condition: and(succeeded(), or(contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master'), contains(variables['Build.SourceBranch'], 'tag')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion')) inputs: script: 'git clone --single-branch --branch $(Build.SourceBranchName) --depth=1 https://github.com/jellyfin/jellyfin-web.git $(Agent.TempDirectory)/jellyfin-web' From 69d76af054dd41cb729edc6d866413aa7e2de622 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Mon, 25 Nov 2019 10:56:23 +0100 Subject: [PATCH 18/62] dlna GetPathValue Forgot to update this last time, just copied the code from `MediaBrowser.Api/BaseApiService.cs` --- Emby.Dlna/Api/DlnaServerService.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 1f137e620c..7ddcaf7e6e 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -214,11 +214,13 @@ namespace Emby.Dlna.Api string baseUrl = _configurationManager.Configuration.BaseUrl; // backwards compatibility - if (baseUrl.Length == 0 - && (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) - || string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase))) + if (baseUrl.Length == 0) { - index++; + if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) + || string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase)) + { + index++; + } } else if (string.Equals(first, baseUrl.Remove(0, 1))) { @@ -234,7 +236,7 @@ namespace Emby.Dlna.Api return pathInfo[index]; } - private List Parse(string pathUri) + private static string[] Parse(string pathUri) { var actionParts = pathUri.Split(new[] { "://" }, StringSplitOptions.None); @@ -248,7 +250,7 @@ namespace Emby.Dlna.Api var args = pathInfo.Split('/'); - return args.Skip(1).ToList(); + return args.Skip(1).ToArray(); } public object Get(GetIcon request) From a4c2886ac0c8eced40cf0e49c128e5b17208e9fb Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Mon, 25 Nov 2019 11:04:51 +0100 Subject: [PATCH 19/62] Fix master build I was wrong, it did break... --- .../ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs index 91d990137d..72b524df02 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs @@ -47,7 +47,7 @@ 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; } From 3221e837f9758e90b91f0f6760af1c3b67e04c2d Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 17 Nov 2019 23:05:39 +0100 Subject: [PATCH 20/62] * 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 1f137e620c..f64c89389f 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 5175898ab7..78d69b3380 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 36adc0b9c4..e6d2b7ae06 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 2b22129f33..e1b031e45e 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 91d990137d..f197734d46 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 0542807af7..1a3657c920 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 5f1f6c5b16..41ee314df3 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 f5845f4e03..f4724e7745 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 d28bfaff59..92c32f2ad5 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 718f537bc5..316be04a03 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 697a84f5c2..8b63decd22 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 d56023fe2c..62c4ff43f2 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 f4813e7132..e231e80425 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 201efe7371..25f23bcd1e 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 922bd8ed69..45b7d0c100 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 6d3037b24c..f1b88de643 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 24d4751c59..5a37d37302 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 084b20bc15..ea5a99892d 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 a1d69cd2b0..5e86f04a82 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 5d524b1859..1847f7fde6 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 cee96f7ab4..0cc5e112f4 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 7266bf9f92..c071b42f75 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 2b9a64e975..4b44961392 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 3b2e18852a..6a69d26568 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 b52f8a547f..95a37dfc56 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 c1c6ffc2e2..7abedd8ef6 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 6e4443dbef..8adf9c6216 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 2cd3a1003c..fd6c0b7da5 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 875f0a8de9..cacec8d640 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 1e5a932107..b0333eb9ce 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 4bd729aac8..1e9cd33136 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 27eb67ee61..8fdc6fa497 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 9ecb5fe8c5..f09c7e9f2a 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 ca5a73ff1b..bb12ab1f0d 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 4a5f4025ba..6d12a1ccd6 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 da8f99a3dd..c3032416b8 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 dfe4b2b8e9..11527007b5 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 97c1a7a496..4ada90d095 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 cfc8a283d9..fc5603d277 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 b3d8bfe59f..b1450e2cc8 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 483bf98fb8..953b00e35a 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 af61887b20..16d3268b9b 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 35bcbea5cd..078af3e305 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 b7e94b73f2..2bd387229a 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 6c67d4fb15..0a3dc19dc6 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 6caf3b4809..700861c554 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 3a9eb7a55e..714157fd74 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 1878f51d05..c4a7ae78e7 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 4e857eafcf..91f85db6ff 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 4d6ce10143..f95fa7ca0b 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 56184e18b7..3a56ba701e 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 0000000000..6d944d19ea --- /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 1340bd8ef7..ac2eca733d 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 a30f8adfed..adb0a440f6 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 e3c9ae58e7..9fa222d324 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 0c04d02dd8..13bb88ca8d 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 b4a3026480..1511420d3d 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 94f5262b08..e9caca14aa 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 2024e9e637..853eada256 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 b40a92a7c3..9d1cf5d9ee 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 890acc9311..683ce5d09d 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 da0bf6dcb0..2ec08f5787 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 d62049ce9e..0fffb06223 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 0ee0fd219f..07b9aff1b8 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 2c0a0b443b..e1b01b012c 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 474036f5cb..46b6d5a947 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 ce4e3f5302..eb735d31a9 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 eea2e3a718..8d92c9f6f2 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 b8abe49e3e..9de6fef619 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 d84bc2abbc..981c3a53a1 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 27c8c1668f..dea4bf68fa 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 0000000000..b01d1af1f0 --- /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 0000000000..1671b8d797 --- /dev/null +++ b/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp3.0 + false + + + + + + + + + + + + + + + From 65ae4eb0dd4f08a621f4d30c18af930785a60841 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 26 Nov 2019 00:32:14 +0900 Subject: [PATCH 21/62] fix some html tags in the readme --- README.md | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 268b28db7f..bbac4dd25a 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,39 @@

Logo Banner -

-GPL 2.0 License -Current Release -Translation Status -Azure Builds -Docker Pull Count +
+
+ +GPL 2.0 License + + +Current Release + + +Translation Status + + +Azure Builds + + +Docker Pull Count +
-Donate -Submit Feature Requests -Discuss on our Forum -Chat on Matrix -Join our Subreddit + +Donate + + +Submit Feature Requests + + +Discuss on our Forum + + +Chat on Matrix + + +Join our Subreddit +

--- @@ -37,7 +58,7 @@ Check out ou New idea or improvement?
Check out our
feature request hub.
-Most of the translations can be found in the web client but we have several other clients that have missing strings. Translations can be improved very easily from our Weblate instance linked above. Look through the following graphic to see if your native language could use some work! +Most of the translations can be found in the web client but we have several other clients that have missing strings. Translations can be improved very easily from our Weblate instance. Look through the following graphic to see if your native language could use some work! Detailed Translation Status From 94ef239de0087ed4df490673b5b395d8b0111e8f Mon Sep 17 00:00:00 2001 From: ferferga Date: Mon, 25 Nov 2019 23:09:23 +0100 Subject: [PATCH 22/62] Add full Raspberry Pi hardware decoding support --- .../MediaEncoding/EncodingHelper.cs | 16 ++++++++++++++-- .../Encoder/EncoderValidator.cs | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 349e371a7b..0664bdd984 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -2529,13 +2529,25 @@ namespace MediaBrowser.Controller.MediaEncoding case "h264": if (_mediaEncoder.SupportsDecoder("h264_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) { - return "-c:v h264_mmal"; + return "-c:v h264_mmal "; } break; case "mpeg2video": if (_mediaEncoder.SupportsDecoder("mpeg2_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase)) { - return "-c:v mpeg2_mmal"; + return "-c:v mpeg2_mmal "; + } + break; + case "mpeg4": + if (_mediaEncoder.SupportsDecoder("mpeg4_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v mpeg4_mmal "; + } + break; + case "vc1": + if (_mediaEncoder.SupportsDecoder("vc1_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v vc1_mmal "; } break; } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 3620abfee7..1feca0ec92 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -18,7 +18,10 @@ namespace MediaBrowser.MediaEncoding.Encoder "h264_qsv", "hevc_qsv", "mpeg2_qsv", + "mpeg2_mmal", + "mpeg4_mmal", "vc1_qsv", + "vc1_mmal", "h264_cuvid", "hevc_cuvid", "dts", @@ -26,6 +29,7 @@ namespace MediaBrowser.MediaEncoding.Encoder "aac", "mp3", "h264", + "h264_mmal", "hevc" }; From 50a535e6e4f53e8aa003e7c5343e8341a06686dc Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 26 Nov 2019 09:47:26 +0100 Subject: [PATCH 23/62] Use .Net Core 3.0 in all docker images --- deployment/debian-package-arm64/Dockerfile.amd64 | 6 +++--- deployment/debian-package-arm64/Dockerfile.arm64 | 4 ++-- deployment/debian-package-arm64/docker-build.sh | 4 ++-- deployment/debian-package-armhf/Dockerfile.amd64 | 6 +++--- deployment/debian-package-armhf/Dockerfile.armhf | 4 ++-- deployment/debian-package-armhf/docker-build.sh | 4 ++-- deployment/debian-package-x64/Dockerfile | 4 ++-- deployment/debian-package-x64/docker-build.sh | 4 ++-- deployment/debian-package-x64/pkg-src/control | 2 +- deployment/linux-x64/Dockerfile | 4 ++-- deployment/macos/Dockerfile | 4 ++-- deployment/portable/Dockerfile | 4 ++-- deployment/ubuntu-package-arm64/Dockerfile.amd64 | 6 +++--- deployment/ubuntu-package-arm64/Dockerfile.arm64 | 4 ++-- deployment/ubuntu-package-arm64/docker-build.sh | 4 ++-- deployment/ubuntu-package-armhf/Dockerfile.amd64 | 6 +++--- deployment/ubuntu-package-armhf/Dockerfile.armhf | 4 ++-- deployment/ubuntu-package-armhf/docker-build.sh | 4 ++-- deployment/ubuntu-package-x64/docker-build.sh | 4 ++-- deployment/win-x64/Dockerfile | 4 ++-- deployment/win-x86/Dockerfile | 4 ++-- 21 files changed, 45 insertions(+), 45 deletions(-) diff --git a/deployment/debian-package-arm64/Dockerfile.amd64 b/deployment/debian-package-arm64/Dockerfile.amd64 index 7a674d029b..069c2ed352 100644 --- a/deployment/debian-package-arm64/Dockerfile.amd64 +++ b/deployment/debian-package-arm64/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/debian-package-arm64/Dockerfile.arm64 b/deployment/debian-package-arm64/Dockerfile.arm64 index 2b43d70aca..d2e1c1f121 100644 --- a/deployment/debian-package-arm64/Dockerfile.arm64 +++ b/deployment/debian-package-arm64/Dockerfile.arm64 @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/1560f31a-d566-4de0-9fef-1a40b2b2a748/163f23fb8018e064034f3492f54358f1/dotnet-sdk-2.2.401-linux-arm64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/89fb60b1-3359-414e-94cf-359f57f37c7c/256e6dac8f44f9bad01f23f9a27b01ee/dotnet-sdk-3.0.101-linux-arm64.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 diff --git a/deployment/debian-package-arm64/docker-build.sh b/deployment/debian-package-arm64/docker-build.sh index 1c75ece8eb..b36b928ba1 100755 --- a/deployment/debian-package-arm64/docker-build.sh +++ b/deployment/debian-package-arm64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/debian-package-armhf/Dockerfile.amd64 b/deployment/debian-package-armhf/Dockerfile.amd64 index 2f15d2fcdf..d0afbed51c 100644 --- a/deployment/debian-package-armhf/Dockerfile.amd64 +++ b/deployment/debian-package-armhf/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/debian-package-armhf/Dockerfile.armhf b/deployment/debian-package-armhf/Dockerfile.armhf index 17a6fa0a1d..dd9e3297e8 100644 --- a/deployment/debian-package-armhf/Dockerfile.armhf +++ b/deployment/debian-package-armhf/Dockerfile.armhf @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/3cb1d917-19cc-4399-9a53-03bb5de223f6/be3e011601610d9fe0a4f6b1962378ea/dotnet-sdk-2.2.401-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/0b30374c-3d52-45ad-b4e5-9a39d0bf5bf0/deb17f7b32968b3a2186650711456152/dotnet-sdk-3.0.101-linux-arm.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 diff --git a/deployment/debian-package-armhf/docker-build.sh b/deployment/debian-package-armhf/docker-build.sh index df35345bdd..1b3af9a937 100755 --- a/deployment/debian-package-armhf/docker-build.sh +++ b/deployment/debian-package-armhf/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/debian-package-x64/Dockerfile b/deployment/debian-package-x64/Dockerfile index 172bbe8fc5..36e8cf3224 100644 --- a/deployment/debian-package-x64/Dockerfile +++ b/deployment/debian-package-x64/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-x64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/debian-package-x64/docker-build.sh b/deployment/debian-package-x64/docker-build.sh index 9781879f6f..bb27bc7ee8 100755 --- a/deployment/debian-package-x64/docker-build.sh +++ b/deployment/debian-package-x64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB dpkg-buildpackage -us -uc diff --git a/deployment/debian-package-x64/pkg-src/control b/deployment/debian-package-x64/pkg-src/control index e8c9d2e23b..07e82069fc 100644 --- a/deployment/debian-package-x64/pkg-src/control +++ b/deployment/debian-package-x64/pkg-src/control @@ -3,7 +3,7 @@ Section: misc Priority: optional Maintainer: Jellyfin Team Build-Depends: debhelper (>= 9), - dotnet-sdk-2.2, + dotnet-sdk-3.0, libc6-dev, libcurl4-openssl-dev, libfontconfig1-dev, diff --git a/deployment/linux-x64/Dockerfile b/deployment/linux-x64/Dockerfile index d634b55de9..169d07a574 100644 --- a/deployment/linux-x64/Dockerfile +++ b/deployment/linux-x64/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/linux-x64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/macos/Dockerfile b/deployment/macos/Dockerfile index 406a2d853e..c8b4e80bfc 100644 --- a/deployment/macos/Dockerfile +++ b/deployment/macos/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/macos ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/portable/Dockerfile b/deployment/portable/Dockerfile index bdbf978fe7..17297a298f 100644 --- a/deployment/portable/Dockerfile +++ b/deployment/portable/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/portable ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/ubuntu-package-arm64/Dockerfile.amd64 b/deployment/ubuntu-package-arm64/Dockerfile.amd64 index 44e67a4062..fac00ffeab 100644 --- a/deployment/ubuntu-package-arm64/Dockerfile.amd64 +++ b/deployment/ubuntu-package-arm64/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/69937b49-a877-4ced-81e6-286620b390ab/8ab938cf6f5e83b2221630354160ef21/dotnet-sdk-2.2.104-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/ubuntu-package-arm64/Dockerfile.arm64 b/deployment/ubuntu-package-arm64/Dockerfile.arm64 index 58f3d3aaff..304cd0efd0 100644 --- a/deployment/ubuntu-package-arm64/Dockerfile.arm64 +++ b/deployment/ubuntu-package-arm64/Dockerfile.arm64 @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/d9f37b73-df8d-4dfa-a905-b7648d3401d0/6312573ac13d7a8ddc16e4058f7d7dc5/dotnet-sdk-2.2.104-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/89fb60b1-3359-414e-94cf-359f57f37c7c/256e6dac8f44f9bad01f23f9a27b01ee/dotnet-sdk-3.0.101-linux-arm64.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 diff --git a/deployment/ubuntu-package-arm64/docker-build.sh b/deployment/ubuntu-package-arm64/docker-build.sh index 1c75ece8eb..b36b928ba1 100755 --- a/deployment/ubuntu-package-arm64/docker-build.sh +++ b/deployment/ubuntu-package-arm64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/ubuntu-package-armhf/Dockerfile.amd64 b/deployment/ubuntu-package-armhf/Dockerfile.amd64 index d69a75b503..3c60537759 100644 --- a/deployment/ubuntu-package-armhf/Dockerfile.amd64 +++ b/deployment/ubuntu-package-armhf/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/69937b49-a877-4ced-81e6-286620b390ab/8ab938cf6f5e83b2221630354160ef21/dotnet-sdk-2.2.104-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/ubuntu-package-armhf/Dockerfile.armhf b/deployment/ubuntu-package-armhf/Dockerfile.armhf index 5d1025080a..1d019bf2df 100644 --- a/deployment/ubuntu-package-armhf/Dockerfile.armhf +++ b/deployment/ubuntu-package-armhf/Dockerfile.armhf @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/d9f37b73-df8d-4dfa-a905-b7648d3401d0/6312573ac13d7a8ddc16e4058f7d7dc5/dotnet-sdk-2.2.104-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/0b30374c-3d52-45ad-b4e5-9a39d0bf5bf0/deb17f7b32968b3a2186650711456152/dotnet-sdk-3.0.101-linux-arm.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 diff --git a/deployment/ubuntu-package-armhf/docker-build.sh b/deployment/ubuntu-package-armhf/docker-build.sh index df35345bdd..1b3af9a937 100755 --- a/deployment/ubuntu-package-armhf/docker-build.sh +++ b/deployment/ubuntu-package-armhf/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/ubuntu-package-x64/docker-build.sh b/deployment/ubuntu-package-x64/docker-build.sh index 9781879f6f..bb27bc7ee8 100755 --- a/deployment/ubuntu-package-x64/docker-build.sh +++ b/deployment/ubuntu-package-x64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB dpkg-buildpackage -us -uc diff --git a/deployment/win-x64/Dockerfile b/deployment/win-x64/Dockerfile index 7f64c7daed..0f85a07d86 100644 --- a/deployment/win-x64/Dockerfile +++ b/deployment/win-x64/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/win-x64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 diff --git a/deployment/win-x86/Dockerfile b/deployment/win-x86/Dockerfile index fb5f5d6b61..f07a8d7fe3 100644 --- a/deployment/win-x86/Dockerfile +++ b/deployment/win-x86/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/win-x86 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +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 From 080b1069914cdca8a4e342ce9fa0a58578248420 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 26 Nov 2019 10:20:45 +0100 Subject: [PATCH 24/62] Update Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs Co-Authored-By: Vasily --- .../FirstTimeSetupOrElevatedRequirement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs index a590155420..51ba637b60 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { /// - /// The authorization requirement, requiring first time setup or elevated privileges, for the authorization handler. + /// The authorization requirement, requiring incomplete first time setup or elevated privileges, for the authorization handler. /// public class FirstTimeSetupOrElevatedRequirement : IAuthorizationRequirement { From 22f50de1fe32889be185f2c5065a0d743ceb3fbb Mon Sep 17 00:00:00 2001 From: Leo Verto Date: Mon, 25 Nov 2019 02:18:03 +0000 Subject: [PATCH 25/62] Translated using Weblate (German) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/de/ --- Emby.Server.Implementations/Localization/Core/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index 888712709e..12bc16d746 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -23,7 +23,7 @@ "HeaderFavoriteEpisodes": "Lieblingsepisoden", "HeaderFavoriteShows": "Lieblingsserien", "HeaderFavoriteSongs": "Lieblingslieder", - "HeaderLiveTV": "Live-TV", + "HeaderLiveTV": "Live TV", "HeaderNextUp": "Als Nächstes", "HeaderRecordingGroups": "Aufnahme-Gruppen", "HomeVideos": "Heimvideos", From 1606706070d56e4ad60f740b6b3317b47791bc2b Mon Sep 17 00:00:00 2001 From: Mehmet Can Kanpolat Date: Mon, 25 Nov 2019 12:53:26 +0000 Subject: [PATCH 26/62] Translated using Weblate (Turkish) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/tr/ --- .../Localization/Core/tr.json | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/tr.json b/Emby.Server.Implementations/Localization/Core/tr.json index 4768e3634e..24366b070a 100644 --- a/Emby.Server.Implementations/Localization/Core/tr.json +++ b/Emby.Server.Implementations/Localization/Core/tr.json @@ -45,46 +45,46 @@ "NameSeasonNumber": "Sezon {0}", "NameSeasonUnknown": "Bilinmeyen Sezon", "NewVersionIsAvailable": "Jellyfin Sunucusunun yeni bir versiyonu indirmek için hazır.", - "NotificationOptionApplicationUpdateAvailable": "Application update available", - "NotificationOptionApplicationUpdateInstalled": "Application update installed", + "NotificationOptionApplicationUpdateAvailable": "Uygulama güncellemesi mevcut", + "NotificationOptionApplicationUpdateInstalled": "Uygulama güncellemesi yüklendi", "NotificationOptionAudioPlayback": "Audio playback started", "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", "NotificationOptionCameraImageUploaded": "Camera image uploaded", - "NotificationOptionInstallationFailed": "Kurulum hatası", + "NotificationOptionInstallationFailed": "Yükleme başarısız oldu", "NotificationOptionNewLibraryContent": "New content added", - "NotificationOptionPluginError": "Plugin failure", - "NotificationOptionPluginInstalled": "Plugin installed", - "NotificationOptionPluginUninstalled": "Plugin uninstalled", - "NotificationOptionPluginUpdateInstalled": "Plugin update installed", - "NotificationOptionServerRestartRequired": "Server restart required", - "NotificationOptionTaskFailed": "Scheduled task failure", - "NotificationOptionUserLockedOut": "User locked out", + "NotificationOptionPluginError": "Eklenti hatası", + "NotificationOptionPluginInstalled": "Eklenti yüklendi", + "NotificationOptionPluginUninstalled": "Eklenti kaldırıldı", + "NotificationOptionPluginUpdateInstalled": "Eklenti güncellemesi yüklendi", + "NotificationOptionServerRestartRequired": "Sunucu yeniden başlatma gerekli", + "NotificationOptionTaskFailed": "Zamanlanmış görev hatası", + "NotificationOptionUserLockedOut": "Kullanıcı kitlendi", "NotificationOptionVideoPlayback": "Video playback started", "NotificationOptionVideoPlaybackStopped": "Video playback stopped", "Photos": "Fotoğraflar", "Playlists": "Çalma listeleri", - "Plugin": "Plugin", - "PluginInstalledWithName": "{0} was installed", - "PluginUninstalledWithName": "{0} was uninstalled", - "PluginUpdatedWithName": "{0} was updated", - "ProviderValue": "Provider: {0}", - "ScheduledTaskFailedWithName": "{0} failed", - "ScheduledTaskStartedWithName": "{0} started", - "ServerNameNeedsToBeRestarted": "{0} needs to be restarted", + "Plugin": "Eklenti", + "PluginInstalledWithName": "{0} yüklendi", + "PluginUninstalledWithName": "{0} kaldırıldı", + "PluginUpdatedWithName": "{0} güncellendi", + "ProviderValue": "Sağlayıcı: {0}", + "ScheduledTaskFailedWithName": "{0} başarısız oldu", + "ScheduledTaskStartedWithName": "{0} başladı", + "ServerNameNeedsToBeRestarted": "{0} yeniden başlatılması gerekiyor", "Shows": "Diziler", "Songs": "Şarkılar", - "StartupEmbyServerIsLoading": "Jellyfin Server is loading. Please try again shortly.", + "StartupEmbyServerIsLoading": "Jellyfin Sunucusu yükleniyor. Lütfen kısa süre sonra tekrar deneyin.", "SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}", "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}", "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}", "Sync": "Eşitle", "System": "System", "TvShows": "TV Shows", - "User": "User", - "UserCreatedWithName": "User {0} has been created", - "UserDeletedWithName": "User {0} has been deleted", - "UserDownloadingItemWithValues": "{0} is downloading {1}", - "UserLockedOutWithName": "User {0} has been locked out", + "User": "Kullanıcı", + "UserCreatedWithName": "Kullanıcı {0} yaratıldı", + "UserDeletedWithName": "Kullanıcı {0} silindi", + "UserDownloadingItemWithValues": "{0} indiriliyor {1}", + "UserLockedOutWithName": "Kullanıcı {0} kitlendi", "UserOfflineFromDevice": "{0} has disconnected from {1}", "UserOnlineFromDevice": "{0} is online from {1}", "UserPasswordChangedWithName": "Password has been changed for user {0}", From 42ffddc26932bcf2da762bf4fe1ec4bdc42e8166 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 1 Nov 2019 18:38:54 +0100 Subject: [PATCH 27/62] 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 efaaa116c6..b622a31674 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 0c513ea127..a30e939121 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 ffaeaa541a..7be72319ea 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 67bb25b077..f5ca8e1448 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 6b0fd2dc6c..4a6e5cfd75 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 b27f84848b..93000ae127 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 718129ef09..f5da0d0183 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 c10f00f9b8..6016fed079 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 bafa68818b..62aeb9bcb9 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 151670074a..ceca878225 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 3c7cbb1159..2712fc8c5e 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 303a8ac7b1..5774c04153 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 0244c4a684..485adf14a8 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 c5a77ce5b5..2b8a5bdc56 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 2291345bee..4def7ca40d 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 fec7d161e5..776074b728 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 4e392f6c9c..30f29beee4 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 f7743a3c25..2a8f2d6b33 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 4c34244100..5c094ddd2d 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 2f6c1288da..d474f1c6ba 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 c76ae0cac0..c87793072e 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 26ac17bdc2..22955850ab 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 26798993b4..a042320c91 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 0e67affbfc..7044b1d194 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 7344dc72f3..f0d43e665b 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 36d4418512..2393f1f458 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 175a8f3ce4..bfa49ac5ff 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 14aadaaae7..02ad3c1a89 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 6c0e32e05b..3d622b3fce 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 19ea093594..d69b0909dd 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 a2619367d5..e290c62e16 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 24906220d1..5f938e59a8 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 0186da9e1e..dbb3503c41 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 3a7516dca9..1ca25ba6f3 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 3ff8d99685..9ccbf7535a 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 8be6db87d9..9cef77dc87 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 5b90dc1fb0..24ac6d1fda 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 bae3422ff6..e431da1481 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 2da0191ddb..50233ea485 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 2c7e81361d..c1c8c3eb30 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 6dd016f8a2..2aefc9fe5d 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 b5cfb6b09a..f9eb3a8979 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 005656d2c1..5015937256 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 320136d11a..8b9028f6bc 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 3e731366e2..5e0466629d 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 594f464989..58421aaf19 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 4574486049..129faeaab0 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 81e11d3122..166952c646 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 194d04441a..eda2360285 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 54a16040f7..5d657b8a7c 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 48b34a3a04..3150f3367c 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 40e8ed5dc7..4b5b11f01f 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 aeb541c540..b1fb8cc635 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 ae8371a32f..442fbabd17 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 5e5e91bb39..e6696b8c4c 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 7c8c079e39..40b397edc2 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 6afcf567a8..fd50f156af 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 8bdb387843..bc1398332d 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 c043568d55..94f60ea621 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 fa6bbcf91c..6c6fbd86f3 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 a3c879f121..9a71868988 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 7913df5e40..dc61aacd7b 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 528636ecd3..4de06f84a3 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 33e6f24341..ed7d8aa402 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 7a26e0c37d..22193c997e 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 0a6c8845d1..6b9f4d052c 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 10602fea76..72e120b254 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 d3a81f6228..4fdf73b773 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 e39192d286..9d4bd9e593 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 3ce1da81a2..4a2d210d5d 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 74e9b83049..ee7e849295 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 541b13cbe1..c4bb861b8d 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 f22554ee57..0b93ebeb81 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 e48b6c9671..7dbce7a6ef 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 a6db407140..32ccc7fdd4 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 922bd4bbb8..e4bc4a4690 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 1b63b00a34..6c76900557 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 d06cda177f..dbadaeefbe 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 3bc5c2fb2a..06d1dd89dc 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 f8459c61f1..6478f1873e 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 9ac4bf7618..1b5c83f1eb 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 710e5d0433..23a28e9360 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 137a010ec3..8275c873af 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 2efae0fe44..00899c3361 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 93ded9e7bd..887eef5c36 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 60691349a11f541958e0b2247c9abc13cb40c9fb Mon Sep 17 00:00:00 2001 From: excelite Date: Thu, 28 Nov 2019 11:20:46 +0100 Subject: [PATCH 28/62] added filesize limit for logfiles and a maximum logfile count --- Jellyfin.Server/Resources/Configuration/logging.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jellyfin.Server/Resources/Configuration/logging.json b/Jellyfin.Server/Resources/Configuration/logging.json index d169912774..e85ef05afd 100644 --- a/Jellyfin.Server/Resources/Configuration/logging.json +++ b/Jellyfin.Server/Resources/Configuration/logging.json @@ -17,6 +17,9 @@ "Args": { "path": "%JELLYFIN_LOG_DIR%//log_.log", "rollingInterval": "Day", + "retainedFileCountLimit": 3, + "rollOnFileSizeLimit": true, + "fileSizeLimitBytes": 100000000, "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" } } From 6f45d959512be3c8114681f819fdb1e2db1e978c Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 28 Nov 2019 17:46:06 +0100 Subject: [PATCH 29/62] Minor improvements to network code --- .../Networking/NetworkManager.cs | 40 ++++------------- .../SocketSharp/WebSocketSharpRequest.cs | 44 ++++++++++--------- MediaBrowser.Api/EnvironmentService.cs | 36 +++------------ MediaBrowser.Common/Net/INetworkManager.cs | 15 ------- 4 files changed, 39 insertions(+), 96 deletions(-) diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index 0b3567986d..1d8d3cf395 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -7,8 +7,6 @@ using System.Net.NetworkInformation; using System.Net.Sockets; using System.Threading.Tasks; using MediaBrowser.Common.Net; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Networking @@ -55,10 +53,7 @@ namespace Emby.Server.Implementations.Networking _macAddresses = null; } - if (NetworkChanged != null) - { - NetworkChanged(this, EventArgs.Empty); - } + NetworkChanged?.Invoke(this, EventArgs.Empty); } public IPAddress[] GetLocalIpAddresses(bool ignoreVirtualInterface = true) @@ -261,10 +256,10 @@ namespace Emby.Server.Implementations.Networking return true; } - if (normalizedSubnet.IndexOf('/') != -1) + if (normalizedSubnet.Contains('/', StringComparison.Ordinal)) { - var ipnetwork = IPNetwork.Parse(normalizedSubnet); - if (ipnetwork.Contains(address)) + var ipNetwork = IPNetwork.Parse(normalizedSubnet); + if (ipNetwork.Contains(address)) { return true; } @@ -455,9 +450,9 @@ namespace Emby.Server.Implementations.Networking public bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask) { - IPAddress network1 = GetNetworkAddress(address1, subnetMask); - IPAddress network2 = GetNetworkAddress(address2, subnetMask); - return network1.Equals(network2); + IPAddress network1 = GetNetworkAddress(address1, subnetMask); + IPAddress network2 = GetNetworkAddress(address2, subnetMask); + return network1.Equals(network2); } private IPAddress GetNetworkAddress(IPAddress address, IPAddress subnetMask) @@ -473,7 +468,7 @@ namespace Emby.Server.Implementations.Networking byte[] broadcastAddress = new byte[ipAdressBytes.Length]; for (int i = 0; i < broadcastAddress.Length; i++) { - broadcastAddress[i] = (byte)(ipAdressBytes[i] & (subnetMaskBytes[i])); + broadcastAddress[i] = (byte)(ipAdressBytes[i] & subnetMaskBytes[i]); } return new IPAddress(broadcastAddress); @@ -513,24 +508,5 @@ namespace Emby.Server.Implementations.Networking return null; } - - /// - /// Gets the network shares. - /// - /// The path. - /// IEnumerable{NetworkShare}. - public virtual IEnumerable GetNetworkShares(string path) - { - return new List(); - } - - /// - /// Gets available devices within the domain - /// - /// PC's in the Domain - public virtual IEnumerable GetNetworkDevices() - { - return new List(); - } } } diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index 690ba0be4a..a1d41c8958 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -14,9 +14,9 @@ namespace Emby.Server.Implementations.SocketSharp { public class WebSocketSharpRequest : IHttpRequest { - public const string FormUrlEncoded = "application/x-www-form-urlencoded"; - public const string MultiPartFormData = "multipart/form-data"; - public const string Soap11 = "text/xml; charset=utf-8"; + private const string FormUrlEncoded = "application/x-www-form-urlencoded"; + private const string MultiPartFormData = "multipart/form-data"; + private const string Soap11 = "text/xml; charset=utf-8"; private string _remoteIp; private Dictionary _items; @@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.SocketSharp get => _responseContentType ?? (_responseContentType = GetResponseContentType(Request)); - set => this._responseContentType = value; + set => _responseContentType = value; } public string PathInfo => Request.Path.Value; @@ -90,7 +90,6 @@ namespace Emby.Server.Implementations.SocketSharp public bool IsLocal => Request.HttpContext.Connection.LocalIpAddress.Equals(Request.HttpContext.Connection.RemoteIpAddress); - public string HttpMethod => Request.Method; public string Verb => HttpMethod; @@ -123,24 +122,29 @@ namespace Emby.Server.Implementations.SocketSharp return specifiedContentType; } - const string serverDefaultContentType = "application/json"; + const string ServerDefaultContentType = "application/json"; var acceptContentTypes = httpReq.Headers.GetCommaSeparatedValues(HeaderNames.Accept); string defaultContentType = null; if (HasAnyOfContentTypes(httpReq, FormUrlEncoded, MultiPartFormData)) { - defaultContentType = serverDefaultContentType; + defaultContentType = ServerDefaultContentType; } var acceptsAnything = false; var hasDefaultContentType = defaultContentType != null; if (acceptContentTypes != null) { - foreach (var acceptsType in acceptContentTypes) + foreach (ReadOnlySpan acceptsType in acceptContentTypes) { - // TODO: @bond move to Span when Span.Split lands - // https://github.com/dotnet/corefx/issues/26528 - var contentType = acceptsType?.Split(';')[0].Trim(); + ReadOnlySpan contentType = acceptsType; + var index = contentType.IndexOf(';'); + if (index != -1) + { + contentType = contentType.Slice(0, index); + } + + contentType = contentType.Trim(); acceptsAnything = contentType.Equals("*/*", StringComparison.OrdinalIgnoreCase); if (acceptsAnything) @@ -157,7 +161,7 @@ namespace Emby.Server.Implementations.SocketSharp } else { - return serverDefaultContentType; + return ServerDefaultContentType; } } } @@ -168,7 +172,7 @@ namespace Emby.Server.Implementations.SocketSharp } // We could also send a '406 Not Acceptable', but this is allowed also - return serverDefaultContentType; + return ServerDefaultContentType; } public static bool HasAnyOfContentTypes(HttpRequest request, params string[] contentTypes) @@ -196,12 +200,12 @@ namespace Emby.Server.Implementations.SocketSharp private static string GetQueryStringContentType(HttpRequest httpReq) { - ReadOnlySpan format = httpReq.Query["format"].ToString().AsSpan(); + ReadOnlySpan format = httpReq.Query["format"].ToString(); if (format == null) { - const int formatMaxLength = 4; - ReadOnlySpan pi = httpReq.Path.ToString().AsSpan(); - if (pi == null || pi.Length <= formatMaxLength) + const int FormatMaxLength = 4; + ReadOnlySpan pi = httpReq.Path.ToString(); + if (pi == null || pi.Length <= FormatMaxLength) { return null; } @@ -212,18 +216,18 @@ namespace Emby.Server.Implementations.SocketSharp } format = LeftPart(pi, '/'); - if (format.Length > formatMaxLength) + if (format.Length > FormatMaxLength) { return null; } } format = LeftPart(format, '.'); - if (format.Contains("json".AsSpan(), StringComparison.OrdinalIgnoreCase)) + if (format.Contains("json", StringComparison.OrdinalIgnoreCase)) { return "application/json"; } - else if (format.Contains("xml".AsSpan(), StringComparison.OrdinalIgnoreCase)) + else if (format.Contains("xml", StringComparison.OrdinalIgnoreCase)) { return "application/xml"; } diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index f4813e7132..a63ef9f053 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -52,6 +52,7 @@ namespace MediaBrowser.Api public bool? IsFile { get; set; } } + [Obsolete] [Route("/Environment/NetworkShares", "GET", Summary = "Gets shares from a network device")] public class GetNetworkShares : IReturn> { @@ -192,22 +193,18 @@ namespace MediaBrowser.Api var networkPrefix = UncSeparatorString + UncSeparatorString; - if (path.StartsWith(networkPrefix, StringComparison.OrdinalIgnoreCase) && path.LastIndexOf(UncSeparator) == 1) + if (path.StartsWith(networkPrefix, StringComparison.OrdinalIgnoreCase) + && path.LastIndexOf(UncSeparator) == 1) { - return ToOptimizedResult(GetNetworkShares(path).OrderBy(i => i.Path).ToList()); + return ToOptimizedResult(Array.Empty()); } return ToOptimizedResult(GetFileSystemEntries(request).ToList()); } + [Obsolete] public object Get(GetNetworkShares request) - { - var path = request.Path; - - var shares = GetNetworkShares(path).OrderBy(i => i.Path).ToList(); - - return ToOptimizedResult(shares); - } + => ToOptimizedResult(Array.Empty()); /// /// Gets the specified request. @@ -241,26 +238,7 @@ namespace MediaBrowser.Api /// The request. /// System.Object. public object Get(GetNetworkDevices request) - { - var result = _networkManager.GetNetworkDevices().ToList(); - - return ToOptimizedResult(result); - } - - /// - /// Gets the network shares. - /// - /// The path. - /// IEnumerable{FileSystemEntryInfo}. - private IEnumerable GetNetworkShares(string path) - { - return _networkManager.GetNetworkShares(path).Where(s => s.ShareType == NetworkShareType.Disk).Select(c => new FileSystemEntryInfo - { - Name = c.Name, - Path = Path.Combine(path, c.Name), - Type = FileSystemEntryType.NetworkShare - }); - } + => ToOptimizedResult(Array.Empty()); /// /// Gets the file system entries. diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs index 97504a471f..0b99dc9103 100644 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ b/MediaBrowser.Common/Net/INetworkManager.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Net; using System.Net.NetworkInformation; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; namespace MediaBrowser.Common.Net { @@ -36,19 +34,6 @@ namespace MediaBrowser.Common.Net /// true if [is in private address space] [the specified endpoint]; otherwise, false. bool IsInPrivateAddressSpace(string endpoint); - /// - /// Gets the network shares. - /// - /// The path. - /// IEnumerable{NetworkShare}. - IEnumerable GetNetworkShares(string path); - - /// - /// Gets available devices within the domain - /// - /// PC's in the Domain - IEnumerable GetNetworkDevices(); - /// /// Determines whether [is in local network] [the specified endpoint]. /// From 12dd2c51a7182898d2529a73676214e1f0dbc7a3 Mon Sep 17 00:00:00 2001 From: excelite Date: Fri, 29 Nov 2019 23:03:59 +0100 Subject: [PATCH 30/62] added required nuget package to enable serilog based centralized logging in gelf fromat --- Jellyfin.Server/Jellyfin.Server.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj index 7d97a1f20f..110028176c 100644 --- a/Jellyfin.Server/Jellyfin.Server.csproj +++ b/Jellyfin.Server/Jellyfin.Server.csproj @@ -46,6 +46,7 @@ + From be14b91f2371ccaf5a93dde80dbeedcda623137e Mon Sep 17 00:00:00 2001 From: Mehmet Can Kanpolat Date: Wed, 27 Nov 2019 16:41:49 +0000 Subject: [PATCH 31/62] Translated using Weblate (Turkish) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/tr/ --- .../Localization/Core/tr.json | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/tr.json b/Emby.Server.Implementations/Localization/Core/tr.json index 24366b070a..eb1c2623f7 100644 --- a/Emby.Server.Implementations/Localization/Core/tr.json +++ b/Emby.Server.Implementations/Localization/Core/tr.json @@ -25,33 +25,33 @@ "HeaderFavoriteSongs": "Favori Şarkılar", "HeaderLiveTV": "Canlı TV", "HeaderNextUp": "Sonraki hafta", - "HeaderRecordingGroups": "Recording Groups", - "HomeVideos": "Home videos", - "Inherit": "Inherit", - "ItemAddedWithName": "{0} was added to the library", - "ItemRemovedWithName": "{0} was removed from the library", - "LabelIpAddressValue": "Ip adresi: {0}", + "HeaderRecordingGroups": "Kayıt Grupları", + "HomeVideos": "Ev videoları", + "Inherit": "Devral", + "ItemAddedWithName": "{0} kütüphaneye eklendi", + "ItemRemovedWithName": "{0} kütüphaneden silindi", + "LabelIpAddressValue": "IP adresi: {0}", "LabelRunningTimeValue": "Çalışma süresi: {0}", - "Latest": "Latest", + "Latest": "En son", "MessageApplicationUpdated": "Jellyfin Sunucusu güncellendi", - "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}", - "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated", - "MessageServerConfigurationUpdated": "Server configuration has been updated", - "MixedContent": "Mixed content", + "MessageApplicationUpdatedTo": "Jellyfin Sunucusu {0} olarak güncellendi", + "MessageNamedServerConfigurationUpdatedWithValue": "Sunucu ayarları kısım {0} güncellendi", + "MessageServerConfigurationUpdated": "Sunucu ayarları güncellendi", + "MixedContent": "Karışık içerik", "Movies": "Filmler", "Music": "Müzik", "MusicVideos": "Müzik videoları", - "NameInstallFailed": "{0} kurulum başarısız", + "NameInstallFailed": "{0} kurulumu başarısız", "NameSeasonNumber": "Sezon {0}", "NameSeasonUnknown": "Bilinmeyen Sezon", "NewVersionIsAvailable": "Jellyfin Sunucusunun yeni bir versiyonu indirmek için hazır.", "NotificationOptionApplicationUpdateAvailable": "Uygulama güncellemesi mevcut", "NotificationOptionApplicationUpdateInstalled": "Uygulama güncellemesi yüklendi", - "NotificationOptionAudioPlayback": "Audio playback started", - "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", - "NotificationOptionCameraImageUploaded": "Camera image uploaded", + "NotificationOptionAudioPlayback": "Ses çalma başladı", + "NotificationOptionAudioPlaybackStopped": "Ses çalma durduruldu", + "NotificationOptionCameraImageUploaded": "Kamera fotoğrafı yüklendi", "NotificationOptionInstallationFailed": "Yükleme başarısız oldu", - "NotificationOptionNewLibraryContent": "New content added", + "NotificationOptionNewLibraryContent": "Yeni içerik eklendi", "NotificationOptionPluginError": "Eklenti hatası", "NotificationOptionPluginInstalled": "Eklenti yüklendi", "NotificationOptionPluginUninstalled": "Eklenti kaldırıldı", @@ -59,8 +59,8 @@ "NotificationOptionServerRestartRequired": "Sunucu yeniden başlatma gerekli", "NotificationOptionTaskFailed": "Zamanlanmış görev hatası", "NotificationOptionUserLockedOut": "Kullanıcı kitlendi", - "NotificationOptionVideoPlayback": "Video playback started", - "NotificationOptionVideoPlaybackStopped": "Video playback stopped", + "NotificationOptionVideoPlayback": "Video oynatma başladı", + "NotificationOptionVideoPlaybackStopped": "Video oynatma durduruldu", "Photos": "Fotoğraflar", "Playlists": "Çalma listeleri", "Plugin": "Eklenti", @@ -75,23 +75,23 @@ "Songs": "Şarkılar", "StartupEmbyServerIsLoading": "Jellyfin Sunucusu yükleniyor. Lütfen kısa süre sonra tekrar deneyin.", "SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}", - "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}", - "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}", + "SubtitleDownloadFailureFromForItem": "{1} için alt yazılar {0} 'dan indirilemedi", + "SubtitlesDownloadedForItem": "{0} için altyazılar indirildi", "Sync": "Eşitle", - "System": "System", - "TvShows": "TV Shows", + "System": "Sistem", + "TvShows": "Diziler", "User": "Kullanıcı", - "UserCreatedWithName": "Kullanıcı {0} yaratıldı", + "UserCreatedWithName": "{0} kullanıcısı oluşturuldu", "UserDeletedWithName": "Kullanıcı {0} silindi", "UserDownloadingItemWithValues": "{0} indiriliyor {1}", "UserLockedOutWithName": "Kullanıcı {0} kitlendi", - "UserOfflineFromDevice": "{0} has disconnected from {1}", - "UserOnlineFromDevice": "{0} is online from {1}", - "UserPasswordChangedWithName": "Password has been changed for user {0}", - "UserPolicyUpdatedWithName": "User policy has been updated for {0}", - "UserStartedPlayingItemWithValues": "{0} is playing {1} on {2}", - "UserStoppedPlayingItemWithValues": "{0} has finished playing {1} on {2}", - "ValueHasBeenAddedToLibrary": "{0} has been added to your media library", - "ValueSpecialEpisodeName": "Özel -{0}", - "VersionNumber": "Version {0}" + "UserOfflineFromDevice": "{0}, {1} ile bağlantısı kesildi", + "UserOnlineFromDevice": "{0}, {1} çevrimiçi", + "UserPasswordChangedWithName": "{0} kullanıcısı için şifre değiştirildi", + "UserPolicyUpdatedWithName": "Kullanıcı politikası {0} için güncellendi", + "UserStartedPlayingItemWithValues": "{0}, {2} cihazında {1} izliyor", + "UserStoppedPlayingItemWithValues": "{0}, {2} cihazında {1} izlemeyi bitirdi", + "ValueHasBeenAddedToLibrary": "Medya kitaplığınıza {0} eklendi", + "ValueSpecialEpisodeName": "Özel - {0}", + "VersionNumber": "Versiyon {0}" } From 28f71b445fd7bdca63f29791e27da8224989d025 Mon Sep 17 00:00:00 2001 From: penguinfuko Date: Thu, 28 Nov 2019 05:21:20 +0000 Subject: [PATCH 32/62] Translated using Weblate (Chinese (Traditional)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/zh_Hant/ --- Emby.Server.Implementations/Localization/Core/zh-TW.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/zh-TW.json b/Emby.Server.Implementations/Localization/Core/zh-TW.json index 293fc28a86..33bdbfb989 100644 --- a/Emby.Server.Implementations/Localization/Core/zh-TW.json +++ b/Emby.Server.Implementations/Localization/Core/zh-TW.json @@ -1,6 +1,6 @@ { "Albums": "專輯", - "AppDeviceValues": "應用: {0}, 裝置: {1}", + "AppDeviceValues": "軟體: {0}, 裝置: {1}", "Application": "應用程式", "Artists": "演出者", "AuthenticationSucceededWithUserName": "{0} 成功授權", From 84c136b1f24096a726f41aaf89091206b76f9c00 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Sun, 1 Dec 2019 19:30:18 +0100 Subject: [PATCH 33/62] Update Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs Co-Authored-By: Claus Vium --- .../SocketSharp/WebSocketSharpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index a1d41c8958..081f61ef93 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.SocketSharp return specifiedContentType; } - const string ServerDefaultContentType = "application/json"; + const string ServerDefaultContentType = MediaTypeNames.Application.Json; var acceptContentTypes = httpReq.Headers.GetCommaSeparatedValues(HeaderNames.Accept); string defaultContentType = null; From 3b7b8eba4c25692d4e2fb950e33c5463d3f0555e Mon Sep 17 00:00:00 2001 From: EscAbe Date: Sun, 1 Dec 2019 20:50:24 +0100 Subject: [PATCH 34/62] Fix for #2088 --- MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs index eaebc13e32..fc7f12b1a8 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs @@ -57,7 +57,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB { IndexNumber = episode.IndexNumber.Value, ParentIndexNumber = episode.ParentIndexNumber.Value, - SeriesProviderIds = series.ProviderIds + SeriesProviderIds = series.ProviderIds, + SeriesDisplayOrder = series.DisplayOrder }; string episodeTvdbId = await _tvDbClientManager .GetEpisodeTvdbId(episodeInfo, language, cancellationToken).ConfigureAwait(false); From a7461f3ba7488b18eab969f344c0045ef4893f21 Mon Sep 17 00:00:00 2001 From: KingsFourze Date: Sun, 1 Dec 2019 03:18:36 +0000 Subject: [PATCH 35/62] Translated using Weblate (Chinese (Hong Kong)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/zh_Hant_HK/ --- Emby.Server.Implementations/Localization/Core/zh-HK.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/zh-HK.json b/Emby.Server.Implementations/Localization/Core/zh-HK.json index 387fc2b92b..33fcb2d37c 100644 --- a/Emby.Server.Implementations/Localization/Core/zh-HK.json +++ b/Emby.Server.Implementations/Localization/Core/zh-HK.json @@ -2,7 +2,7 @@ "Albums": "Albums", "AppDeviceValues": "App: {0}, Device: {1}", "Application": "Application", - "Artists": "Artists", + "Artists": "藝人", "AuthenticationSucceededWithUserName": "{0} successfully authenticated", "Books": "Books", "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", From caca2b31fe831ae33bea36128655ed587837f40e Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 3 Dec 2019 10:55:22 +0100 Subject: [PATCH 36/62] Fix build --- Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index 081f61ef93..1781df8b51 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Mime; using MediaBrowser.Common.Net; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; From df10cf8012a64a931b2d48c07a475e33414f5edf Mon Sep 17 00:00:00 2001 From: WtK0040 Date: Tue, 3 Dec 2019 12:59:32 +0000 Subject: [PATCH 37/62] Added translation using Weblate (Afrikaans) --- Emby.Server.Implementations/Localization/Core/af.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 Emby.Server.Implementations/Localization/Core/af.json diff --git a/Emby.Server.Implementations/Localization/Core/af.json b/Emby.Server.Implementations/Localization/Core/af.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/Emby.Server.Implementations/Localization/Core/af.json @@ -0,0 +1 @@ +{} From 903752b77b222a4a5113f2f679771d0b64ea9436 Mon Sep 17 00:00:00 2001 From: WtK0040 Date: Tue, 3 Dec 2019 13:05:03 +0000 Subject: [PATCH 38/62] Translated using Weblate (English (United States)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/en_US/ --- Emby.Server.Implementations/Localization/Core/en-US.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json index aa855ed21f..dbbf5b27b6 100644 --- a/Emby.Server.Implementations/Localization/Core/en-US.json +++ b/Emby.Server.Implementations/Localization/Core/en-US.json @@ -8,9 +8,9 @@ "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", "Channels": "Channels", "ChapterNameValue": "Chapter {0}", - "Collections": "Collections", - "DeviceOfflineWithName": "{0} has disconnected", - "DeviceOnlineWithName": "{0} is connected", + "Collections": "Versamelings", + "DeviceOfflineWithName": "{0} het afgesluit", + "DeviceOnlineWithName": "{0} is verbind", "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", "Favorites": "Favorites", "Folders": "Folders", From f7d71a2bc722a178c967ac736c4c2b920eefa10f Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 4 Dec 2019 21:47:01 +0100 Subject: [PATCH 39/62] Remove unused fields and properties --- .../ServerApplicationPaths.cs | 17 +++++------------ .../IServerApplicationPaths.cs | 17 +++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs index 4b8298abbd..2f57c97a13 100644 --- a/Emby.Server.Implementations/ServerApplicationPaths.cs +++ b/Emby.Server.Implementations/ServerApplicationPaths.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Emby.Server.Implementations.AppBase; using MediaBrowser.Controller; @@ -10,8 +9,6 @@ namespace Emby.Server.Implementations /// public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths { - private string _defaultTranscodePath; - private string _transcodePath; private string _internalMetadataPath; /// @@ -23,7 +20,8 @@ namespace Emby.Server.Implementations string configurationDirectoryPath, string cacheDirectoryPath, string webDirectoryPath) - : base(programDataPath, + : base( + programDataPath, logDirectoryPath, configurationDirectoryPath, cacheDirectoryPath, @@ -31,8 +29,6 @@ namespace Emby.Server.Implementations { } - public string ApplicationResourcesPath { get; } = AppContext.BaseDirectory; - /// /// Gets the path to the base root media directory. /// @@ -45,18 +41,13 @@ namespace Emby.Server.Implementations /// The default user views path. public string DefaultUserViewsPath => Path.Combine(RootFolderPath, "default"); - /// - /// Gets the path to localization data. - /// - /// The localization path. - public string LocalizationPath => Path.Combine(ProgramDataPath, "localization"); - /// /// Gets the path to the People directory. /// /// The people path. public string PeoplePath => Path.Combine(InternalMetadataPath, "People"); + /// public string ArtistsPath => Path.Combine(InternalMetadataPath, "artists"); /// @@ -107,12 +98,14 @@ namespace Emby.Server.Implementations /// The user configuration directory path. public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users"); + /// public string InternalMetadataPath { get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata")); set => _internalMetadataPath = value; } + /// public string VirtualInternalMetadataPath { get; } = "%MetadataPath%"; } } diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs index 56e7e4e47a..5d7c60910a 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -10,24 +10,12 @@ namespace MediaBrowser.Controller /// The root folder path. string RootFolderPath { get; } - /// - /// Gets the application resources path. This is the path to the folder containing resources that are deployed as part of the application - /// - /// The application resources path. - string ApplicationResourcesPath { get; } - /// /// Gets the path to the default user view directory. Used if no specific user view is defined. /// /// The default user views path. string DefaultUserViewsPath { get; } - /// - /// Gets the path to localization data. - /// - /// The localization path. - string LocalizationPath { get; } - /// /// Gets the path to the People directory /// @@ -87,8 +75,13 @@ namespace MediaBrowser.Controller /// /// The internal metadata path. string InternalMetadataPath { get; } + string VirtualInternalMetadataPath { get; } + /// + /// Gets the path to the artists directory. + /// + /// The artists path. string ArtistsPath { get; } } } From 4a0df15bbd7f4cb87eba2e0a2ff39b74abd083fe Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 4 Dec 2019 22:18:37 +0100 Subject: [PATCH 40/62] Fix GetTranscodePath function and cache path update logline * GetTranscodePath returned an empty string after the option was left blank in the web UI * Unified the log style for all paths --- .../AppBase/BaseConfigurationManager.cs | 10 ++++++---- .../Configuration/EncodingConfigurationExtensions.cs | 11 +++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 67bb25b077..2a5d56c603 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. /// @@ -97,7 +98,7 @@ namespace Emby.Server.Implementations.AppBase public IApplicationPaths CommonApplicationPaths { get; private set; } /// - /// Gets the system configuration. + /// Gets or sets the system configuration. /// /// The configuration. public BaseApplicationConfiguration CommonConfiguration @@ -123,6 +124,7 @@ namespace Emby.Server.Implementations.AppBase return _configuration; } } + protected set { _configuration = value; @@ -215,7 +217,7 @@ namespace Emby.Server.Implementations.AppBase cachePath = CommonConfiguration.CachePath; } - Logger.LogInformation("Setting cache path to " + cachePath); + Logger.LogInformation("Setting cache path: {Path}", cachePath); ((BaseApplicationPaths)CommonApplicationPaths).CachePath = cachePath; } @@ -223,7 +225,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 +236,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.", diff --git a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs index 2bf1f6bc8c..ccf9658988 100644 --- a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs +++ b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs @@ -22,7 +22,14 @@ namespace MediaBrowser.Common.Configuration /// The Configuration manager. /// The transcoding temp path. public static string GetTranscodePath(this IConfigurationManager configurationManager) - => configurationManager.GetEncodingOptions().TranscodingTempPath - ?? Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes"); + { + var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath; + if (string.IsNullOrEmpty(transcodingTempPath)) + { + return Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes"); + } + + return transcodingTempPath; + } } } From 383733044ff6220213c355ee950b9390976fbb2d Mon Sep 17 00:00:00 2001 From: woodmichl Date: Tue, 3 Dec 2019 20:30:12 +0000 Subject: [PATCH 41/62] Translated using Weblate (German) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/de/ --- Emby.Server.Implementations/Localization/Core/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index 12bc16d746..d22195ce23 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -10,7 +10,7 @@ "ChapterNameValue": "Kapitel {0}", "Collections": "Sammlungen", "DeviceOfflineWithName": "{0} wurde getrennt", - "DeviceOnlineWithName": "{0} hat sich verbunden", + "DeviceOnlineWithName": "{0} ist verbunden", "FailedLoginAttemptWithUserName": "Fehlgeschlagener Anmeldeversuch von {0}", "Favorites": "Favoriten", "Folders": "Verzeichnisse", From 7d2f066cd42fe36b7d073d894cf75533c315d18c Mon Sep 17 00:00:00 2001 From: Dominik Date: Thu, 5 Dec 2019 08:56:43 +0000 Subject: [PATCH 42/62] Translated using Weblate (German) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/de/ --- Emby.Server.Implementations/Localization/Core/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index d22195ce23..019736c471 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -3,7 +3,7 @@ "AppDeviceValues": "App: {0}, Gerät: {1}", "Application": "Anwendung", "Artists": "Interpreten", - "AuthenticationSucceededWithUserName": "{0} hat sich angemeldet", + "AuthenticationSucceededWithUserName": "{0} hat sich erfolgreich angemeldet", "Books": "Bücher", "CameraImageUploadedFrom": "Ein neues Foto wurde hochgeladen von {0}", "Channels": "Kanäle", From 5234c686e75796adbab8110d7a86820be04873ab Mon Sep 17 00:00:00 2001 From: TheGoose Date: Wed, 4 Dec 2019 07:25:38 +0000 Subject: [PATCH 43/62] Translated using Weblate (English (United States)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/en_US/ --- Emby.Server.Implementations/Localization/Core/en-US.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json index dbbf5b27b6..aa855ed21f 100644 --- a/Emby.Server.Implementations/Localization/Core/en-US.json +++ b/Emby.Server.Implementations/Localization/Core/en-US.json @@ -8,9 +8,9 @@ "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", "Channels": "Channels", "ChapterNameValue": "Chapter {0}", - "Collections": "Versamelings", - "DeviceOfflineWithName": "{0} het afgesluit", - "DeviceOnlineWithName": "{0} is verbind", + "Collections": "Collections", + "DeviceOfflineWithName": "{0} has disconnected", + "DeviceOnlineWithName": "{0} is connected", "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", "Favorites": "Favorites", "Folders": "Folders", From 9144c84dc9b62845a1e9aa680048e03f8e5c3ad8 Mon Sep 17 00:00:00 2001 From: bugthug Date: Wed, 4 Dec 2019 18:32:38 +0000 Subject: [PATCH 44/62] Translated using Weblate (Hebrew) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/he/ --- .../Localization/Core/he.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json index 0ed998c4bd..3e96fa482d 100644 --- a/Emby.Server.Implementations/Localization/Core/he.json +++ b/Emby.Server.Implementations/Localization/Core/he.json @@ -5,37 +5,37 @@ "Artists": "אמנים", "AuthenticationSucceededWithUserName": "{0} successfully authenticated", "Books": "ספרים", - "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", - "Channels": "Channels", - "ChapterNameValue": "Chapter {0}", - "Collections": "Collections", - "DeviceOfflineWithName": "{0} has disconnected", - "DeviceOnlineWithName": "{0} is connected", - "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", - "Favorites": "Favorites", - "Folders": "Folders", + "CameraImageUploadedFrom": "תמונה חדשה הועלתה מ{0}", + "Channels": "ערוצים", + "ChapterNameValue": "פרק {0}", + "Collections": "קולקציות", + "DeviceOfflineWithName": "{0} התנתק", + "DeviceOnlineWithName": "{0} מחובר", + "FailedLoginAttemptWithUserName": "ניסיון כניסה שגוי מ{0}", + "Favorites": "אהובים", + "Folders": "תיקיות", "Genres": "ז'אנרים", - "HeaderAlbumArtists": "Album Artists", - "HeaderCameraUploads": "Camera Uploads", - "HeaderContinueWatching": "המשך בצפייה", - "HeaderFavoriteAlbums": "Favorite Albums", - "HeaderFavoriteArtists": "Favorite Artists", - "HeaderFavoriteEpisodes": "Favorite Episodes", - "HeaderFavoriteShows": "Favorite Shows", - "HeaderFavoriteSongs": "Favorite Songs", - "HeaderLiveTV": "Live TV", - "HeaderNextUp": "Next Up", + "HeaderAlbumArtists": "אמני האלבום", + "HeaderCameraUploads": "העלאות ממצלמה", + "HeaderContinueWatching": "המשך לצפות", + "HeaderFavoriteAlbums": "אלבומים שאהבתי", + "HeaderFavoriteArtists": "אמנים שאהבתי", + "HeaderFavoriteEpisodes": "פרקים אהובים", + "HeaderFavoriteShows": "תוכניות אהובות", + "HeaderFavoriteSongs": "שירים שאהבתי", + "HeaderLiveTV": "טלוויזיה בשידור חי", + "HeaderNextUp": "הבא", "HeaderRecordingGroups": "קבוצות הקלטה", - "HomeVideos": "Home videos", - "Inherit": "Inherit", + "HomeVideos": "סרטונים בייתים", + "Inherit": "הורש", "ItemAddedWithName": "{0} was added to the library", - "ItemRemovedWithName": "{0} was removed from the library", + "ItemRemovedWithName": "{0} נמחק מהספרייה", "LabelIpAddressValue": "Ip address: {0}", - "LabelRunningTimeValue": "Running time: {0}", + "LabelRunningTimeValue": "משך צפייה: {0}", "Latest": "אחרון", - "MessageApplicationUpdated": "Jellyfin Server has been updated", - "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}", - "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated", + "MessageApplicationUpdated": "שרת הJellyfin עודכן", + "MessageApplicationUpdatedTo": "שרת הJellyfin עודכן לגרסא {0}", + "MessageNamedServerConfigurationUpdatedWithValue": "הגדרת השרת {0} שונתה", "MessageServerConfigurationUpdated": "Server configuration has been updated", "MixedContent": "תוכן מעורב", "Movies": "סרטים", From fc4bbee39ff4a7a9daf79c528837551a293d020c Mon Sep 17 00:00:00 2001 From: Yuval Pecht Date: Thu, 5 Dec 2019 08:05:29 +0000 Subject: [PATCH 45/62] Translated using Weblate (Hebrew) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/he/ --- Emby.Server.Implementations/Localization/Core/he.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json index 3e96fa482d..b08c8966e2 100644 --- a/Emby.Server.Implementations/Localization/Core/he.json +++ b/Emby.Server.Implementations/Localization/Core/he.json @@ -1,9 +1,9 @@ { "Albums": "אלבומים", - "AppDeviceValues": "App: {0}, Device: {1}", + "AppDeviceValues": "יישום: {0}, מכשיר: {1}", "Application": "אפליקציה", "Artists": "אמנים", - "AuthenticationSucceededWithUserName": "{0} successfully authenticated", + "AuthenticationSucceededWithUserName": "{0} זוהה בהצלחה", "Books": "ספרים", "CameraImageUploadedFrom": "תמונה חדשה הועלתה מ{0}", "Channels": "ערוצים", @@ -30,7 +30,7 @@ "Inherit": "הורש", "ItemAddedWithName": "{0} was added to the library", "ItemRemovedWithName": "{0} נמחק מהספרייה", - "LabelIpAddressValue": "Ip address: {0}", + "LabelIpAddressValue": "Ip כתובת: {0}", "LabelRunningTimeValue": "משך צפייה: {0}", "Latest": "אחרון", "MessageApplicationUpdated": "שרת הJellyfin עודכן", @@ -50,7 +50,7 @@ "NotificationOptionAudioPlayback": "Audio playback started", "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", "NotificationOptionCameraImageUploaded": "Camera image uploaded", - "NotificationOptionInstallationFailed": "Installation failure", + "NotificationOptionInstallationFailed": "התקנה נכשלה", "NotificationOptionNewLibraryContent": "New content added", "NotificationOptionPluginError": "Plugin failure", "NotificationOptionPluginInstalled": "Plugin installed", From fccc90ae1a7ebd0f1a24b407e6bf8ff82d6357e2 Mon Sep 17 00:00:00 2001 From: Pavel Sochor Date: Thu, 5 Dec 2019 08:22:23 +0000 Subject: [PATCH 46/62] Translated using Weblate (Slovak) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/sk/ --- Emby.Server.Implementations/Localization/Core/sk.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/sk.json b/Emby.Server.Implementations/Localization/Core/sk.json index 6eade79429..75eecbe3e0 100644 --- a/Emby.Server.Implementations/Localization/Core/sk.json +++ b/Emby.Server.Implementations/Localization/Core/sk.json @@ -5,7 +5,7 @@ "Artists": "Umelci", "AuthenticationSucceededWithUserName": "{0} úspešne overený", "Books": "Knihy", - "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", + "CameraImageUploadedFrom": "Z {0} bola nahraná nová fotografia", "Channels": "Kanály", "ChapterNameValue": "Kapitola {0}", "Collections": "Zbierky", @@ -15,9 +15,9 @@ "Favorites": "Obľúbené", "Folders": "Priečinky", "Genres": "Žánre", - "HeaderAlbumArtists": "Album Artists", + "HeaderAlbumArtists": "Albumy umelcov", "HeaderCameraUploads": "Nahrané fotografie", - "HeaderContinueWatching": "Pokračujte v pozeraní", + "HeaderContinueWatching": "Pokračovať v pozeraní", "HeaderFavoriteAlbums": "Obľúbené albumy", "HeaderFavoriteArtists": "Obľúbení umelci", "HeaderFavoriteEpisodes": "Obľúbené epizódy", From 82575db6620fa7ddbcfd908d9575b85eeeb4ad07 Mon Sep 17 00:00:00 2001 From: WtK0040 Date: Tue, 3 Dec 2019 13:00:59 +0000 Subject: [PATCH 47/62] Translated using Weblate (Afrikaans) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/af/ --- .../Localization/Core/af.json | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/af.json b/Emby.Server.Implementations/Localization/Core/af.json index 0967ef424b..dcec268017 100644 --- a/Emby.Server.Implementations/Localization/Core/af.json +++ b/Emby.Server.Implementations/Localization/Core/af.json @@ -1 +1,96 @@ -{} +{ + "Artists": "Kunstenare", + "Channels": "Kanale", + "Folders": "Fouers", + "Favorites": "Gunstelinge", + "HeaderFavoriteShows": "Gunsteling Vertonings", + "ValueSpecialEpisodeName": "Spesiaal - {0}", + "HeaderAlbumArtists": "Album Kunstenaars", + "Books": "Boeke", + "HeaderNextUp": "Volgende", + "Movies": "Rolprente", + "Shows": "Program", + "HeaderContinueWatching": "Hou Aan Kyk", + "HeaderFavoriteEpisodes": "Gunsteling Episodes", + "Photos": "Fotos", + "Playlists": "Speellysse", + "HeaderFavoriteArtists": "Gunsteling Kunstenaars", + "HeaderFavoriteAlbums": "Gunsteling Albums", + "Sync": "Sinkroniseer", + "HeaderFavoriteSongs": "Gunsteling Liedjies", + "Songs": "Liedjies", + "DeviceOnlineWithName": "{0} is verbind", + "DeviceOfflineWithName": "{0} het afgesluit", + "Collections": "Versamelings", + "Inherit": "Ontvang", + "HeaderLiveTV": "Live TV", + "Application": "Program", + "AppDeviceValues": "App: {0}, Toestel: {1}", + "VersionNumber": "Weergawe {0}", + "ValueHasBeenAddedToLibrary": "{0} is by jou media biblioteek bygevoeg", + "UserStoppedPlayingItemWithValues": "{0} het klaar {1} op {2} gespeel", + "UserStartedPlayingItemWithValues": "{0} is besig om {1} op {2} te speel", + "UserPolicyUpdatedWithName": "Gebruiker beleid is verander vir {0}", + "UserPasswordChangedWithName": "Gebruiker {0} se wagwoord is verander", + "UserOnlineFromDevice": "{0} is aanlyn van {1}", + "UserOfflineFromDevice": "{0} is ontkoppel van {1}", + "UserLockedOutWithName": "Gebruiker {0} is uitgesluit", + "UserDownloadingItemWithValues": "{0} is besig om {1} af te laai", + "UserDeletedWithName": "Gebruiker {0} is verwyder", + "UserCreatedWithName": "Gebruiker {0} is geskep", + "User": "Gebruiker", + "TvShows": "TV Programme", + "System": "Stelsel", + "SubtitlesDownloadedForItem": "Ondertitels afgelaai vir {0}", + "SubtitleDownloadFailureFromForItem": "Ondertitels het misluk om af te laai van {0} vir {1}", + "StartupEmbyServerIsLoading": "Jellyfin Bediener is besig om te laai. Probeer weer in 'n kort tyd.", + "ServerNameNeedsToBeRestarted": "{0} moet herbegin word", + "ScheduledTaskStartedWithName": "{0} het begin", + "ScheduledTaskFailedWithName": "{0} het misluk", + "ProviderValue": "Voorsiener: {0}", + "PluginUpdatedWithName": "{0} was opgedateer", + "PluginUninstalledWithName": "{0} was verwyder", + "PluginInstalledWithName": "{0} is geïnstalleer", + "Plugin": "Inprop module", + "NotificationOptionVideoPlaybackStopped": "Video terugspeel het gestop", + "NotificationOptionVideoPlayback": "Video terugspeel het begin", + "NotificationOptionUserLockedOut": "Gebruiker uitgeslyt", + "NotificationOptionTaskFailed": "Geskeduleerde taak het misluk", + "NotificationOptionServerRestartRequired": "Bediener herbegin nodig", + "NotificationOptionPluginUpdateInstalled": "Nuwe inprop module geïnstalleer", + "NotificationOptionPluginUninstalled": "Inprop module verwyder", + "NotificationOptionPluginInstalled": "Inprop module geïnstalleer", + "NotificationOptionPluginError": "Inprop module het misluk", + "NotificationOptionNewLibraryContent": "Nuwe inhoud bygevoeg", + "NotificationOptionInstallationFailed": "Installering het misluk", + "NotificationOptionCameraImageUploaded": "Kamera foto is opgelaai", + "NotificationOptionAudioPlaybackStopped": "Oudio terugspeel het gestop", + "NotificationOptionAudioPlayback": "Oudio terugspeel het begin", + "NotificationOptionApplicationUpdateInstalled": "Nuwe program weergawe geïnstalleer", + "NotificationOptionApplicationUpdateAvailable": "Nuwe program weergawe beskikbaar", + "NewVersionIsAvailable": "'n Nuwe Jellyfin Bedienaar weergawe kan afgelaai word.", + "NameSeasonUnknown": "Seisoen Onbekend", + "NameSeasonNumber": "Seisoen {0}", + "NameInstallFailed": "{0} installering het misluk", + "MusicVideos": "Musiek videos", + "Music": "Musiek", + "MixedContent": "Gemengde inhoud", + "MessageServerConfigurationUpdated": "Bediener konfigurasie is opgedateer", + "MessageNamedServerConfigurationUpdatedWithValue": "Bediener konfigurasie seksie {0} is opgedateer", + "MessageApplicationUpdatedTo": "Jellyfin Bediener is opgedateer na {0}", + "MessageApplicationUpdated": "Jellyfin Bediener is opgedateer", + "Latest": "Nuutste", + "LabelRunningTimeValue": "Lopende tyd: {0}", + "LabelIpAddressValue": "IP adres: {0}", + "ItemRemovedWithName": "{0} is uit versameling verwyder", + "ItemAddedWithName": "{0} is in die versameling", + "HomeVideos": "Tuis opnames", + "HeaderRecordingGroups": "Groep Opnames", + "HeaderCameraUploads": "Kamera Oplaai", + "Genres": "Genres", + "FailedLoginAttemptWithUserName": "Mislukte aansluiting van {0}", + "ChapterNameValue": "Hoofstuk", + "CameraImageUploadedFrom": "'n Nuwe kamera photo opgelaai van {0}", + "AuthenticationSucceededWithUserName": "{0} suksesvol geverifieer", + "Albums": "Albums" +} From a6f883345f1941bf99db1667e84c1caf0b370479 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 5 Dec 2019 17:44:46 +0100 Subject: [PATCH 48/62] 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 f64c89389f..a451bbcf91 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 41ee314df3..2b994d2799 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 8718e1ea6b76386e4b5032da0a770cec1b7acf42 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 5 Dec 2019 18:30:56 +0100 Subject: [PATCH 49/62] Add installed plugins to bug reports --- .github/ISSUE_TEMPLATE/bug_report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ca89c1cb91..bd13d4b00e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,6 +30,7 @@ assignees: '' - OS: [e.g. Docker, Debian, Windows] - Browser: [e.g. Firefox, Chrome, Safari] - Jellyfin Version: [e.g. 10.0.1] + - Installed Plugins: [e.g. none, Fanart, Anime, etc.] - Reverse proxy: [e.g. no, nginx, apache, etc.] **Additional context** From 8694577c7164cc65ad68cf0ee5fa0963f6b2ad39 Mon Sep 17 00:00:00 2001 From: gustinn Date: Thu, 5 Dec 2019 18:29:37 +0000 Subject: [PATCH 50/62] Added translation using Weblate (Icelandic) --- Emby.Server.Implementations/Localization/Core/is.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 Emby.Server.Implementations/Localization/Core/is.json diff --git a/Emby.Server.Implementations/Localization/Core/is.json b/Emby.Server.Implementations/Localization/Core/is.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/Emby.Server.Implementations/Localization/Core/is.json @@ -0,0 +1 @@ +{} From caa57d5bda10722b1224e774f30f4ccad4f8c446 Mon Sep 17 00:00:00 2001 From: memnos Date: Thu, 5 Dec 2019 10:57:35 +0000 Subject: [PATCH 51/62] Translated using Weblate (Italian) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/it/ --- .../Localization/Core/it.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/it.json b/Emby.Server.Implementations/Localization/Core/it.json index 357883cd37..8f91effb92 100644 --- a/Emby.Server.Implementations/Localization/Core/it.json +++ b/Emby.Server.Implementations/Localization/Core/it.json @@ -9,13 +9,13 @@ "Channels": "Canali", "ChapterNameValue": "Capitolo {0}", "Collections": "Collezioni", - "DeviceOfflineWithName": "{0} è stato disconnesso", + "DeviceOfflineWithName": "{0} ha disconnesso", "DeviceOnlineWithName": "{0} è connesso", "FailedLoginAttemptWithUserName": "Tentativo di accesso fallito da {0}", "Favorites": "Preferiti", "Folders": "Cartelle", "Genres": "Generi", - "HeaderAlbumArtists": "Artisti Album", + "HeaderAlbumArtists": "Artisti dell' Album", "HeaderCameraUploads": "Caricamenti Fotocamera", "HeaderContinueWatching": "Continua a guardare", "HeaderFavoriteAlbums": "Album preferiti", @@ -32,7 +32,7 @@ "ItemRemovedWithName": "{0} è stato rimosso dalla libreria", "LabelIpAddressValue": "Indirizzo IP: {0}", "LabelRunningTimeValue": "Durata: {0}", - "Latest": "Più recenti", + "Latest": "Novità", "MessageApplicationUpdated": "Il Server Jellyfin è stato aggiornato", "MessageApplicationUpdatedTo": "Jellyfin Server è stato aggiornato a {0}", "MessageNamedServerConfigurationUpdatedWithValue": "La sezione {0} della configurazione server è stata aggiornata", @@ -43,7 +43,7 @@ "MusicVideos": "Video musicali", "NameInstallFailed": "{0} installazione fallita", "NameSeasonNumber": "Stagione {0}", - "NameSeasonUnknown": "Stagione sconosciuto", + "NameSeasonUnknown": "Stagione sconosciuta", "NewVersionIsAvailable": "Una nuova versione di Jellyfin Server è disponibile per il download.", "NotificationOptionApplicationUpdateAvailable": "Aggiornamento dell'applicazione disponibile", "NotificationOptionApplicationUpdateInstalled": "Aggiornamento dell'applicazione installato", @@ -88,9 +88,9 @@ "UserOfflineFromDevice": "{0} è stato disconnesso da {1}", "UserOnlineFromDevice": "{0} è online da {1}", "UserPasswordChangedWithName": "La password è stata cambiata per l'utente {0}", - "UserPolicyUpdatedWithName": "La politica dell'utente è stata aggiornata per {0}", - "UserStartedPlayingItemWithValues": "{0} ha avviato la riproduzione di {1}", - "UserStoppedPlayingItemWithValues": "{0} ha interrotto la riproduzione di {1}", + "UserPolicyUpdatedWithName": "La policy dell'utente è stata aggiornata per {0}", + "UserStartedPlayingItemWithValues": "{0} ha avviato la riproduzione di {1} su {2}", + "UserStoppedPlayingItemWithValues": "{0} ha interrotto la riproduzione di {1} su {2}", "ValueHasBeenAddedToLibrary": "{0} è stato aggiunto alla tua libreria multimediale", "ValueSpecialEpisodeName": "Speciale - {0}", "VersionNumber": "Versione {0}" From 94edb5b9f98cf3b06144255eccc988712332f0a8 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Fri, 6 Dec 2019 11:58:45 +0100 Subject: [PATCH 52/62] 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 438ca39ea7..4f74bb222e 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 53/62] 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 d37be0e639..4c2c43437a 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 4fa8f9ccfe6e570d6d122ee41c70a242370576df Mon Sep 17 00:00:00 2001 From: antoniy Date: Thu, 5 Dec 2019 22:14:29 +0000 Subject: [PATCH 54/62] 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 bfe32a6c2b..46c10d912e 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 55/62] 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 3589a48938..580b423302 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 56/62] 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 faa8499b88..fcc724a7df 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 57/62] 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 0ad4b37aa2..7cf957a945 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 58/62] 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 75eecbe3e0..9bac305a27 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 59/62] 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 fb2761a7db..744b0e2d39 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 60/62] 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 0967ef424b..982232afd6 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 61/62] 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 f5ca8e1448..edf68cf7c8 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 4def7ca40d..3d8d15d197 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 30f29beee4..0654132f41 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 1ca25ba6f3..f00996b5fe 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 9ccbf7535a..e1dbb663bc 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 9cef77dc87..161788c636 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 24ac6d1fda..9ee219854d 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 f9eb3a8979..a62b4e7aff 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 eda2360285..5afc51dbc3 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 5d657b8a7c..2292d86a4a 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 1233dcc43e..eaad05f92b 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 dbadaeefbe..1497f4a3a7 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 6478f1873e..b0cd5f87a7 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 1b5c83f1eb..58549e9d76 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 23a28e9360..5ee4ca72ea 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 887eef5c36..15e7a0dbb8 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 62/62] 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 f1b88de643..e94c1321f4 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 fd6c0b7da5..58c95d053e 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 fc5603d277..56ec86cd47 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,