From 3edf91ce564266e43a96c89edb71887096e8d296 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 5 Jan 2017 23:38:03 -0500 Subject: [PATCH] update music artists --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 6 +++--- Emby.Dlna/Didl/DidlBuilder.cs | 2 +- .../Playback/BaseStreamingService.cs | 17 +++++++++++++++- .../Entities/Audio/MusicArtist.cs | 9 +++++++++ .../Entities/Audio/MusicGenre.cs | 9 +++++++++ MediaBrowser.Controller/Entities/BaseItem.cs | 9 +++++++++ MediaBrowser.Controller/Entities/Folder.cs | 9 +++++++++ MediaBrowser.Controller/Entities/Genre.cs | 9 +++++++++ MediaBrowser.Controller/Entities/Studio.cs | 9 +++++++++ .../Manager/ProviderManager.cs | 20 +++++++++---------- 10 files changed, 84 insertions(+), 15 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 5718cbd09..2251a8f58 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -260,7 +260,7 @@ namespace Emby.Dlna.ContentDirectory { totalCount = 1; - if (item.IsFolder || serverItem.StubType.HasValue) + if (item.IsDisplayedAsFolder || serverItem.StubType.HasValue) { var childrenResult = (await GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount).ConfigureAwait(false)); @@ -285,7 +285,7 @@ namespace Emby.Dlna.ContentDirectory var childItem = i.Item; var displayStubType = i.StubType; - if (childItem.IsFolder || displayStubType.HasValue) + if (childItem.IsDisplayedAsFolder || displayStubType.HasValue) { var childCount = (await GetUserItems(childItem, displayStubType, user, sortCriteria, null, 0).ConfigureAwait(false)) .TotalRecordCount; @@ -381,7 +381,7 @@ namespace Emby.Dlna.ContentDirectory foreach (var i in childrenResult.Items) { - if (i.IsFolder) + if (i.IsDisplayedAsFolder) { var childCount = (await GetChildrenSorted(i, user, searchCriteria, sortCriteria, null, 0).ConfigureAwait(false)) .TotalRecordCount; diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 8771681ad..ca4c3b912 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -686,7 +686,7 @@ namespace Emby.Dlna.Didl writer.WriteStartElement("upnp", "class", NS_UPNP); - if (item.IsFolder || stubType.HasValue) + if (item.IsDisplayedAsFolder || stubType.HasValue) { string classType = null; diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 1ad472038..0e0a22c39 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -2710,7 +2710,12 @@ namespace MediaBrowser.Api.Playback { if (!string.IsNullOrWhiteSpace(stream.Codec) && stream.Index != -1) { - inputModifier += " -codec:" + stream.Index.ToString(UsCulture) + " " + stream.Codec; + var decoder = GetDecoderFromCodec(stream.Codec); + + if (!string.IsNullOrWhiteSpace(decoder)) + { + inputModifier += " -codec:" + stream.Index.ToString(UsCulture) + " " + decoder; + } } } } @@ -2730,6 +2735,16 @@ namespace MediaBrowser.Api.Playback return inputModifier; } + private string GetDecoderFromCodec(string codec) + { + if (string.Equals(codec, "mp2", StringComparison.OrdinalIgnoreCase)) + { + return null; + } + + return codec; + } + /// /// Infers the audio codec based on the url /// diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 1d2716b64..37631bbe8 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -44,6 +44,15 @@ namespace MediaBrowser.Controller.Entities.Audio } } + [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + [IgnoreDataMember] public override bool SupportsAddingToPlaylist { diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index d75b31f6a..bbe1a54a4 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -40,6 +40,15 @@ namespace MediaBrowser.Controller.Entities.Audio } } + [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + /// /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 2aa53d651..9e32fd199 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1631,6 +1631,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public virtual bool IsDisplayedAsFolder + { + get + { + return false; + } + } + public virtual string GetClientTypeName() { if (IsFolder && SourceType == SourceType.Channel && !(this is Channel)) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 943c9d882..b5d07b933 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -85,6 +85,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + [IgnoreDataMember] public virtual bool SupportsCumulativeRunTimeTicks { diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index da4ee352f..1b746ae51 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -40,6 +40,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + [IgnoreDataMember] public override bool SupportsAncestors { diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index c14dd70bf..dbd9d1cef 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -39,6 +39,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + [IgnoreDataMember] public override bool SupportsAncestors { diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index a645ab55f..4eab20e7e 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -921,19 +921,19 @@ namespace MediaBrowser.Providers.Manager { await item.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false); - if (item.IsFolder) + // Collection folders don't validate their children so we'll have to simulate that here + var collectionFolder = item as CollectionFolder; + + if (collectionFolder != null) { - // Collection folders don't validate their children so we'll have to simulate that here - var collectionFolder = item as CollectionFolder; + await RefreshCollectionFolderChildren(options, collectionFolder).ConfigureAwait(false); + } + else + { + var folder = item as Folder; - if (collectionFolder != null) + if (folder != null) { - await RefreshCollectionFolderChildren(options, collectionFolder).ConfigureAwait(false); - } - else - { - var folder = (Folder)item; - await folder.ValidateChildren(new Progress(), cancellationToken, options).ConfigureAwait(false); } }