ChannelVideoItem.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 string ExternalId { get; set; }
  14. public string ChannelId { get; set; }
  15. public ChannelItemType ChannelItemType { get; set; }
  16. public bool IsInfiniteStream { get; set; }
  17. public ChannelMediaContentType ContentType { get; set; }
  18. public string OriginalImageUrl { get; set; }
  19. public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
  20. public override string GetUserDataKey()
  21. {
  22. if (ContentType == ChannelMediaContentType.Trailer)
  23. {
  24. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  25. if (!string.IsNullOrWhiteSpace(key))
  26. {
  27. key = key + "-trailer";
  28. // Make sure different trailers have their own data.
  29. if (RunTimeTicks.HasValue)
  30. {
  31. key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
  32. }
  33. return key;
  34. }
  35. }
  36. return ExternalId;
  37. }
  38. protected override bool GetBlockUnratedValue(UserConfiguration config)
  39. {
  40. return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
  41. }
  42. public override bool SupportsLocalMetadata
  43. {
  44. get
  45. {
  46. return false;
  47. }
  48. }
  49. public ChannelVideoItem()
  50. {
  51. ChannelMediaSources = new List<ChannelMediaInfo>();
  52. }
  53. public override LocationType LocationType
  54. {
  55. get
  56. {
  57. if (string.IsNullOrEmpty(Path))
  58. {
  59. return LocationType.Remote;
  60. }
  61. return base.LocationType;
  62. }
  63. }
  64. public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  65. {
  66. var list = base.GetMediaSources(enablePathSubstitution).ToList();
  67. list.InsertRange(0, ChannelManager.GetCachedChannelItemMediaSources(Id.ToString("N")));
  68. return list;
  69. }
  70. }
  71. }