diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Dto/DtoService.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Dto/DtoService.cs | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 2584fa4f0..ae08a7c3d 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -900,8 +900,16 @@ namespace MediaBrowser.Server.Implementations.Dto if (fields.Contains(ItemFields.Path)) { - dto.Path = item.Path; - dto.MappedPaths = GetMappedPaths(item); + var locationType = item.LocationType; + + if (locationType == LocationType.FileSystem || locationType == LocationType.Offline) + { + dto.Path = GetMappedPath(item.Path); + } + else + { + dto.Path = item.Path; + } } dto.PremiereDate = item.PremiereDate; @@ -1135,39 +1143,11 @@ namespace MediaBrowser.Server.Implementations.Dto } } - private List<string> GetMappedPaths(BaseItem item) - { - var list = new List<string>(); - - var locationType = item.LocationType; - - if (locationType == LocationType.FileSystem || locationType == LocationType.Offline) - { - var path = item.Path; - var mappedPaths = _config.Configuration.PathSubstitutions - .Select(p => GetMappedPath(path, p)) - .Where(p => !string.Equals(p, path, StringComparison.OrdinalIgnoreCase)) - .Distinct(StringComparer.OrdinalIgnoreCase); - - list.AddRange(mappedPaths); - } - - return list; - } - - private string GetMappedPath(string path, PathSubstitution map) + private string GetMappedPath(string path) { - var toValue = map.To ?? string.Empty; - - path = path.Replace(map.From, toValue, StringComparison.OrdinalIgnoreCase); - - if (toValue.IndexOf('/') != -1) - { - path = path.Replace('\\', '/'); - } - else + foreach (var map in _config.Configuration.PathSubstitutions) { - path = path.Replace('/', '\\'); + path = _fileSystem.SubstitutePath(path, map.From, map.To); } return path; |
