mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Change the API to use the virtual folders call and also take into consideration mixed content folders #2389
This commit is contained in:
parent
046bad66d6
commit
309f214203
5 changed files with 80 additions and 7 deletions
|
@ -115,13 +115,12 @@ namespace Ombi.Api.Emby
|
|||
return await Api.Request<EmbyItemContainer<EmbyMovie>>(request);
|
||||
}
|
||||
|
||||
public async Task<EmbyItemContainer<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<EmbyItemContainer<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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Api.Emby.Models;
|
||||
using Ombi.Api.Emby.Models.Media;
|
||||
|
||||
|
@ -7,6 +8,6 @@ namespace Ombi.Api.Emby
|
|||
public interface IEmbyApi : IBaseEmbyApi
|
||||
{
|
||||
Task<EmbyConnectUser> LoginConnectUser(string username, string password);
|
||||
Task<EmbyItemContainer<MediaFolders>> GetLibraries(string apiKey, string baseUrl);
|
||||
Task<List<LibraryVirtualFolders>> GetLibraries(string apiKey, string baseUrl);
|
||||
}
|
||||
}
|
26
src/Ombi.Api.Emby/Models/LibraryVirtualFolders.cs
Normal file
26
src/Ombi.Api.Emby/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.Emby.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; }
|
||||
}
|
||||
|
||||
}
|
|
@ -95,6 +95,15 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
_logger.LogInformation($"Scanning Lib '{tvParentIdFilter.Title}'");
|
||||
await ProcessTv(server, tvParentIdFilter.Key);
|
||||
}
|
||||
|
||||
|
||||
var mixedLibs = server.EmbySelectedLibraries.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
|
||||
{
|
||||
|
|
|
@ -98,7 +98,45 @@ namespace Ombi.Controllers.V1.External
|
|||
{
|
||||
var client = await EmbyApi.CreateClient();
|
||||
var result = await client.GetLibraries(server.ApiKey, server.FullUri);
|
||||
return result;
|
||||
var mediaFolders = new EmbyItemContainer<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);
|
||||
|
||||
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.Where(x => x.Equals("Movie", System.StringComparison.InvariantCultureIgnoreCase)).Any())
|
||||
{
|
||||
toAdd.CollectionType = "movies";
|
||||
}
|
||||
else if (types.Where(x => x.Equals("Episode", System.StringComparison.InvariantCultureIgnoreCase)).Any())
|
||||
{
|
||||
toAdd.CollectionType = "tvshows";
|
||||
}
|
||||
|
||||
mediaFolders.Items.Add(toAdd);
|
||||
}
|
||||
return mediaFolders;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue