Browse Source

add tuner infos to tv service status

Luke Pulverenti 11 năm trước cách đây
mục cha
commit
9b370d904f

+ 62 - 0
MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs

@@ -1,4 +1,5 @@
 using MediaBrowser.Model.LiveTv;
+using System.Collections.Generic;
 
 namespace MediaBrowser.Controller.LiveTv
 {
@@ -27,5 +28,66 @@ namespace MediaBrowser.Controller.LiveTv
         /// </summary>
         /// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>
         public bool HasUpdateAvailable { get; set; }
+
+        /// <summary>
+        /// Gets or sets the tuners.
+        /// </summary>
+        /// <value>The tuners.</value>
+        public List<LiveTvTunerInfo> Tuners { get; set; }
+
+        public LiveTvServiceStatusInfo()
+        {
+            Tuners = new List<LiveTvTunerInfo>();
+        }
+    }
+
+    public class LiveTvTunerInfo
+    {
+        /// <summary>
+        /// Gets or sets the type of the source.
+        /// </summary>
+        /// <value>The type of the source.</value>
+        public string SourceType { get; set; }
+
+        /// <summary>
+        /// Gets or sets the name.
+        /// </summary>
+        /// <value>The name.</value>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the identifier.
+        /// </summary>
+        /// <value>The identifier.</value>
+        public string Id { get; set; }
+
+        /// <summary>
+        /// Gets or sets the status.
+        /// </summary>
+        /// <value>The status.</value>
+        public LiveTvTunerStatus Status { get; set; }
+
+        /// <summary>
+        /// Gets or sets the channel identifier.
+        /// </summary>
+        /// <value>The channel identifier.</value>
+        public string ChannelId { get; set; }
+
+        /// <summary>
+        /// Gets or sets the timer identifier.
+        /// </summary>
+        /// <value>The timer identifier.</value>
+        public string TimerId { get; set; }
+
+        /// <summary>
+        /// Gets or sets the clients.
+        /// </summary>
+        /// <value>The clients.</value>
+        public List<string> Clients { get; set; }
+
+        public LiveTvTunerInfo()
+        {
+            Clients = new List<string>();
+        }
     }
 }

+ 8 - 0
MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs

@@ -103,4 +103,12 @@ namespace MediaBrowser.Model.LiveTv
         Ok = 0,
         Unavailable = 1
     }
+
+    public enum LiveTvTunerStatus
+    {
+        Available = 0,
+        Disabled = 1,
+        RecordingTv = 2,
+        LiveTv = 3
+    }
 }

+ 26 - 1
MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs

@@ -86,7 +86,10 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
 
                 if (options.DeleteEmptyFolders)
                 {
-                    DeleteEmptyFolders(path);
+                    foreach (var subfolder in GetDirectories(path).ToList())
+                    {
+                        DeleteEmptyFolders(subfolder);
+                    }
                 }
             }
 
@@ -99,6 +102,27 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
             progress.Report(100);
         }
 
+        /// <summary>
+        /// Gets the directories.
+        /// </summary>
+        /// <param name="path">The path.</param>
+        /// <returns>IEnumerable{System.String}.</returns>
+        private IEnumerable<string> GetDirectories(string path)
+        {
+            try
+            {
+                return Directory
+                    .EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly)
+                    .ToList();
+            }
+            catch (IOException ex)
+            {
+                _logger.ErrorException("Error getting files from {0}", ex, path);
+
+                return new List<string>();
+            }
+        }
+
         /// <summary>
         /// Gets the files to organize.
         /// </summary>
@@ -164,6 +188,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
                 {
                     try
                     {
+                        _logger.Debug("Deleting empty directory {0}", path);
                         Directory.Delete(path);
                     }
                     catch (UnauthorizedAccessException) { }