Files
jellyfin-jellyfin-1/MediaBrowser.Controller/Providers/MetadataResult.cs

75 lines
1.8 KiB
C#
Raw Normal View History

#nullable disable
#pragma warning disable CA1002, CA2227, CS1591
2018-12-27 18:27:57 -05:00
using System.Collections.Generic;
2024-10-09 10:36:08 +00:00
using System.Linq;
using MediaBrowser.Controller.Entities;
2021-02-27 22:46:03 +01:00
using MediaBrowser.Model.Entities;
2018-12-27 18:27:57 -05:00
namespace MediaBrowser.Controller.Providers
{
public class MetadataResult<T>
{
2021-05-24 00:30:41 +02:00
// Images aren't always used so the allocation is a waste a lot of the time
private List<LocalImageInfo> _images;
2021-12-24 14:18:24 -07:00
private List<(string Url, ImageType Type)> _remoteImages;
2024-10-09 10:36:08 +00:00
private List<PersonInfo> _people;
2021-05-24 00:30:41 +02:00
2018-12-27 18:27:57 -05:00
public MetadataResult()
{
ResultLanguage = "en";
}
2021-05-24 00:30:41 +02:00
public List<LocalImageInfo> Images
{
2024-10-09 10:36:08 +00:00
get => _images ??= [];
2021-05-24 00:30:41 +02:00
set => _images = value;
}
2021-02-27 22:46:03 +01:00
2021-12-24 14:18:24 -07:00
public List<(string Url, ImageType Type)> RemoteImages
2021-05-24 00:30:41 +02:00
{
2024-10-09 10:36:08 +00:00
get => _remoteImages ??= [];
2021-05-24 00:30:41 +02:00
set => _remoteImages = value;
}
2021-02-27 22:46:03 +01:00
2024-10-09 10:36:08 +00:00
public IReadOnlyList<PersonInfo> People
{
get => _people;
set => _people = value.ToList();
}
2018-12-27 18:27:57 -05:00
public bool HasMetadata { get; set; }
2018-12-27 18:27:57 -05:00
public T Item { get; set; }
2018-12-27 18:27:57 -05:00
public string ResultLanguage { get; set; }
2018-12-27 18:27:57 -05:00
public string Provider { get; set; }
2018-12-27 18:27:57 -05:00
public bool QueriedById { get; set; }
2018-12-27 18:27:57 -05:00
public void AddPerson(PersonInfo p)
{
People ??= new List<PersonInfo>();
2018-12-27 18:27:57 -05:00
2024-10-09 10:36:08 +00:00
PeopleHelper.AddPerson(_people, p);
2018-12-27 18:27:57 -05:00
}
/// <summary>
/// Not only does this clear, but initializes the list so that services can differentiate between a null list and zero people.
2018-12-27 18:27:57 -05:00
/// </summary>
public void ResetPeople()
{
2022-12-05 15:00:20 +01:00
if (People is null)
2018-12-27 18:27:57 -05:00
{
People = new List<PersonInfo>();
}
else
{
2024-10-09 10:36:08 +00:00
_people.Clear();
}
2018-12-27 18:27:57 -05:00
}
}
2018-12-27 22:43:48 +01:00
}