2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-23 16:16:48 +00:00
|
|
|
#pragma warning disable CA1002, CA2227, CS1591
|
2020-08-22 19:56:24 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2019-02-28 22:22:57 +00:00
|
|
|
using System.Globalization;
|
2019-01-13 19:25:32 +00:00
|
|
|
using MediaBrowser.Controller.Entities;
|
2021-02-27 21:46:03 +00:00
|
|
|
using MediaBrowser.Model.Entities;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Providers
|
|
|
|
{
|
|
|
|
public class MetadataResult<T>
|
|
|
|
{
|
2021-05-23 22:30:41 +00:00
|
|
|
// Images aren't always used so the allocation is a waste a lot of the time
|
|
|
|
private List<LocalImageInfo> _images;
|
2021-12-24 21:18:24 +00:00
|
|
|
private List<(string Url, ImageType Type)> _remoteImages;
|
2021-05-23 22:30:41 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public MetadataResult()
|
|
|
|
{
|
|
|
|
ResultLanguage = "en";
|
|
|
|
}
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
public List<LocalImageInfo> Images
|
|
|
|
{
|
|
|
|
get => _images ??= new List<LocalImageInfo>();
|
|
|
|
set => _images = value;
|
|
|
|
}
|
2021-02-27 21:46:03 +00:00
|
|
|
|
2021-12-24 21:18:24 +00:00
|
|
|
public List<(string Url, ImageType Type)> RemoteImages
|
2021-05-23 22:30:41 +00:00
|
|
|
{
|
2021-12-24 21:18:24 +00:00
|
|
|
get => _remoteImages ??= new List<(string Url, ImageType Type)>();
|
2021-05-23 22:30:41 +00:00
|
|
|
set => _remoteImages = value;
|
|
|
|
}
|
2021-02-27 21:46:03 +00:00
|
|
|
|
|
|
|
public List<UserItemData> UserDataList { get; set; }
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public List<PersonInfo> People { get; set; }
|
|
|
|
|
|
|
|
public bool HasMetadata { get; set; }
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public T Item { get; set; }
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public string ResultLanguage { get; set; }
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public string Provider { get; set; }
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public bool QueriedById { get; set; }
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
public void AddPerson(PersonInfo p)
|
|
|
|
{
|
2021-05-05 11:51:14 +00:00
|
|
|
People ??= new List<PersonInfo>();
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
PeopleHelper.AddPerson(People, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Not only does this clear, but initializes the list so that services can differentiate between a null list and zero people.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
public void ResetPeople()
|
|
|
|
{
|
2022-12-05 14:00:20 +00:00
|
|
|
if (People is null)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
People = new List<PersonInfo>();
|
|
|
|
}
|
2021-05-05 11:51:14 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
People.Clear();
|
|
|
|
}
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public UserItemData GetOrAddUserData(string userId)
|
|
|
|
{
|
2021-05-05 11:51:14 +00:00
|
|
|
UserDataList ??= new List<UserItemData>();
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
UserItemData userData = null;
|
|
|
|
|
|
|
|
foreach (var i in UserDataList)
|
|
|
|
{
|
2019-02-28 22:22:57 +00:00
|
|
|
if (string.Equals(userId, i.UserId.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
userData = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-05 14:00:20 +00:00
|
|
|
if (userData is null)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
userData = new UserItemData()
|
|
|
|
{
|
|
|
|
UserId = new Guid(userId)
|
|
|
|
};
|
|
|
|
|
|
|
|
UserDataList.Add(userData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return userData;
|
|
|
|
}
|
|
|
|
}
|
2018-12-27 21:43:48 +00:00
|
|
|
}
|