mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
improve poster sizing
This commit is contained in:
@@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||
|
||||
public Folder GetCollectionsFolder(string userId)
|
||||
{
|
||||
return _libraryManager.RootFolder.Children.Concat(_libraryManager.RootFolder).OfType<ManualCollectionsFolder>()
|
||||
return _libraryManager.RootFolder.Children.OfType<ManualCollectionsFolder>()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
@@ -10,16 +9,17 @@ using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Server.Implementations.Configuration;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
@@ -33,8 +33,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
private readonly IPlaylistManager _playlists;
|
||||
|
||||
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IFileSystem fileSystem, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerApplicationPaths appPaths)
|
||||
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IFileSystem fileSystem, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerApplicationPaths appPaths, IPlaylistManager playlists)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_localizationManager = localizationManager;
|
||||
@@ -43,6 +44,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
_channelManager = channelManager;
|
||||
_liveTvManager = liveTvManager;
|
||||
_appPaths = appPaths;
|
||||
_playlists = playlists;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken)
|
||||
@@ -94,6 +96,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
list.Add(await GetUserView(CollectionType.BoxSets, user, CollectionType.BoxSets, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (recursiveChildren.OfType<Playlist>().Any())
|
||||
{
|
||||
list.Add(_playlists.GetPlaylistsFolder(user.Id.ToString("N")));
|
||||
}
|
||||
|
||||
if (query.IncludeExternalContent)
|
||||
{
|
||||
var channelResult = await _channelManager.GetChannels(new ChannelQuery
|
||||
|
||||
@@ -221,6 +221,8 @@
|
||||
<Compile Include="Persistence\SqliteProviderInfoRepository.cs" />
|
||||
<Compile Include="Persistence\SqliteShrinkMemoryTimer.cs" />
|
||||
<Compile Include="Persistence\TypeMapper.cs" />
|
||||
<Compile Include="Playlists\ManualPlaylistsFolder.cs" />
|
||||
<Compile Include="Playlists\PlaylistManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ScheduledTasks\PeopleValidationTask.cs" />
|
||||
<Compile Include="ScheduledTasks\ChapterImagesTask.cs" />
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Playlists
|
||||
{
|
||||
public class PlaylistsFolder : BasePluginFolder
|
||||
{
|
||||
public PlaylistsFolder()
|
||||
{
|
||||
Name = "Playlists";
|
||||
}
|
||||
|
||||
public override bool IsVisible(User user)
|
||||
{
|
||||
return GetChildren(user, true).Any() &&
|
||||
base.IsVisible(user);
|
||||
}
|
||||
|
||||
public override bool IsHidden
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsHiddenFromUser(User user)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string CollectionType
|
||||
{
|
||||
get { return Model.Entities.CollectionType.Playlists; }
|
||||
}
|
||||
}
|
||||
|
||||
public class PlaylistssDynamicFolder : IVirtualFolderCreator
|
||||
{
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
public PlaylistssDynamicFolder(IApplicationPaths appPaths)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public BasePluginFolder GetFolder()
|
||||
{
|
||||
var path = Path.Combine(_appPaths.DataPath, "playlists");
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
return new PlaylistsFolder
|
||||
{
|
||||
Path = path
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
137
MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs
Normal file
137
MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Playlists
|
||||
{
|
||||
public class PlaylistManager : IPlaylistManager
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryMonitor _iLibraryMonitor;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public PlaylistManager(ILibraryManager libraryManager, IFileSystem fileSystem, ILibraryMonitor iLibraryMonitor, ILogger logger, IUserManager userManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_fileSystem = fileSystem;
|
||||
_iLibraryMonitor = iLibraryMonitor;
|
||||
_logger = logger;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public IEnumerable<Playlist> GetPlaylists(string userId)
|
||||
{
|
||||
var user = _userManager.GetUserById(new Guid(userId));
|
||||
|
||||
return GetPlaylistsFolder(userId).GetChildren(user, true).OfType<Playlist>();
|
||||
}
|
||||
|
||||
public async Task<Playlist> CreatePlaylist(PlaylistCreationOptions options)
|
||||
{
|
||||
var name = options.Name;
|
||||
|
||||
// Need to use the [boxset] suffix
|
||||
// If internet metadata is not found, or if xml saving is off there will be no collection.xml
|
||||
// This could cause it to get re-resolved as a plain folder
|
||||
var folderName = _fileSystem.GetValidFilename(name) + " [playlist]";
|
||||
|
||||
var parentFolder = GetPlaylistsFolder(null);
|
||||
|
||||
if (parentFolder == null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
var path = Path.Combine(parentFolder.Path, folderName);
|
||||
|
||||
_iLibraryMonitor.ReportFileSystemChangeBeginning(path);
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var collection = new Playlist
|
||||
{
|
||||
Name = name,
|
||||
Parent = parentFolder,
|
||||
Path = path
|
||||
};
|
||||
|
||||
await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await collection.RefreshMetadata(new MetadataRefreshOptions(), CancellationToken.None)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (options.ItemIdList.Count > 0)
|
||||
{
|
||||
await AddToPlaylist(collection.Id.ToString("N"), options.ItemIdList);
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Refresh handled internally
|
||||
_iLibraryMonitor.ReportFileSystemChangeComplete(path, false);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddToPlaylist(string playlistId, IEnumerable<string> itemIds)
|
||||
{
|
||||
var collection = _libraryManager.GetItemById(playlistId) as Playlist;
|
||||
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentException("No Playlist exists with the supplied Id");
|
||||
}
|
||||
|
||||
var list = new List<LinkedChild>();
|
||||
var itemList = new List<BaseItem>();
|
||||
|
||||
foreach (var itemId in itemIds)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(itemId);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentException("No item exists with the supplied Id");
|
||||
}
|
||||
|
||||
itemList.Add(item);
|
||||
|
||||
list.Add(new LinkedChild
|
||||
{
|
||||
Type = LinkedChildType.Manual,
|
||||
ItemId = item.Id
|
||||
});
|
||||
}
|
||||
|
||||
collection.LinkedChildren.AddRange(list);
|
||||
|
||||
await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||
await collection.RefreshMetadata(CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public Task RemoveFromPlaylist(string playlistId, IEnumerable<int> indeces)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Folder GetPlaylistsFolder(string userId)
|
||||
{
|
||||
return _libraryManager.RootFolder.Children.OfType<PlaylistsFolder>()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user