diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 7ccb83bc8..319470554 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -309,6 +309,11 @@ namespace MediaBrowser.Api.LiveTv StatusMessage = activeServiceInfo == null ? null : activeServiceInfo.StatusMessage }; + info.EnabledUsers = _userManager.Users + .Where(i => i.Configuration.EnableLiveTvAccess && info.IsEnabled) + .Select(i => i.Id.ToString("N")) + .ToList(); + return ToOptimizedResult(info); } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 988b62002..3abbe500f 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -197,5 +197,13 @@ namespace MediaBrowser.Controller.LiveTv /// The cancellation token. /// Task. Task RecordLiveStream(string id, CancellationToken cancellationToken); + + /// + /// Resets the tuner. + /// + /// The identifier. + /// The cancellation token. + /// Task. + Task ResetTuner(string id, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index ba4726956..c306c7775 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -68,6 +68,7 @@ namespace MediaBrowser.Model.Configuration public bool BlockUnratedBooks { get; set; } public bool EnableLiveTvManagement { get; set; } + public bool EnableLiveTvAccess { get; set; } public bool EnableMediaPlayback { get; set; } @@ -82,6 +83,7 @@ namespace MediaBrowser.Model.Configuration EnableLiveTvManagement = true; EnableMediaPlayback = true; + EnableLiveTvAccess = true; } } } diff --git a/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs b/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs index d2d52f4aa..e01df6d94 100644 --- a/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs +++ b/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace MediaBrowser.Model.FileOrganization { @@ -81,6 +82,17 @@ namespace MediaBrowser.Model.FileOrganization /// /// The type. public FileOrganizerType Type { get; set; } + + /// + /// Gets or sets the duplicate paths. + /// + /// The duplicate paths. + public List DuplicatePaths { get; set; } + + public FileOrganizationResult() + { + DuplicatePaths = new List(); + } } public enum FileSortingStatus diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs index 8597f6720..38ce50a1b 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs @@ -80,6 +80,12 @@ namespace MediaBrowser.Model.LiveTv /// true if this instance is enabled; otherwise, false. public bool IsEnabled { get; set; } + /// + /// Gets or sets the enabled users. + /// + /// The enabled users. + public List EnabledUsers { get; set; } + /// /// Gets or sets the status. /// @@ -95,6 +101,7 @@ namespace MediaBrowser.Model.LiveTv public LiveTvInfo() { Services = new List(); + EnabledUsers = new List(); } } diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 4e27e4e9e..ece21df7a 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -162,6 +162,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { result.Status = FileSortingStatus.SkippedExisting; result.StatusMessage = string.Empty; + result.DuplicatePaths = otherDuplicatePaths; return; } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs index 4463ac6f3..86bf0d71c 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Data; using System.Globalization; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -48,8 +49,8 @@ namespace MediaBrowser.Server.Implementations.Persistence string[] queries = { - "create table if not exists organizationresults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber int null)", - "create index if not exists idx_organizationresults on organizationresults(ResultId)", + "create table if not exists OrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)", + "create index if not exists idx_OrganizerResults on OrganizerResults(ResultId)", //pragmas "pragma temp_store = memory", @@ -67,7 +68,7 @@ namespace MediaBrowser.Server.Implementations.Persistence private void PrepareStatements() { _saveResultCommand = _connection.CreateCommand(); - _saveResultCommand.CommandText = "replace into organizationresults (ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber) values (@ResultId, @OriginalPath, @TargetPath, @OrganizationDate, @Status, @OrganizationType, @StatusMessage, @ExtractedName, @ExtractedYear, @ExtractedSeasonNumber, @ExtractedEpisodeNumber, @ExtractedEndingEpisodeNumber)"; + _saveResultCommand.CommandText = "replace into OrganizerResults (ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (@ResultId, @OriginalPath, @TargetPath, @OrganizationDate, @Status, @OrganizationType, @StatusMessage, @ExtractedName, @ExtractedYear, @ExtractedSeasonNumber, @ExtractedEpisodeNumber, @ExtractedEndingEpisodeNumber, @DuplicatePaths)"; _saveResultCommand.Parameters.Add(_saveResultCommand, "@ResultId"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@OriginalPath"); @@ -81,14 +82,15 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveResultCommand.Parameters.Add(_saveResultCommand, "@ExtractedSeasonNumber"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@ExtractedEpisodeNumber"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@ExtractedEndingEpisodeNumber"); + _saveResultCommand.Parameters.Add(_saveResultCommand, "@DuplicatePaths"); _deleteResultCommand = _connection.CreateCommand(); - _deleteResultCommand.CommandText = "delete from organizationresults where ResultId = @ResultId"; + _deleteResultCommand.CommandText = "delete from OrganizerResults where ResultId = @ResultId"; _deleteResultCommand.Parameters.Add(_saveResultCommand, "@ResultId"); _deleteAllCommand = _connection.CreateCommand(); - _deleteAllCommand.CommandText = "delete from organizationresults"; + _deleteAllCommand.CommandText = "delete from OrganizerResults"; } public async Task SaveResult(FileOrganizationResult result, CancellationToken cancellationToken) @@ -120,6 +122,7 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveResultCommand.GetParameter(9).Value = result.ExtractedSeasonNumber; _saveResultCommand.GetParameter(10).Value = result.ExtractedEpisodeNumber; _saveResultCommand.GetParameter(11).Value = result.ExtractedEndingEpisodeNumber; + _saveResultCommand.GetParameter(12).Value = string.Join("|", result.DuplicatePaths.ToArray()); _saveResultCommand.Transaction = transaction; @@ -268,11 +271,11 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var cmd = _connection.CreateCommand()) { - cmd.CommandText = "SELECT ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber from organizationresults"; + cmd.CommandText = "SELECT ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from OrganizerResults"; if (query.StartIndex.HasValue && query.StartIndex.Value > 0) { - cmd.CommandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM organizationresults ORDER BY OrganizationDate desc LIMIT {0})", + cmd.CommandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM OrganizerResults ORDER BY OrganizationDate desc LIMIT {0})", query.StartIndex.Value.ToString(_usCulture)); } @@ -283,7 +286,7 @@ namespace MediaBrowser.Server.Implementations.Persistence cmd.CommandText += " LIMIT " + query.Limit.Value.ToString(_usCulture); } - cmd.CommandText += "; select count (ResultId) from organizationresults"; + cmd.CommandText += "; select count (ResultId) from OrganizerResults"; var list = new List(); var count = 0; @@ -320,7 +323,7 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var cmd = _connection.CreateCommand()) { - cmd.CommandText = "select ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber from organizationresults where ResultId=@Id"; + cmd.CommandText = "select ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from OrganizerResults where ResultId=@Id"; cmd.Parameters.Add(cmd, "@Id", DbType.Guid).Value = guid; @@ -389,6 +392,11 @@ namespace MediaBrowser.Server.Implementations.Persistence result.ExtractedEndingEpisodeNumber = reader.GetInt32(11); } + if (!reader.IsDBNull(12)) + { + result.DuplicatePaths = reader.GetString(12).Split('|').Where(i => !string.IsNullOrEmpty(i)).ToList(); + } + return result; }