You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Entities/Extensions.cs

52 lines
1.5 KiB

using MediaBrowser.Model.Entities;
using System;
using System.Linq;
namespace MediaBrowser.Controller.Entities
{
public static class Extensions
{
/// <summary>
/// Adds the tagline.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tagline">The tagline.</param>
/// <exception cref="System.ArgumentNullException">tagline</exception>
public static void AddTagline(this BaseItem item, string tagline)
{
if (string.IsNullOrWhiteSpace(tagline))
{
throw new ArgumentNullException("tagline");
}
if (!item.Taglines.Contains(tagline, StringComparer.OrdinalIgnoreCase))
{
item.Taglines.Add(tagline);
}
}
public static void AddTrailerUrl(this BaseItem item, string url, bool isDirectLink)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException("url");
}
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
if (current != null)
{
current.IsDirectLink = isDirectLink;
}
else
{
item.RemoteTrailers.Add(new MediaUrl
{
Url = url,
IsDirectLink = isDirectLink
});
}
}
}
}