Browse Source

added HasImage to live tv objects

Luke Pulverenti 11 years ago
parent
commit
2884920f0f

+ 2 - 0
MediaBrowser.Controller/LiveTv/Channel.cs

@@ -50,6 +50,8 @@ namespace MediaBrowser.Controller.LiveTv
         /// <value>The type of the channel.</value>
         public ChannelType ChannelType { get; set; }
 
+        public bool? HasProviderImage { get; set; }
+        
         protected override string CreateSortName()
         {
             double number = 0;

+ 6 - 0
MediaBrowser.Controller/LiveTv/ChannelInfo.cs

@@ -30,5 +30,11 @@ namespace MediaBrowser.Controller.LiveTv
         /// </summary>
         /// <value>The type of the channel.</value>
         public ChannelType ChannelType { get; set; }
+
+        /// <summary>
+        /// Set this value to true or false if it is known via channel info whether there is an image or not.
+        /// Leave it null if the only way to determine is by requesting the image and handling the failure.
+        /// </summary>
+        public bool? HasImage { get; set; }
     }
 }

+ 6 - 0
MediaBrowser.Controller/LiveTv/ProgramInfo.cs

@@ -90,6 +90,12 @@ namespace MediaBrowser.Controller.LiveTv
         /// </summary>
         /// <value>The episode title.</value>
         public string EpisodeTitle { get; set; }
+
+        /// <summary>
+        /// Set this value to true or false if it is known via program info whether there is an image or not.
+        /// Leave it null if the only way to determine is by requesting the image and handling the failure.
+        /// </summary>
+        public bool? HasImage { get; set; }
         
         public ProgramInfo()
         {

+ 6 - 0
MediaBrowser.Controller/LiveTv/RecordingInfo.cs

@@ -107,6 +107,12 @@ namespace MediaBrowser.Controller.LiveTv
         /// <value>The community rating.</value>
         public float? CommunityRating { get; set; }
 
+        /// <summary>
+        /// Set this value to true or false if it is known via recording info whether there is an image or not.
+        /// Leave it null if the only way to determine is by requesting the image and handling the failure.
+        /// </summary>
+        public bool? HasImage { get; set; }
+
         public RecordingInfo()
         {
             Genres = new List<string>();

+ 13 - 9
MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs

@@ -44,20 +44,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 return true;
             }
 
-            try
-            {
-                await DownloadImage(item, cancellationToken).ConfigureAwait(false);
-            }
-            catch (HttpException ex)
+            var channel = (Channel)item;
+
+            if (channel.HasProviderImage ?? true)
             {
-                // Don't fail the provider on a 404
-                if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
+                try
                 {
-                    throw;
+                    await DownloadImage(item, cancellationToken).ConfigureAwait(false);
+                }
+                catch (HttpException ex)
+                {
+                    // Don't fail the provider on a 404
+                    if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
+                    {
+                        throw;
+                    }
                 }
             }
 
-
             SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
             return true;
         }

+ 2 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -269,7 +269,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                     Path = path,
                     ChannelId = channelInfo.Id,
                     ChannelNumber = channelInfo.Number,
-                    ServiceName = serviceName
+                    ServiceName = serviceName,
+                    HasProviderImage = channelInfo.HasImage
                 };
 
                 isNew = true;