mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 06:18:28 +01:00
improve user view images
This commit is contained in:
@@ -530,8 +530,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return item;
|
||||
}
|
||||
|
||||
public BaseItem ResolvePath(FileSystemInfo fileInfo,
|
||||
Folder parent = null,
|
||||
public BaseItem ResolvePath(FileSystemInfo fileInfo,
|
||||
Folder parent = null,
|
||||
string collectionType = null)
|
||||
{
|
||||
return ResolvePath(fileInfo, new DirectoryService(_logger), parent, collectionType);
|
||||
@@ -1190,7 +1190,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intros.
|
||||
/// </summary>
|
||||
@@ -1508,27 +1508,22 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return collectionTypes.Count == 1 ? collectionTypes[0] : null;
|
||||
}
|
||||
|
||||
public Task<UserView> GetNamedView(string name, string type, string sortName, CancellationToken cancellationToken)
|
||||
{
|
||||
return GetNamedView(name, null, type, sortName, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<UserView> GetNamedView(string name, string category, string type, string sortName, CancellationToken cancellationToken)
|
||||
public async Task<UserView> GetNamedView(string name,
|
||||
string type,
|
||||
string sortName,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
|
||||
"views");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(category))
|
||||
{
|
||||
path = Path.Combine(path, _fileSystem.GetValidFilename(category));
|
||||
}
|
||||
|
||||
path = Path.Combine(path, _fileSystem.GetValidFilename(type));
|
||||
|
||||
var id = (path + "_namedview_" + name).GetMBId(typeof(UserView));
|
||||
|
||||
var item = GetItemById(id) as UserView;
|
||||
|
||||
var refresh = false;
|
||||
|
||||
if (item == null ||
|
||||
!string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -1546,7 +1541,89 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
await CreateItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
refresh = true;
|
||||
}
|
||||
|
||||
if (!refresh && item != null)
|
||||
{
|
||||
refresh = (DateTime.UtcNow - item.DateLastSaved).TotalHours >= 24;
|
||||
}
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
await item.RefreshMetadata(new MetadataRefreshOptions
|
||||
{
|
||||
ForceSave = true
|
||||
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<UserView> GetSpecialFolder(User user,
|
||||
string name,
|
||||
string parentId,
|
||||
string viewType,
|
||||
string sortName,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(parentId))
|
||||
{
|
||||
throw new ArgumentNullException("parentId");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(viewType))
|
||||
{
|
||||
throw new ArgumentNullException("viewType");
|
||||
}
|
||||
|
||||
var id = ("7_namedview_" + name + user.Id.ToString("N") + parentId).GetMBId(typeof(UserView));
|
||||
|
||||
var path = BaseItem.GetInternalMetadataPathForId(id);
|
||||
|
||||
var item = GetItemById(id) as UserView;
|
||||
|
||||
var refresh = false;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
item = new UserView
|
||||
{
|
||||
Path = path,
|
||||
Id = id,
|
||||
DateCreated = DateTime.UtcNow,
|
||||
Name = name,
|
||||
ViewType = viewType,
|
||||
ForcedSortName = sortName,
|
||||
UserId = user.Id,
|
||||
ParentId = new Guid(parentId)
|
||||
};
|
||||
|
||||
await CreateItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
refresh = true;
|
||||
}
|
||||
|
||||
if (!refresh && item != null)
|
||||
{
|
||||
refresh = (DateTime.UtcNow - item.DateLastSaved).TotalHours >= 24;
|
||||
}
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
await item.RefreshMetadata(new MetadataRefreshOptions
|
||||
{
|
||||
ForceSave = true
|
||||
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
@@ -68,24 +68,24 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) ||
|
||||
foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType)))
|
||||
{
|
||||
list.Add(await GetUserView(CollectionType.TvShows, user, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(CollectionType.TvShows, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) ||
|
||||
foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
list.Add(await GetUserView(CollectionType.Music, user, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(CollectionType.Music, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) ||
|
||||
foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType)))
|
||||
{
|
||||
list.Add(await GetUserView(CollectionType.Movies, user, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(CollectionType.Movies, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
list.Add(await GetUserView(CollectionType.Games, user, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(CollectionType.Games, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (user.Configuration.DisplayCollectionsView &&
|
||||
@@ -93,7 +93,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
.Except(standaloneFolders)
|
||||
.SelectMany(i => i.GetRecursiveChildren(user, false)).OfType<BoxSet>().Any())
|
||||
{
|
||||
list.Add(await GetUserView(CollectionType.BoxSets, user, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)))
|
||||
@@ -103,7 +103,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
if (user.Configuration.DisplayFoldersView)
|
||||
{
|
||||
list.Add(await GetUserView(CollectionType.Folders, user, "zz_" + CollectionType.Folders, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(CollectionType.Folders, "zz_" + CollectionType.Folders, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (query.IncludeExternalContent)
|
||||
@@ -148,16 +148,18 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
.ThenBy(i => i.SortName);
|
||||
}
|
||||
|
||||
public Task<UserView> GetUserView(string category, string type, User user, string sortName, CancellationToken cancellationToken)
|
||||
public Task<UserView> GetUserView(string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
|
||||
{
|
||||
var name = _localizationManager.GetLocalizedString("ViewType" + type);
|
||||
|
||||
return _libraryManager.GetNamedView(name, category, type, sortName, cancellationToken);
|
||||
return _libraryManager.GetSpecialFolder(user, name, parentId, type, sortName, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
|
||||
public Task<UserView> GetUserView(string type, string sortName, CancellationToken cancellationToken)
|
||||
{
|
||||
return GetUserView(null, type, user, sortName, cancellationToken);
|
||||
var name = _localizationManager.GetLocalizedString("ViewType" + type);
|
||||
|
||||
return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user