2018-12-28 00:27:57 +01:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using MediaBrowser.Model.Extensions;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class Extensions
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Extensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the trailer URL.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void AddTrailerUrl(this BaseItem item, string url)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
2019-01-06 21:50:43 +01:00
|
|
|
|
throw new ArgumentNullException(nameof(url));
|
2018-12-28 00:27:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (current == null)
|
|
|
|
|
{
|
|
|
|
|
var mediaUrl = new MediaUrl
|
|
|
|
|
{
|
|
|
|
|
Url = url
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.RemoteTrailers.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
item.RemoteTrailers = new[] { mediaUrl };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-12-28 16:48:26 +01:00
|
|
|
|
item.RemoteTrailers = item.RemoteTrailers.Concat(new [] { mediaUrl }).ToArray();
|
2018-12-28 00:27:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|