don't look at me
This commit is contained in:
parent
e9f444e5b4
commit
cedbad8fba
56 changed files with 1111 additions and 294 deletions
74
backend/src/Services/LibraryService.cs
Normal file
74
backend/src/Services/LibraryService.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
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 (!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)
|
||||
// {
|
||||
|
||||
// }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue