mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 06:18:28 +01:00
added sync job database
This commit is contained in:
@@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (args.Parent != null)
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(Path.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(filename))
|
||||
if (string.Equals(_fileSystem.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(filename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1157,7 +1157,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
private string GetCollectionType(string path)
|
||||
{
|
||||
return new DirectoryInfo(path).EnumerateFiles("*.collection", SearchOption.TopDirectoryOnly)
|
||||
.Select(i => Path.GetFileNameWithoutExtension(i.FullName))
|
||||
.Select(i => _fileSystem.GetFileNameWithoutExtension(i))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
@@ -1486,23 +1486,22 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
public async Task<UserView> GetNamedView(string name, string type, string sortName, CancellationToken cancellationToken)
|
||||
{
|
||||
var id = "namedview_3_" + name;
|
||||
var guid = id.GetMD5();
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
|
||||
"views",
|
||||
_fileSystem.GetValidFilename(type));
|
||||
|
||||
var item = GetItemById(guid) as UserView;
|
||||
var id = (path + "_namedview_" + name).GetMBId(typeof(UserView));
|
||||
|
||||
var item = GetItemById(id) as UserView;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
|
||||
"views",
|
||||
_fileSystem.GetValidFilename(type));
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
item = new UserView
|
||||
{
|
||||
Path = path,
|
||||
Id = guid,
|
||||
Id = id,
|
||||
DateCreated = DateTime.UtcNow,
|
||||
Name = name,
|
||||
ViewType = type,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
@@ -6,6 +7,7 @@ using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -17,6 +19,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
public class MusicAlbumResolver : ItemResolver<MusicAlbum>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public MusicAlbumResolver(ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@@ -64,10 +75,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsMusicAlbum(string path, IDirectoryService directoryService)
|
||||
public static bool IsMusicAlbum(string path, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService);
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, logger, fileSystem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,13 +88,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <returns><c>true</c> if [is music album] [the specified args]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsMusicAlbum(ItemResolveArgs args)
|
||||
private bool IsMusicAlbum(ItemResolveArgs args)
|
||||
{
|
||||
// Args points to an album if parent is an Artist folder or it directly contains music
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
//if (args.Parent is MusicArtist) return true; //saves us from testing children twice
|
||||
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService)) return true;
|
||||
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -93,19 +106,23 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// <param name="list">The list.</param>
|
||||
/// <param name="allowSubfolders">if set to <c>true</c> [allow subfolders].</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
|
||||
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list, bool allowSubfolders, IDirectoryService directoryService)
|
||||
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list, bool allowSubfolders, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||
var foundAudio = 0;
|
||||
|
||||
var discSubfolderCount = 0;
|
||||
|
||||
foreach (var fileSystemInfo in list)
|
||||
{
|
||||
if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
if (allowSubfolders && IsAlbumSubfolder(fileSystemInfo, directoryService))
|
||||
if (allowSubfolders && IsAlbumSubfolder(fileSystemInfo, directoryService, logger, fileSystem))
|
||||
{
|
||||
return true;
|
||||
discSubfolderCount++;
|
||||
}
|
||||
if (!IsAdditionalSubfolderAllowed(fileSystemInfo))
|
||||
{
|
||||
@@ -118,7 +135,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
if (EntityResolutionHelper.IsAudioFile(fullName))
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(Path.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(fullName))
|
||||
if (string.Equals(fileSystem.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(fullName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -135,16 +152,18 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
}
|
||||
|
||||
// or a single audio file and no video files
|
||||
return foundAudio > 0;
|
||||
return foundAudio > 0 || discSubfolderCount > 0;
|
||||
}
|
||||
|
||||
private static bool IsAlbumSubfolder(FileSystemInfo directory, IDirectoryService directoryService)
|
||||
private static bool IsAlbumSubfolder(FileSystemInfo directory, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
var path = directory.FullName;
|
||||
|
||||
if (IsMultiDiscFolder(path))
|
||||
{
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService);
|
||||
logger.Debug("Found multi-disc folder: " + path);
|
||||
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -15,6 +17,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
public class MusicArtistResolver : ItemResolver<MusicArtist>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public MusicArtistResolver(ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@@ -61,7 +72,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
var directoryService = args.DirectoryService;
|
||||
|
||||
// If we contain an album assume we are an artist folder
|
||||
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, directoryService)) ? new MusicArtist() : null;
|
||||
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, directoryService, _logger, _fileSystem)) ? new MusicArtist() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using System;
|
||||
@@ -12,6 +13,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
/// </summary>
|
||||
public class FolderResolver : FolderResolver<Folder>
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public FolderResolver(IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@@ -69,7 +77,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
}
|
||||
|
||||
})
|
||||
.Select(i => Path.GetFileNameWithoutExtension(i.FullName))
|
||||
.Select(i => _fileSystem.GetFileNameWithoutExtension(i))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using System;
|
||||
@@ -11,6 +12,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
/// </summary>
|
||||
public class LocalTrailerResolver : BaseVideoResolver<Trailer>
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public LocalTrailerResolver(IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the specified args.
|
||||
/// </summary>
|
||||
@@ -33,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
}
|
||||
|
||||
// Support xbmc local trailer convention, but only when looking for local trailers (hence the parent == null check)
|
||||
if (args.Parent == null && Path.GetFileNameWithoutExtension(args.Path).EndsWith(BaseItem.XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase))
|
||||
if (args.Parent == null && _fileSystem.GetFileNameWithoutExtension(args.Path).EndsWith(BaseItem.XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return base.Resolve(args);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
@@ -22,12 +23,14 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
private readonly IServerApplicationPaths _applicationPaths;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public MovieResolver(IServerApplicationPaths appPaths, ILibraryManager libraryManager, ILogger logger)
|
||||
public MovieResolver(IServerApplicationPaths appPaths, ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
_applicationPaths = appPaths;
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -407,7 +410,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filenamePrefix))
|
||||
{
|
||||
if (sortedMovies.All(i => Path.GetFileNameWithoutExtension(i.Path).StartsWith(filenamePrefix + " - ", StringComparison.OrdinalIgnoreCase)))
|
||||
if (sortedMovies.All(i => _fileSystem.GetFileNameWithoutExtension(i.Path).StartsWith(filenamePrefix + " - ", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
firstMovie.HasLocalAlternateVersions = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -14,6 +15,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
/// </summary>
|
||||
public class SeriesResolver : FolderResolver<Series>
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public SeriesResolver(IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@@ -67,8 +75,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (TVUtils.IsSeriesFolder(args.Path, collectionType == CollectionType.TvShows, args.FileSystemChildren, args.DirectoryService))
|
||||
|
||||
if (TVUtils.IsSeriesFolder(args.Path, collectionType == CollectionType.TvShows, args.FileSystemChildren, args.DirectoryService, _fileSystem))
|
||||
{
|
||||
return new Series();
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <exception cref="System.ArgumentException"></exception>
|
||||
public async Task<User> CreateUser(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user