mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-31 21:08:27 +01:00
improved performance of item counts
This commit is contained in:
51
MediaBrowser.Controller/Entities/Extensions.cs
Normal file
51
MediaBrowser.Controller/Entities/Extensions.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user