Extensions.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using MediaBrowser.Model.Entities;
  2. using System;
  3. using System.Linq;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. public static class Extensions
  7. {
  8. /// <summary>
  9. /// Adds the tagline.
  10. /// </summary>
  11. /// <param name="item">The item.</param>
  12. /// <param name="tagline">The tagline.</param>
  13. /// <exception cref="System.ArgumentNullException">tagline</exception>
  14. public static void AddTagline(this BaseItem item, string tagline)
  15. {
  16. if (string.IsNullOrWhiteSpace(tagline))
  17. {
  18. throw new ArgumentNullException("tagline");
  19. }
  20. if (!item.Taglines.Contains(tagline, StringComparer.OrdinalIgnoreCase))
  21. {
  22. item.Taglines.Add(tagline);
  23. }
  24. }
  25. public static void AddTrailerUrl(this BaseItem item, string url, bool isDirectLink)
  26. {
  27. if (string.IsNullOrWhiteSpace(url))
  28. {
  29. throw new ArgumentNullException("url");
  30. }
  31. var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
  32. if (current != null)
  33. {
  34. current.IsDirectLink = isDirectLink;
  35. }
  36. else
  37. {
  38. item.RemoteTrailers.Add(new MediaUrl
  39. {
  40. Url = url,
  41. IsDirectLink = isDirectLink
  42. });
  43. }
  44. }
  45. }
  46. }