added the api to get libs

pull/4252/head
tidusjar 4 years ago
parent b3a2fbdb0d
commit 4505488289

@ -6,5 +6,6 @@ namespace Ombi.Api.Jellyfin
public interface IJellyfinApi : IBaseJellyfinApi
{
Task<JellyfinConnectUser> LoginConnectUser(string username, string password);
Task<JellyfinItemContainer<MediaFolders>> GetLibraries(string apiKey, string baseUrl);
}
}

@ -1,12 +1,12 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Internal;
using Newtonsoft.Json;
using Ombi.Api.Jellyfin.Models;
using Ombi.Api.Jellyfin.Models.Media.Tv;
using Ombi.Api.Jellyfin.Models.Movie;
using Ombi.Helpers;
namespace Ombi.Api.Jellyfin
{
@ -87,6 +87,16 @@ namespace Ombi.Api.Jellyfin
return await Api.Request<JellyfinItemContainer<JellyfinMovie>>(request);
}
public async Task<JellyfinItemContainer<MediaFolders>> GetLibraries(string apiKey, string baseUrl)
{
var request = new Request("library/mediafolders", baseUrl, HttpMethod.Get);
AddHeaders(request, apiKey);
var response = await Api.Request<JellyfinItemContainer<MediaFolders>>(request);
response.Items = response.Items.Where(x => !x.CollectionType.Equals("playlists", StringComparison.InvariantCultureIgnoreCase)).ToList();
return response;
}
public async Task<JellyfinItemContainer<JellyfinMovie>> GetAllMovies(string apiKey, int startIndex, int count, string userId, string baseUri)
{
return await GetAll<JellyfinMovie>("Movie", apiKey, userId, baseUri, true, startIndex, count);

@ -0,0 +1,10 @@
namespace Ombi.Api.Jellyfin.Models
{
public class MediaFolders
{
public string Name { get; set; }
public string ServerId { get; set; }
public string Id { get; set; }
public string CollectionType { get; set; }
}
}

@ -66,6 +66,14 @@ namespace Ombi.Controllers.V1.External
return result;
}
[HttpPost("Library")]
public async Task<JellyfinItemContainer<MediaFolders>> GetLibaries([FromBody] JellyfinServers server)
{
var client = await JellyfinApi.CreateClient();
var result = await client.GetLibraries(server.ApiKey, server.FullUri);
return result;
}
/// <summary>
/// Gets the jellyfin users.
/// </summary>

Loading…
Cancel
Save