2013-09-11 17:54:59 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
|
{
|
2013-09-13 15:04:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class Extensions
|
|
|
|
|
/// </summary>
|
2013-09-11 17:54:59 +00:00
|
|
|
|
public static class Extensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2013-09-13 15:04:19 +00:00
|
|
|
|
/// Adds the trailer URL.
|
2013-09-11 17:54:59 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2013-09-13 15:04:19 +00:00
|
|
|
|
/// <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-09-11 17:54:59 +00:00
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|