fixes #687 - Enable/disable live tv per user

This commit is contained in:
Luke Pulverenti 2014-01-23 16:09:00 -05:00
parent 2977a55b1b
commit 8e7b97db52
7 changed files with 52 additions and 9 deletions

View File

@ -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);
}

View File

@ -197,5 +197,13 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task RecordLiveStream(string id, CancellationToken cancellationToken);
/// <summary>
/// Resets the tuner.
/// </summary>
/// <param name="id">The identifier.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task ResetTuner(string id, CancellationToken cancellationToken);
}
}

View File

@ -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;
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.FileOrganization
{
@ -81,6 +82,17 @@ namespace MediaBrowser.Model.FileOrganization
/// </summary>
/// <value>The type.</value>
public FileOrganizerType Type { get; set; }
/// <summary>
/// Gets or sets the duplicate paths.
/// </summary>
/// <value>The duplicate paths.</value>
public List<string> DuplicatePaths { get; set; }
public FileOrganizationResult()
{
DuplicatePaths = new List<string>();
}
}
public enum FileSortingStatus

View File

@ -80,6 +80,12 @@ namespace MediaBrowser.Model.LiveTv
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
public bool IsEnabled { get; set; }
/// <summary>
/// Gets or sets the enabled users.
/// </summary>
/// <value>The enabled users.</value>
public List<string> EnabledUsers { get; set; }
/// <summary>
/// Gets or sets the status.
/// </summary>
@ -95,6 +101,7 @@ namespace MediaBrowser.Model.LiveTv
public LiveTvInfo()
{
Services = new List<LiveTvServiceInfo>();
EnabledUsers = new List<string>();
}
}

View File

@ -162,6 +162,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
{
result.Status = FileSortingStatus.SkippedExisting;
result.StatusMessage = string.Empty;
result.DuplicatePaths = otherDuplicatePaths;
return;
}

View File

@ -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<FileOrganizationResult>();
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;
}