79 lines
No EOL
1.6 KiB
C#
79 lines
No EOL
1.6 KiB
C#
using JellyGlass.Models;
|
|
|
|
namespace JellyGlass.Services;
|
|
|
|
public class LibraryService : ILibraryService
|
|
{
|
|
private IServerService _serverService;
|
|
|
|
public LibraryService(IServerService serverService)
|
|
{
|
|
_serverService = serverService;
|
|
}
|
|
|
|
public async Task<Library[]> GetLibraries()
|
|
{
|
|
var clients = await _serverService.GetJellyfinClients();
|
|
|
|
var libraries = new Dictionary<string, Library>();
|
|
|
|
foreach (var client in clients)
|
|
{
|
|
var clientLibraries = await client.GetInstanceLibraries();
|
|
|
|
foreach (var library in clientLibraries.Items)
|
|
{
|
|
if (library.Name == "Collections" || library.Name == "Playlists")
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (!libraries.ContainsKey(library.Name))
|
|
{
|
|
|
|
libraries.Add(library.Name, new Library()
|
|
{
|
|
Name = library.Name,
|
|
ThumbnailUrl = $"{client.InstanceUrl}/Items/{library.Id}/Primary"
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
return libraries.Values.ToArray();
|
|
}
|
|
|
|
public async Task<ItemDTO[]> GetItemsFromLibrary(string libraryName)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
// public async Task<ItemDTO[]> GetChildrenFromItems(ItemDTO[] items)
|
|
// {
|
|
// var children = new List<ItemDTO>();
|
|
|
|
// foreach (var item in items)
|
|
// {
|
|
// var client = _serverService.GetClientForServerId(item.ServerID);
|
|
|
|
// var itemChildren = await client.GetItemChildren(item.ID);
|
|
|
|
// foreach (var child in itemChildren.Items)
|
|
// {
|
|
// children.Add(new ItemDTO(child, client.InstanceUrl));
|
|
// }
|
|
// }
|
|
|
|
// return children.ToArray();
|
|
// }
|
|
|
|
// public async Task<ItemDTO> GetItemsByName(string name, string itemType)
|
|
// {
|
|
|
|
// }
|
|
|
|
// public async Task<ItemDTO> GetItemsByType(string itemType)
|
|
// {
|
|
|
|
// }
|
|
} |