mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04:00
fixes #672 - Support path mapping
This commit is contained in:
parent
1f6918117c
commit
7d23dea414
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Model.Weather;
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Model.Weather;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Configuration
|
namespace MediaBrowser.Model.Configuration
|
||||||
@ -228,7 +229,8 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
public LiveTvOptions LiveTvOptions { get; set; }
|
public LiveTvOptions LiveTvOptions { get; set; }
|
||||||
|
|
||||||
public bool EnableRealtimeMonitor { get; set; }
|
public bool EnableRealtimeMonitor { get; set; }
|
||||||
|
public PathSubstitution[] PathSubstitutions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -259,6 +261,7 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
EnableInternetProviders = true; //initial installs will need these
|
EnableInternetProviders = true; //initial installs will need these
|
||||||
|
|
||||||
ManualLoginClients = new ManualLoginCategory[] { };
|
ManualLoginClients = new ManualLoginCategory[] { };
|
||||||
|
PathSubstitutions = new PathSubstitution[] { };
|
||||||
|
|
||||||
MetadataRefreshDays = 30;
|
MetadataRefreshDays = 30;
|
||||||
PreferredMetadataLanguage = "en";
|
PreferredMetadataLanguage = "en";
|
||||||
@ -352,4 +355,10 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
SeasonZeroFolderName = "Season 0";
|
SeasonZeroFolderName = "Season 0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PathSubstitution
|
||||||
|
{
|
||||||
|
public string From { get; set; }
|
||||||
|
public string To { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,12 @@ namespace MediaBrowser.Model.Dto
|
|||||||
/// <value>The genres.</value>
|
/// <value>The genres.</value>
|
||||||
public List<string> Genres { get; set; }
|
public List<string> Genres { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the mapped paths.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The mapped paths.</value>
|
||||||
|
public List<string> MappedPaths { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the community rating.
|
/// Gets or sets the community rating.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
@ -8,6 +9,7 @@ using MediaBrowser.Controller.Entities.TV;
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
@ -31,8 +33,9 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||||||
private readonly IItemRepository _itemRepo;
|
private readonly IItemRepository _itemRepo;
|
||||||
|
|
||||||
private readonly IImageProcessor _imageProcessor;
|
private readonly IImageProcessor _imageProcessor;
|
||||||
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
public DtoService(ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor)
|
public DtoService(ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
@ -40,6 +43,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||||||
_userDataRepository = userDataRepository;
|
_userDataRepository = userDataRepository;
|
||||||
_itemRepo = itemRepo;
|
_itemRepo = itemRepo;
|
||||||
_imageProcessor = imageProcessor;
|
_imageProcessor = imageProcessor;
|
||||||
|
_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -891,6 +895,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||||||
if (fields.Contains(ItemFields.Path))
|
if (fields.Contains(ItemFields.Path))
|
||||||
{
|
{
|
||||||
dto.Path = item.Path;
|
dto.Path = item.Path;
|
||||||
|
dto.MappedPaths = GetMappedPaths(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
dto.PremiereDate = item.PremiereDate;
|
dto.PremiereDate = item.PremiereDate;
|
||||||
@ -1142,6 +1147,44 @@ 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)
|
||||||
|
{
|
||||||
|
var toValue = map.To ?? string.Empty;
|
||||||
|
|
||||||
|
path = path.Replace(map.From, toValue, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (toValue.IndexOf('/') != -1)
|
||||||
|
{
|
||||||
|
path = path.Replace('\\', '/');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = path.Replace('/', '\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
private void SetProductionLocations(BaseItem item, BaseItemDto dto)
|
private void SetProductionLocations(BaseItem item, BaseItemDto dto)
|
||||||
{
|
{
|
||||||
var hasProductionLocations = item as IHasProductionLocations;
|
var hasProductionLocations = item as IHasProductionLocations;
|
||||||
|
@ -309,7 +309,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
ImageProcessor = new ImageProcessor(Logger, ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer);
|
ImageProcessor = new ImageProcessor(Logger, ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer);
|
||||||
RegisterSingleInstance(ImageProcessor);
|
RegisterSingleInstance(ImageProcessor);
|
||||||
|
|
||||||
DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor);
|
DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager);
|
||||||
RegisterSingleInstance(DtoService);
|
RegisterSingleInstance(DtoService);
|
||||||
|
|
||||||
var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
|
var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user