jellyfin-server/MediaBrowser.Controller/Entities/Extensions.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2013-09-11 17:54:59 +00:00
using MediaBrowser.Model.Entities;
using System;
using System.Linq;
namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// Class Extensions
/// </summary>
2013-09-11 17:54:59 +00:00
public static class Extensions
{
/// <summary>
/// Adds the trailer URL.
2013-09-11 17:54:59 +00:00
/// </summary>
/// <param name="item">The item.</param>
/// <param name="url">The URL.</param>
/// <param name="isDirectLink">if set to <c>true</c> [is direct link].</param>
/// <exception cref="System.ArgumentNullException">url</exception>
2013-12-02 16:46:25 +00:00
public static void AddTrailerUrl(this IHasTrailers item, string url, bool isDirectLink)
2013-09-11 17:54:59 +00:00
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException("url");
}
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
2014-09-22 21:56:54 +00:00
if (current == null)
2013-09-11 17:54:59 +00:00
{
item.RemoteTrailers.Add(new MediaUrl
{
2014-09-22 21:56:54 +00:00
Url = url
2013-09-11 17:54:59 +00:00
});
}
}
}
}