update series timer editor

This commit is contained in:
Luke Pulverenti 2016-10-01 03:06:00 -04:00
parent 229172da50
commit 3f77a9a8a2
9 changed files with 120 additions and 16 deletions

View File

@ -243,11 +243,7 @@ namespace MediaBrowser.Api
hasBudget.Revenue = request.Revenue; hasBudget.Revenue = request.Revenue;
} }
var hasOriginalTitle = item as IHasOriginalTitle; item.OriginalTitle = string.IsNullOrWhiteSpace(request.OriginalTitle) ? null : request.OriginalTitle;
if (hasOriginalTitle != null)
{
hasOriginalTitle.OriginalTitle = hasOriginalTitle.OriginalTitle;
}
var hasCriticRating = item as IHasCriticRating; var hasCriticRating = item as IHasCriticRating;
if (hasCriticRating != null) if (hasCriticRating != null)

View File

@ -386,6 +386,8 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableUserData { get; set; } public bool? EnableUserData { get; set; }
public string SeriesTimerId { get; set; }
/// <summary> /// <summary>
/// Fields to return within the items, in addition to basic information /// Fields to return within the items, in addition to basic information
/// </summary> /// </summary>
@ -985,6 +987,7 @@ namespace MediaBrowser.Api.LiveTv
query.IsSeries = request.IsSeries; query.IsSeries = request.IsSeries;
query.IsKids = request.IsKids; query.IsKids = request.IsKids;
query.IsSports = request.IsSports; query.IsSports = request.IsSports;
query.SeriesTimerId = request.SeriesTimerId;
query.Genres = (request.Genres ?? String.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); query.Genres = (request.Genres ?? String.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var result = await _liveTvManager.GetPrograms(query, GetDtoOptions(request), CancellationToken.None).ConfigureAwait(false); var result = await _liveTvManager.GetPrograms(query, GetDtoOptions(request), CancellationToken.None).ConfigureAwait(false);

View File

@ -256,7 +256,10 @@ namespace MediaBrowser.Controller.Entities
} }
[IgnoreDataMember] [IgnoreDataMember]
public string ExternalSeriesId public string ExternalSeriesId { get; set; }
[IgnoreDataMember]
public string ExternalSeriesIdLegacy
{ {
get { return this.GetProviderId("ProviderExternalSeriesId"); } get { return this.GetProviderId("ProviderExternalSeriesId"); }
set set

View File

@ -139,6 +139,7 @@ namespace MediaBrowser.Controller.Entities
public DayOfWeek[] AirDays { get; set; } public DayOfWeek[] AirDays { get; set; }
public SeriesStatus[] SeriesStatuses { get; set; } public SeriesStatus[] SeriesStatuses { get; set; }
public string AlbumArtistStartsWithOrGreater { get; set; } public string AlbumArtistStartsWithOrGreater { get; set; }
public string ExternalSeriesId { get; set; }
public string[] AlbumNames { get; set; } public string[] AlbumNames { get; set; }
public string[] ArtistNames { get; set; } public string[] ArtistNames { get; set; }

View File

@ -27,6 +27,8 @@ namespace MediaBrowser.Controller.LiveTv
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
public string ServiceName { get; set; }
/// <summary> /// <summary>
/// Description of the recording. /// Description of the recording.
/// </summary> /// </summary>

View File

@ -339,12 +339,9 @@ namespace MediaBrowser.Dlna.Main
if (_Publisher != null) if (_Publisher != null)
{ {
var devices = _Publisher.Devices.ToList(); var devices = _Publisher.Devices.ToList();
var tasks = devices.Select(i => _Publisher.RemoveDevice(i)).ToArray();
foreach (var device in devices) Task.WaitAll(tasks);
{
var task = _Publisher.RemoveDevice(device);
Task.WaitAll(task);
}
//foreach (var device in devices) //foreach (var device in devices)
//{ //{
// try // try

View File

@ -41,6 +41,7 @@ namespace MediaBrowser.Model.LiveTv
/// </summary> /// </summary>
/// <value>The user identifier.</value> /// <value>The user identifier.</value>
public string UserId { get; set; } public string UserId { get; set; }
public string SeriesTimerId { get; set; }
/// <summary> /// <summary>
/// The earliest date for which a program starts to return /// The earliest date for which a program starts to return

View File

@ -565,6 +565,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}; };
} }
var seriesId = info.SeriesId;
if (string.IsNullOrWhiteSpace(seriesId) && info.IsSeries)
{
seriesId = info.Name.GetMD5().ToString("N");
}
if (!item.ParentId.Equals(channel.Id)) if (!item.ParentId.Equals(channel.Id))
{ {
forceUpdate = true; forceUpdate = true;
@ -584,7 +590,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
item.EpisodeTitle = info.EpisodeTitle; item.EpisodeTitle = info.EpisodeTitle;
item.ExternalId = info.Id; item.ExternalId = info.Id;
item.ExternalSeriesId = info.SeriesId; item.ExternalSeriesIdLegacy = seriesId;
if (!string.IsNullOrWhiteSpace(seriesId) && !string.Equals(item.ExternalSeriesId, seriesId, StringComparison.Ordinal))
{
forceUpdate = true;
}
item.ExternalSeriesId = seriesId;
item.Genres = info.Genres; item.Genres = info.Genres;
item.IsHD = info.IsHD; item.IsHD = info.IsHD;
item.IsKids = info.IsKids; item.IsKids = info.IsKids;
@ -825,7 +838,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user); var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user);
var list = new List<Tuple<BaseItemDto, string, string, string>>(); var list = new List<Tuple<BaseItemDto, string, string, string>>();
list.Add(new Tuple<BaseItemDto, string, string, string>(dto, program.ServiceName, program.ExternalId, program.ExternalSeriesId)); list.Add(new Tuple<BaseItemDto, string, string, string>(dto, program.ServiceName, program.ExternalId, program.ExternalSeriesIdLegacy));
await AddRecordingInfo(list, cancellationToken).ConfigureAwait(false); await AddRecordingInfo(list, cancellationToken).ConfigureAwait(false);
@ -866,6 +879,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv
TopParentIds = new[] { topFolder.Id.ToString("N") } TopParentIds = new[] { topFolder.Id.ToString("N") }
}; };
if (!string.IsNullOrWhiteSpace(query.SeriesTimerId))
{
var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery {}, cancellationToken).ConfigureAwait(false);
var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.ServiceName, i.Id).ToString("N"), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
if (seriesTimer != null)
{
internalQuery.ExternalSeriesId = seriesTimer.SeriesId;
if (string.IsNullOrWhiteSpace(seriesTimer.SeriesId))
{
// Better to return nothing than every program in the database
return new QueryResult<BaseItemDto>();
}
}
else
{
// Better to return nothing than every program in the database
return new QueryResult<BaseItemDto>();
}
}
if (query.HasAired.HasValue) if (query.HasAired.HasValue)
{ {
if (query.HasAired.Value) if (query.HasAired.Value)
@ -1730,7 +1764,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
dto.ServiceName = serviceName; dto.ServiceName = serviceName;
} }
recordingTuples.Add(new Tuple<BaseItemDto, string, string, string>(dto, serviceName, program.ExternalId, program.ExternalSeriesId)); recordingTuples.Add(new Tuple<BaseItemDto, string, string, string>(dto, serviceName, program.ExternalId, program.ExternalSeriesIdLegacy));
} }
await AddRecordingInfo(recordingTuples, CancellationToken.None).ConfigureAwait(false); await AddRecordingInfo(recordingTuples, CancellationToken.None).ConfigureAwait(false);
@ -2005,6 +2039,56 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase));
} }
private async Task<QueryResult<SeriesTimerInfo>> GetSeriesTimersInternal(SeriesTimerQuery query, CancellationToken cancellationToken)
{
var tasks = _services.Select(async i =>
{
try
{
var recs = await i.GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
return recs.Select(r =>
{
r.ServiceName = i.Name;
return new Tuple<SeriesTimerInfo, ILiveTvService>(r, i);
});
}
catch (Exception ex)
{
_logger.ErrorException("Error getting recordings", ex);
return new List<Tuple<SeriesTimerInfo, ILiveTvService>>();
}
});
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
var timers = results.SelectMany(i => i.ToList());
if (string.Equals(query.SortBy, "Priority", StringComparison.OrdinalIgnoreCase))
{
timers = query.SortOrder == SortOrder.Descending ?
timers.OrderBy(i => i.Item1.Priority).ThenByStringDescending(i => i.Item1.Name) :
timers.OrderByDescending(i => i.Item1.Priority).ThenByString(i => i.Item1.Name);
}
else
{
timers = query.SortOrder == SortOrder.Descending ?
timers.OrderByStringDescending(i => i.Item1.Name) :
timers.OrderByString(i => i.Item1.Name);
}
var returnArray = timers
.Select(i =>
{
return i.Item1;
})
.ToArray();
return new QueryResult<SeriesTimerInfo>
{
Items = returnArray,
TotalRecordCount = returnArray.Length
};
}
public async Task<QueryResult<SeriesTimerInfoDto>> GetSeriesTimers(SeriesTimerQuery query, CancellationToken cancellationToken) public async Task<QueryResult<SeriesTimerInfoDto>> GetSeriesTimers(SeriesTimerQuery query, CancellationToken cancellationToken)
{ {
var tasks = _services.Select(async i => var tasks = _services.Select(async i =>

View File

@ -270,6 +270,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID"); _connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID");
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID"); _connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID");
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesSortName", "Text"); _connection.AddColumn(Logger, "TypedBaseItems", "SeriesSortName", "Text");
_connection.AddColumn(Logger, "TypedBaseItems", "ExternalSeriesId", "Text");
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT"); _connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text"); _connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
@ -413,7 +414,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"SeriesSortName", "SeriesSortName",
"PresentationUniqueKey", "PresentationUniqueKey",
"InheritedParentalRatingValue", "InheritedParentalRatingValue",
"InheritedTags" "InheritedTags",
"ExternalSeriesId"
}; };
private readonly string[] _mediaStreamSaveColumns = private readonly string[] _mediaStreamSaveColumns =
@ -535,7 +537,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"SeasonName", "SeasonName",
"SeasonId", "SeasonId",
"SeriesId", "SeriesId",
"SeriesSortName" "SeriesSortName",
"ExternalSeriesId"
}; };
_saveItemCommand = _connection.CreateCommand(); _saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values ("; _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@ -975,6 +978,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = null; _saveItemCommand.GetParameter(index++).Value = null;
} }
_saveItemCommand.GetParameter(index++).Value = item.ExternalSeriesId;
_saveItemCommand.Transaction = transaction; _saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery(); _saveItemCommand.ExecuteNonQuery();
@ -1466,6 +1471,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
index++; index++;
if (!reader.IsDBNull(index))
{
item.ExternalSeriesId = reader.GetString(index);
}
index++;
return item; return item;
} }
@ -2852,6 +2863,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@MinSortName", DbType.String).Value = query.MinSortName; cmd.Parameters.Add(cmd, "@MinSortName", DbType.String).Value = query.MinSortName;
} }
if (!string.IsNullOrWhiteSpace(query.ExternalSeriesId))
{
whereClauses.Add("ExternalSeriesId=@ExternalSeriesId");
cmd.Parameters.Add(cmd, "@ExternalSeriesId", DbType.String).Value = query.ExternalSeriesId;
}
if (!string.IsNullOrWhiteSpace(query.Name)) if (!string.IsNullOrWhiteSpace(query.Name))
{ {
whereClauses.Add("CleanName=@Name"); whereClauses.Add("CleanName=@Name");