diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-08-23 13:27:53 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-08-23 13:27:53 -0400 |
| commit | 2d0c98733aa7cfe3337034bca815e807b203ac24 (patch) | |
| tree | 88e867fe7060cff520cd3646f05a6384f4f32dce | |
| parent | 6736f79abe3da4cdb8747ef83a02ff512230a614 (diff) | |
normalize media source container
| -rw-r--r-- | Emby.Server.Implementations/Dto/DtoService.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index c6243a0a6..2ea88b52a 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -369,6 +369,8 @@ namespace Emby.Server.Implementations.Dto { dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user); } + + NormalizeMediaSourceContainers(dto); } } @@ -413,6 +415,45 @@ namespace Emby.Server.Implementations.Dto return dto; } + private void NormalizeMediaSourceContainers(BaseItemDto dto) + { + foreach (var mediaSource in dto.MediaSources) + { + var container = mediaSource.Container; + if (string.IsNullOrWhiteSpace(container)) + { + continue; + } + var containers = container.Split(new[] { ',' }); + if (containers.Length < 2) + { + continue; + } + + var path = mediaSource.Path; + string fileExtensionContainer = null; + + if (!string.IsNullOrWhiteSpace(path)) + { + path = Path.GetExtension(path); + if (!string.IsNullOrWhiteSpace(path)) + { + path = Path.GetExtension(path); + if (!string.IsNullOrWhiteSpace(path)) + { + path = path.TrimStart('.'); + } + if (!string.IsNullOrWhiteSpace(path) && containers.Contains(path, StringComparer.OrdinalIgnoreCase)) + { + fileExtensionContainer = path; + } + } + } + + mediaSource.Container = fileExtensionContainer ?? containers[0]; + } + } + public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List<BaseItem> taggedItems, Dictionary<string, SyncedItemProgress> syncProgress, User user = null) { var dto = GetBaseItemDtoInternal(item, options, user); |
