Selaa lähdekoodia

Merge branch 'beta' of https://github.com/MediaBrowser/Emby into beta

Luke Pulverenti 9 vuotta sitten
vanhempi
sitoutus
88e12d1b4f

+ 9 - 1
MediaBrowser.Api/LiveTv/LiveTvService.cs

@@ -146,6 +146,13 @@ namespace MediaBrowser.Api.LiveTv
         /// <value>The fields.</value>
         [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
         public string Fields { get; set; }
+
+        public bool EnableTotalRecordCount { get; set; }
+
+        public GetRecordings()
+        {
+            EnableTotalRecordCount = true;
+        }
     }
 
     [Route("/LiveTv/Recordings/Groups", "GET", Summary = "Gets live tv recording groups")]
@@ -898,7 +905,8 @@ namespace MediaBrowser.Api.LiveTv
                 Limit = request.Limit,
                 Status = request.Status,
                 SeriesTimerId = request.SeriesTimerId,
-                IsInProgress = request.IsInProgress
+                IsInProgress = request.IsInProgress,
+                EnableTotalRecordCount = request.EnableTotalRecordCount
 
             }, options, CancellationToken.None).ConfigureAwait(false);
 

+ 3 - 2
MediaBrowser.Api/Sync/SyncService.cs

@@ -243,7 +243,7 @@ namespace MediaBrowser.Api.Sync
 
             await _syncManager.ReportSyncJobItemTransferBeginning(request.Id).ConfigureAwait(false);
 
-            return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
+            return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
             {
                 Path = jobItem.OutputPath,
                 OnError = () =>
@@ -251,7 +251,8 @@ namespace MediaBrowser.Api.Sync
                     var failedTask = _syncManager.ReportSyncJobItemTransferFailed(request.Id);
                     Task.WaitAll(failedTask);
                 }
-            });
+
+            }).ConfigureAwait(false);
         }
 
         public async Task<object> Get(GetSyncDialogOptions request)

+ 6 - 0
MediaBrowser.Controller/Channels/ChannelItemInfo.cs

@@ -55,6 +55,10 @@ namespace MediaBrowser.Controller.Channels
 
         public string HomePageUrl { get; set; }
 
+        public List<string> Artists { get; set; }
+
+        public List<string> AlbumArtists { get; set; }
+
         public ChannelItemInfo()
         {
             MediaSources = new List<ChannelMediaInfo>();
@@ -64,6 +68,8 @@ namespace MediaBrowser.Controller.Channels
             People = new List<PersonInfo>();
             Tags = new List<string>();
             ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+            Artists = new List<string>();
+            AlbumArtists = new List<string>();
         }
     }
 }

+ 7 - 0
MediaBrowser.Model/LiveTv/RecordingQuery.cs

@@ -70,5 +70,12 @@ namespace MediaBrowser.Model.LiveTv
         public bool? EnableImages { get; set; }
         public int? ImageTypeLimit { get; set; }
         public ImageType[] EnableImageTypes { get; set; }
+
+        public bool EnableTotalRecordCount { get; set; }
+
+        public RecordingQuery()
+        {
+            EnableTotalRecordCount = true;
+        }
     }
 }

+ 25 - 13
MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs

@@ -14,6 +14,7 @@ using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Xml;
+using MediaBrowser.Model.Serialization;
 
 namespace MediaBrowser.Providers.Music
 {
@@ -24,14 +25,16 @@ namespace MediaBrowser.Providers.Music
         private readonly IHttpClient _httpClient;
         private readonly IApplicationHost _appHost;
         private readonly ILogger _logger;
+        private readonly IJsonSerializer _json;
 
         public static string MusicBrainzBaseUrl = "https://www.musicbrainz.org";
 
-        public MusicBrainzAlbumProvider(IHttpClient httpClient, IApplicationHost appHost, ILogger logger)
+        public MusicBrainzAlbumProvider(IHttpClient httpClient, IApplicationHost appHost, ILogger logger, IJsonSerializer json)
         {
             _httpClient = httpClient;
             _appHost = appHost;
             _logger = logger;
+            _json = json;
             Current = this;
         }
 
@@ -332,33 +335,38 @@ namespace MediaBrowser.Providers.Music
 
         private async Task<MbzUrl> GetMbzUrl()
         {
-            if (_mbzUrls == null || (DateTime.UtcNow.Ticks - _lastMbzUrlQueryTicks) > TimeSpan.FromHours(12).Ticks)
+            if (_chosenUrl == null || _mbzUrls == null || (DateTime.UtcNow.Ticks - _lastMbzUrlQueryTicks) > TimeSpan.FromHours(12).Ticks)
             {
-                await RefreshMzbUrls().ConfigureAwait(false);
+                var urls = await RefreshMzbUrls().ConfigureAwait(false);
 
-                var urls = _mbzUrls.ToList();
                 _chosenUrl = urls[new Random().Next(0, urls.Count - 1)];
             }
 
             return _chosenUrl;
         }
 
-        private async Task RefreshMzbUrls()
+        private async Task<List<MbzUrl>> RefreshMzbUrls()
         {
+            List<MbzUrl> list;
+
             try
             {
-                _mbzUrls = new List<MbzUrl>
+                var options = new HttpRequestOptions
                 {
-                    new MbzUrl
-                    {
-                        url = MusicBrainzBaseUrl,
-                        throttleMs = 1000
-                    }
+                    Url = "https://mb3admin.com/admin/service/standards/musicBrainzUrls",
+                    UserAgent = _appHost.Name + "/" + _appHost.ApplicationVersion
                 };
+
+                using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
+                {
+                    list = _json.DeserializeFromStream<List<MbzUrl>>(stream);
+                }
             }
-            catch
+            catch (Exception ex)
             {
-                _mbzUrls = new List<MbzUrl>
+                _logger.ErrorException("Error getting music brainz info", ex);
+
+                list = new List<MbzUrl>
                 {
                     new MbzUrl
                     {
@@ -367,6 +375,10 @@ namespace MediaBrowser.Providers.Music
                     }
                 };
             }
+
+            _mbzUrls = list.ToList();
+
+            return list;
         }
 
         /// <summary>

+ 12 - 0
MediaBrowser.Server.Implementations/Channels/ChannelManager.cs

@@ -1310,6 +1310,18 @@ namespace MediaBrowser.Server.Implementations.Channels
                 item.HomePageUrl = info.HomePageUrl;
             }
 
+            var hasArtists = item as IHasArtist;
+            if (hasArtists != null)
+            {
+                hasArtists.Artists = info.Artists;
+            }
+
+            var hasAlbumArtists = item as IHasAlbumArtist;
+            if (hasAlbumArtists != null)
+            {
+                hasAlbumArtists.AlbumArtists = info.AlbumArtists;
+            }
+
             var trailer = item as Trailer;
             if (trailer != null)
             {

+ 8 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -896,6 +896,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
 
             var topFolder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false);
 
+            if (query.SortBy.Length == 0)
+            {
+                // Unless something else was specified, order by start date to take advantage of a specialized index
+                query.SortBy = new[] { ItemSortBy.StartDate };
+            }
+
             var internalQuery = new InternalItemsQuery(user)
             {
                 IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
@@ -1414,7 +1420,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 ExcludeLocationTypes = new[] { LocationType.Virtual },
                 Limit = Math.Min(200, query.Limit ?? int.MaxValue),
                 SortBy = new[] { ItemSortBy.DateCreated },
-                SortOrder = SortOrder.Descending
+                SortOrder = SortOrder.Descending,
+                EnableTotalRecordCount = query.EnableTotalRecordCount
             });
         }
 

+ 9 - 2
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -162,7 +162,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
                                 "create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)",
                                 //"create index if not exists idx_ItemValues on ItemValues(ItemId)",
                                 "create index if not exists idx_ItemValues2 on ItemValues(ItemId,Type)",
-                                "create index if not exists idx_ItemValues3 on ItemValues(ItemId,Type,CleanValue)",
 
                                 "create table if not exists ProviderIds (ItemId GUID, Name TEXT, Value TEXT, PRIMARY KEY (ItemId, Name))",
                                 "create index if not exists Idx_ProviderIds on ProviderIds(ItemId)",
@@ -276,6 +275,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 "create index if not exists idx_TopParentId on TypedBaseItems(TopParentId)",
                 "create index if not exists idx_TypeTopParentId on TypedBaseItems(Type,TopParentId)",
 
+                // live tv programs
+                "create index if not exists idx_TypeTopParentIdStartDate on TypedBaseItems(Type,TopParentId,StartDate)",
+
                 // used by movie suggestions
                 "create index if not exists idx_TypeTopParentIdGroup on TypedBaseItems(Type,TopParentId,PresentationUniqueKey)",
                 "create index if not exists idx_TypeTopParentId2 on TypedBaseItems(TopParentId,MediaType,IsVirtualItem)",
@@ -286,8 +288,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
 
                 // latest items
                 "create index if not exists idx_TypeTopParentId9 on TypedBaseItems(TopParentId,Type,IsVirtualItem,PresentationUniqueKey,DateCreated)",
+                "create index if not exists idx_TypeTopParentId8 on TypedBaseItems(TopParentId,IsFolder,IsVirtualItem,PresentationUniqueKey,DateCreated)",
+
+                // resume
                 "create index if not exists idx_TypeTopParentId7 on TypedBaseItems(TopParentId,MediaType,IsVirtualItem,PresentationUniqueKey)",
-                "create index if not exists idx_TypeTopParentId8 on TypedBaseItems(TopParentId,IsFolder,IsVirtualItem,PresentationUniqueKey)"
+
+                // items by name
+                "create index if not exists idx_ItemValues3 on ItemValues(ItemId,Type,CleanValue)"
                 };
 
             _connection.RunQueries(postQueries, Logger);

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common.Internal</id>
-        <version>3.0.650</version>
+        <version>3.0.651</version>
         <title>MediaBrowser.Common.Internal</title>
         <authors>Luke</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption.</description>
         <copyright>Copyright © Emby 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.650" />
+            <dependency id="MediaBrowser.Common" version="3.0.651" />
             <dependency id="NLog" version="4.3.4" />
             <dependency id="SimpleInjector" version="3.1.5" />
         </dependencies>

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common</id>
-        <version>3.0.650</version>
+        <version>3.0.651</version>
         <title>MediaBrowser.Common</title>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>

+ 1 - 1
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.650</version>
+        <version>3.0.651</version>
         <title>Media Browser.Server.Core</title>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>