ChannelVideoItem.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Model.Channels;
  3. using MediaBrowser.Model.Configuration;
  4. using MediaBrowser.Model.Dto;
  5. using MediaBrowser.Model.Entities;
  6. using System.Collections.Generic;
  7. using System.Globalization;
  8. using System.Linq;
  9. namespace MediaBrowser.Controller.Channels
  10. {
  11. public class ChannelVideoItem : Video, IChannelMediaItem
  12. {
  13. public static IChannelManager ChannelManager { get; set; }
  14. public string ExternalId { get; set; }
  15. public string ChannelId { get; set; }
  16. public ChannelItemType ChannelItemType { get; set; }
  17. public bool IsInfiniteStream { get; set; }
  18. public ChannelMediaContentType ContentType { get; set; }
  19. public string OriginalImageUrl { get; set; }
  20. public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
  21. public override string GetUserDataKey()
  22. {
  23. if (ContentType == ChannelMediaContentType.Trailer)
  24. {
  25. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  26. if (!string.IsNullOrWhiteSpace(key))
  27. {
  28. key = key + "-trailer";
  29. // Make sure different trailers have their own data.
  30. if (RunTimeTicks.HasValue)
  31. {
  32. key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
  33. }
  34. return key;
  35. }
  36. }
  37. return ExternalId;
  38. }
  39. protected override bool GetBlockUnratedValue(UserConfiguration config)
  40. {
  41. return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
  42. }
  43. public override bool SupportsLocalMetadata
  44. {
  45. get
  46. {
  47. return false;
  48. }
  49. }
  50. public ChannelVideoItem()
  51. {
  52. ChannelMediaSources = new List<ChannelMediaInfo>();
  53. }
  54. public override LocationType LocationType
  55. {
  56. get
  57. {
  58. if (string.IsNullOrEmpty(Path))
  59. {
  60. return LocationType.Remote;
  61. }
  62. return base.LocationType;
  63. }
  64. }
  65. public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  66. {
  67. var list = base.GetMediaSources(enablePathSubstitution).ToList();
  68. list.InsertRange(0, ChannelManager.GetCachedChannelItemMediaSources(Id.ToString("N")));
  69. return list;
  70. }
  71. }
  72. }