mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
commit
de78c34102
8 changed files with 141 additions and 113 deletions
|
@ -50,40 +50,5 @@ namespace MediaBrowser.Api.Library
|
||||||
fileSystem.DeleteFile(shortcut);
|
fileSystem.DeleteFile(shortcut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileSystem">The file system.</param>
|
|
||||||
/// <param name="virtualFolderName">Name of the virtual folder.</param>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="appPaths">The app paths.</param>
|
|
||||||
public static void AddMediaPath(IFileSystem fileSystem, string virtualFolderName, string path, IServerApplicationPaths appPaths)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(path))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("path");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fileSystem.DirectoryExists(path))
|
|
||||||
{
|
|
||||||
throw new DirectoryNotFoundException("The path does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var rootFolderPath = appPaths.DefaultUserViewsPath;
|
|
||||||
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
|
|
||||||
|
|
||||||
var shortcutFilename = fileSystem.GetFileNameWithoutExtension(path);
|
|
||||||
|
|
||||||
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
|
|
||||||
|
|
||||||
while (fileSystem.FileExists(lnk))
|
|
||||||
{
|
|
||||||
shortcutFilename += "1";
|
|
||||||
lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileSystem.CreateShortcut(lnk, path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,75 +190,7 @@ namespace MediaBrowser.Api.Library
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
public void Post(AddVirtualFolder request)
|
public void Post(AddVirtualFolder request)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(request.Name))
|
_libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, request.RefreshLibrary);
|
||||||
{
|
|
||||||
throw new ArgumentNullException("request");
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = _fileSystem.GetValidFilename(request.Name);
|
|
||||||
|
|
||||||
var rootFolderPath = _appPaths.DefaultUserViewsPath;
|
|
||||||
|
|
||||||
var virtualFolderPath = Path.Combine(rootFolderPath, name);
|
|
||||||
while (_fileSystem.DirectoryExists(virtualFolderPath))
|
|
||||||
{
|
|
||||||
name += "1";
|
|
||||||
virtualFolderPath = Path.Combine(rootFolderPath, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.Paths != null)
|
|
||||||
{
|
|
||||||
var invalidpath = request.Paths.FirstOrDefault(i => !_fileSystem.DirectoryExists(i));
|
|
||||||
if (invalidpath != null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("The specified path does not exist: " + invalidpath + ".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_libraryMonitor.Stop();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_fileSystem.CreateDirectory(virtualFolderPath);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(request.CollectionType))
|
|
||||||
{
|
|
||||||
var path = Path.Combine(virtualFolderPath, request.CollectionType + ".collection");
|
|
||||||
|
|
||||||
using (File.Create(path))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.Paths != null)
|
|
||||||
{
|
|
||||||
foreach (var path in request.Paths)
|
|
||||||
{
|
|
||||||
LibraryHelpers.AddMediaPath(_fileSystem, name, path, _appPaths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
// No need to start if scanning the library because it will handle it
|
|
||||||
if (request.RefreshLibrary)
|
|
||||||
{
|
|
||||||
_libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Need to add a delay here or directory watchers may still pick up the changes
|
|
||||||
var task = Task.Delay(1000);
|
|
||||||
// Have to block here to allow exceptions to bubble
|
|
||||||
Task.WaitAll(task);
|
|
||||||
|
|
||||||
_libraryMonitor.Start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -393,7 +325,7 @@ namespace MediaBrowser.Api.Library
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LibraryHelpers.AddMediaPath(_fileSystem, request.Name, request.Path, _appPaths);
|
_libraryManager.AddMediaPath(request.Name, request.Path);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public string PresentationUniqueKey { get; set; }
|
public string PresentationUniqueKey { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
public string Person { get; set; }
|
public string Person { get; set; }
|
||||||
public string[] PersonIds { get; set; }
|
public string[] PersonIds { get; set; }
|
||||||
public string[] ItemIds { get; set; }
|
public string[] ItemIds { get; set; }
|
||||||
|
@ -107,6 +108,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
|
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
|
||||||
public int? ParentIndexNumber { get; set; }
|
public int? ParentIndexNumber { get; set; }
|
||||||
|
public int? IndexNumber { get; set; }
|
||||||
public int? MinParentalRating { get; set; }
|
public int? MinParentalRating { get; set; }
|
||||||
public int? MaxParentalRating { get; set; }
|
public int? MaxParentalRating { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -569,5 +569,8 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <param name="parent">The parent.</param>
|
/// <param name="parent">The parent.</param>
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
bool IgnoreFile(FileSystemMetadata file, BaseItem parent);
|
bool IgnoreFile(FileSystemMetadata file, BaseItem parent);
|
||||||
|
|
||||||
|
void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, bool refreshLibrary);
|
||||||
|
void AddMediaPath(string virtualFolderName, string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -117,7 +117,7 @@ namespace MediaBrowser.Providers.Folders
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(viewType))
|
if (string.IsNullOrWhiteSpace(viewType))
|
||||||
{
|
{
|
||||||
return urlPrefix + "generic.jpg";
|
//return urlPrefix + "generic.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -952,10 +952,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
if (isArtist)
|
if (isArtist)
|
||||||
{
|
{
|
||||||
var existing = RootFolder
|
var existing = GetItemList(new InternalItemsQuery
|
||||||
.GetRecursiveChildren(i => i is T && NameExtensions.AreEqual(i.Name, name))
|
{
|
||||||
.Cast<T>()
|
IncludeItemTypes = new[] { typeof(T).Name },
|
||||||
.FirstOrDefault();
|
Name = name
|
||||||
|
|
||||||
|
}).Cast<MusicArtist>()
|
||||||
|
.Where(i => !i.IsAccessedByName)
|
||||||
|
.Cast<T>()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
|
@ -2558,5 +2563,107 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, bool refreshLibrary)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
name = _fileSystem.GetValidFilename(name);
|
||||||
|
|
||||||
|
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||||
|
|
||||||
|
var virtualFolderPath = Path.Combine(rootFolderPath, name);
|
||||||
|
while (_fileSystem.DirectoryExists(virtualFolderPath))
|
||||||
|
{
|
||||||
|
name += "1";
|
||||||
|
virtualFolderPath = Path.Combine(rootFolderPath, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mediaPaths != null)
|
||||||
|
{
|
||||||
|
var invalidpath = mediaPaths.FirstOrDefault(i => !_fileSystem.DirectoryExists(i));
|
||||||
|
if (invalidpath != null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("The specified path does not exist: " + invalidpath + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_libraryMonitorFactory().Stop();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_fileSystem.CreateDirectory(virtualFolderPath);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(collectionType))
|
||||||
|
{
|
||||||
|
var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
|
||||||
|
|
||||||
|
using (File.Create(path))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mediaPaths != null)
|
||||||
|
{
|
||||||
|
foreach (var path in mediaPaths)
|
||||||
|
{
|
||||||
|
AddMediaPath(name, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
// No need to start if scanning the library because it will handle it
|
||||||
|
if (refreshLibrary)
|
||||||
|
{
|
||||||
|
ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Need to add a delay here or directory watchers may still pick up the changes
|
||||||
|
var task = Task.Delay(1000);
|
||||||
|
// Have to block here to allow exceptions to bubble
|
||||||
|
Task.WaitAll(task);
|
||||||
|
|
||||||
|
_libraryMonitorFactory().Start();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private const string ShortcutFileExtension = ".mblink";
|
||||||
|
public void AddMediaPath(string virtualFolderName, string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("path");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_fileSystem.DirectoryExists(path))
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException("The path does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||||
|
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
|
||||||
|
|
||||||
|
var shortcutFilename = _fileSystem.GetFileNameWithoutExtension(path);
|
||||||
|
|
||||||
|
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
|
||||||
|
|
||||||
|
while (_fileSystem.FileExists(lnk))
|
||||||
|
{
|
||||||
|
shortcutFilename += "1";
|
||||||
|
lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
|
||||||
|
}
|
||||||
|
|
||||||
|
_fileSystem.CreateShortcut(lnk, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1966,9 +1966,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
// cmd.Parameters.Add(cmd, "@MaxPlayers", DbType.Int32).Value = query.MaxPlayers.Value;
|
// cmd.Parameters.Add(cmd, "@MaxPlayers", DbType.Int32).Value = query.MaxPlayers.Value;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
if (query.IndexNumber.HasValue)
|
||||||
|
{
|
||||||
|
whereClauses.Add("IndexNumber=@IndexNumber");
|
||||||
|
cmd.Parameters.Add(cmd, "@IndexNumber", DbType.Int32).Value = query.IndexNumber.Value;
|
||||||
|
}
|
||||||
if (query.ParentIndexNumber.HasValue)
|
if (query.ParentIndexNumber.HasValue)
|
||||||
{
|
{
|
||||||
whereClauses.Add("ParentIndexNumber=@MinEndDate");
|
whereClauses.Add("ParentIndexNumber=@ParentIndexNumber");
|
||||||
cmd.Parameters.Add(cmd, "@ParentIndexNumber", DbType.Int32).Value = query.ParentIndexNumber.Value;
|
cmd.Parameters.Add(cmd, "@ParentIndexNumber", DbType.Int32).Value = query.ParentIndexNumber.Value;
|
||||||
}
|
}
|
||||||
if (query.MinEndDate.HasValue)
|
if (query.MinEndDate.HasValue)
|
||||||
|
@ -2065,6 +2070,19 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
cmd.Parameters.Add(cmd, "@PersonName", DbType.String).Value = query.Person;
|
cmd.Parameters.Add(cmd, "@PersonName", DbType.String).Value = query.Person;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(query.Name))
|
||||||
|
{
|
||||||
|
if (_config.Configuration.SchemaVersion >= 66)
|
||||||
|
{
|
||||||
|
whereClauses.Add("CleanName=@Name");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
whereClauses.Add("Name=@Name");
|
||||||
|
}
|
||||||
|
cmd.Parameters.Add(cmd, "@Name", DbType.String).Value = query.Name;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(query.NameContains))
|
if (!string.IsNullOrWhiteSpace(query.NameContains))
|
||||||
{
|
{
|
||||||
if (_config.Configuration.SchemaVersion >= 66)
|
if (_config.Configuration.SchemaVersion >= 66)
|
||||||
|
|
|
@ -153,7 +153,8 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||||
CollectionType.HomeVideos,
|
CollectionType.HomeVideos,
|
||||||
CollectionType.BoxSets,
|
CollectionType.BoxSets,
|
||||||
CollectionType.Playlists,
|
CollectionType.Playlists,
|
||||||
CollectionType.Photos
|
CollectionType.Photos,
|
||||||
|
string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty);
|
return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty);
|
||||||
|
|
Loading…
Reference in a new issue