From 9b370d904feb99fd39ff7a94fe84a13697db31f5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 22 Jan 2014 12:22:04 -0500 Subject: [PATCH] add tuner infos to tv service status --- .../LiveTv/LiveTvServiceStatusInfo.cs | 62 +++++++++++++++++++ .../LiveTv/LiveTvServiceInfo.cs | 8 +++ .../FileOrganization/TvFolderOrganizer.cs | 27 +++++++- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs b/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs index cc51075907..4159e5271b 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs +++ b/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 /// /// true if this instance has update available; otherwise, false. public bool HasUpdateAvailable { get; set; } + + /// + /// Gets or sets the tuners. + /// + /// The tuners. + public List Tuners { get; set; } + + public LiveTvServiceStatusInfo() + { + Tuners = new List(); + } + } + + public class LiveTvTunerInfo + { + /// + /// Gets or sets the type of the source. + /// + /// The type of the source. + public string SourceType { get; set; } + + /// + /// Gets or sets the name. + /// + /// The name. + public string Name { get; set; } + + /// + /// Gets or sets the identifier. + /// + /// The identifier. + public string Id { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public LiveTvTunerStatus Status { get; set; } + + /// + /// Gets or sets the channel identifier. + /// + /// The channel identifier. + public string ChannelId { get; set; } + + /// + /// Gets or sets the timer identifier. + /// + /// The timer identifier. + public string TimerId { get; set; } + + /// + /// Gets or sets the clients. + /// + /// The clients. + public List Clients { get; set; } + + public LiveTvTunerInfo() + { + Clients = new List(); + } } } diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs index b54369ef54..8597f67209 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs +++ b/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 + } } diff --git a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs index ad3208b771..6a413f2f04 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs +++ b/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); } + /// + /// Gets the directories. + /// + /// The path. + /// IEnumerable{System.String}. + private IEnumerable 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(); + } + } + /// /// Gets the files to organize. /// @@ -164,6 +188,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { try { + _logger.Debug("Deleting empty directory {0}", path); Directory.Delete(path); } catch (UnauthorizedAccessException) { }