mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Fixed the jellyfin load libraries issue #4266
This commit is contained in:
parent
a702e22b04
commit
7119407141
5 changed files with 81 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Api.Jellyfin.Models;
|
||||
|
||||
namespace Ombi.Api.Jellyfin
|
||||
|
@ -6,6 +7,6 @@ namespace Ombi.Api.Jellyfin
|
|||
public interface IJellyfinApi : IBaseJellyfinApi
|
||||
{
|
||||
Task<JellyfinConnectUser> LoginConnectUser(string username, string password);
|
||||
Task<JellyfinItemContainer<MediaFolders>> GetLibraries(string apiKey, string baseUrl);
|
||||
Task<List<LibraryVirtualFolders>> GetLibraries(string apiKey, string baseUrl);
|
||||
}
|
||||
}
|
|
@ -87,13 +87,12 @@ namespace Ombi.Api.Jellyfin
|
|||
return await Api.Request<JellyfinItemContainer<JellyfinMovie>>(request);
|
||||
}
|
||||
|
||||
public async Task<JellyfinItemContainer<MediaFolders>> GetLibraries(string apiKey, string baseUrl)
|
||||
public async Task<List<LibraryVirtualFolders>> GetLibraries(string apiKey, string baseUrl)
|
||||
{
|
||||
var request = new Request("library/mediafolders", baseUrl, HttpMethod.Get);
|
||||
var request = new Request("library/virtualfolders", 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();
|
||||
var response = await Api.Request<List<LibraryVirtualFolders>>(request);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
26
src/Ombi.Api.Jellyfin/Models/LibraryVirtualFolders.cs
Normal file
26
src/Ombi.Api.Jellyfin/Models/LibraryVirtualFolders.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Api.Jellyfin.Models
|
||||
{
|
||||
public class LibraryVirtualFolders
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Libraryoptions LibraryOptions { get; set; }
|
||||
public string ItemId { get; set; }
|
||||
}
|
||||
|
||||
public class Libraryoptions
|
||||
{
|
||||
public List<Typeoption> TypeOptions { get; set; } = new List<Typeoption>();
|
||||
}
|
||||
|
||||
public class Typeoption
|
||||
{
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
}
|
|
@ -96,6 +96,14 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
|||
_logger.LogInformation($"Scanning Lib '{tvParentIdFilter.Title}'");
|
||||
await ProcessTv(server, tvParentIdFilter.Key);
|
||||
}
|
||||
|
||||
var mixedLibs = server.JellyfinSelectedLibraries.Where(x => x.Enabled && x.CollectionType == "mixed");
|
||||
foreach (var m in mixedLibs)
|
||||
{
|
||||
_logger.LogInformation($"Scanning Lib '{m.Title}'");
|
||||
await ProcessTv(server, m.Key);
|
||||
await ProcessMovies(server, m.Key);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
@ -71,7 +72,45 @@ namespace Ombi.Controllers.V1.External
|
|||
{
|
||||
var client = await JellyfinApi.CreateClient();
|
||||
var result = await client.GetLibraries(server.ApiKey, server.FullUri);
|
||||
return result;
|
||||
var mediaFolders = new JellyfinItemContainer<MediaFolders>
|
||||
{
|
||||
TotalRecordCount = result.Count,
|
||||
Items = new List<MediaFolders>()
|
||||
};
|
||||
|
||||
foreach (var folder in result)
|
||||
{
|
||||
var toAdd = new MediaFolders
|
||||
{
|
||||
Name = folder.Name,
|
||||
Id = folder.ItemId,
|
||||
ServerId = server.ServerId
|
||||
};
|
||||
|
||||
var types = folder?.LibraryOptions?.TypeOptions?.Select(x => x.Type).ToList();
|
||||
|
||||
if (!types.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (types.Where(x => x.Equals("Movie", System.StringComparison.InvariantCultureIgnoreCase)
|
||||
|| x.Equals("Episode", System.StringComparison.InvariantCultureIgnoreCase)).Count() >= 2)
|
||||
{
|
||||
toAdd.CollectionType = "mixed";
|
||||
}
|
||||
else if (types.Any(x => x.Equals("Movie", StringComparison.InvariantCultureIgnoreCase)))
|
||||
{
|
||||
toAdd.CollectionType = "movies";
|
||||
}
|
||||
else if (types.Any(x => x.Equals("Episode", StringComparison.InvariantCultureIgnoreCase)))
|
||||
{
|
||||
toAdd.CollectionType = "tvshows";
|
||||
}
|
||||
|
||||
mediaFolders.Items.Add(toAdd);
|
||||
}
|
||||
return mediaFolders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue