mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
update series timer editor
This commit is contained in:
@@ -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))
|
||||
{
|
||||
forceUpdate = true;
|
||||
@@ -584,7 +590,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
item.EpisodeTitle = info.EpisodeTitle;
|
||||
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.IsHD = info.IsHD;
|
||||
item.IsKids = info.IsKids;
|
||||
@@ -825,7 +838,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user);
|
||||
|
||||
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);
|
||||
|
||||
@@ -866,6 +879,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
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.Value)
|
||||
@@ -1730,7 +1764,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
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);
|
||||
@@ -2005,6 +2039,56 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
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)
|
||||
{
|
||||
var tasks = _services.Select(async i =>
|
||||
|
||||
@@ -270,6 +270,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID");
|
||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID");
|
||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesSortName", "Text");
|
||||
_connection.AddColumn(Logger, "TypedBaseItems", "ExternalSeriesId", "Text");
|
||||
|
||||
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
||||
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
|
||||
@@ -413,7 +414,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"SeriesSortName",
|
||||
"PresentationUniqueKey",
|
||||
"InheritedParentalRatingValue",
|
||||
"InheritedTags"
|
||||
"InheritedTags",
|
||||
"ExternalSeriesId"
|
||||
};
|
||||
|
||||
private readonly string[] _mediaStreamSaveColumns =
|
||||
@@ -535,7 +537,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"SeasonName",
|
||||
"SeasonId",
|
||||
"SeriesId",
|
||||
"SeriesSortName"
|
||||
"SeriesSortName",
|
||||
"ExternalSeriesId"
|
||||
};
|
||||
_saveItemCommand = _connection.CreateCommand();
|
||||
_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 = item.ExternalSeriesId;
|
||||
|
||||
_saveItemCommand.Transaction = transaction;
|
||||
|
||||
_saveItemCommand.ExecuteNonQuery();
|
||||
@@ -1466,6 +1471,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
}
|
||||
index++;
|
||||
|
||||
if (!reader.IsDBNull(index))
|
||||
{
|
||||
item.ExternalSeriesId = reader.GetString(index);
|
||||
}
|
||||
index++;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -2852,6 +2863,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
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))
|
||||
{
|
||||
whereClauses.Add("CleanName=@Name");
|
||||
|
||||
Reference in New Issue
Block a user