mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-02 14:56:31 +01:00
display recording groups
This commit is contained in:
@@ -160,10 +160,30 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
return val.Value * 2;
|
||||
}
|
||||
|
||||
public string GetStatusName(RecordingStatus status)
|
||||
{
|
||||
if (status == RecordingStatus.InProgress)
|
||||
{
|
||||
return "In Progress";
|
||||
}
|
||||
|
||||
if (status == RecordingStatus.ConflictedNotOk)
|
||||
{
|
||||
return "Conflicted";
|
||||
}
|
||||
|
||||
if (status == RecordingStatus.ConflictedOk)
|
||||
{
|
||||
return "Scheduled";
|
||||
}
|
||||
|
||||
return status.ToString();
|
||||
}
|
||||
|
||||
public RecordingInfoDto GetRecordingInfoDto(LiveTvRecording recording, LiveTvChannel channel, ILiveTvService service, User user = null)
|
||||
{
|
||||
var info = recording.RecordingInfo;
|
||||
|
||||
|
||||
var dto = new RecordingInfoDto
|
||||
{
|
||||
Id = GetInternalRecordingId(service.Name, info.Id).ToString("N"),
|
||||
@@ -176,6 +196,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
ExternalId = info.Id,
|
||||
ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"),
|
||||
Status = info.Status,
|
||||
StatusName = GetStatusName(info.Status),
|
||||
Path = info.Path,
|
||||
Genres = info.Genres,
|
||||
IsRepeat = info.IsRepeat,
|
||||
@@ -219,7 +240,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
dto.ChannelName = channel.ChannelInfo.Name;
|
||||
}
|
||||
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -263,7 +284,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
public ProgramInfoDto GetProgramInfoDto(LiveTvProgram item, string channelName, User user = null)
|
||||
{
|
||||
var program = item.ProgramInfo;
|
||||
|
||||
|
||||
var dto = new ProgramInfoDto
|
||||
{
|
||||
Id = GetInternalProgramId(item.ServiceName, program.Id).ToString("N"),
|
||||
@@ -291,9 +312,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
IsNews = program.IsNews,
|
||||
IsKids = program.IsKids,
|
||||
IsPremiere = program.IsPremiere,
|
||||
RunTimeTicks = (program.EndDate - program.StartDate).Ticks
|
||||
RunTimeTicks = (program.EndDate - program.StartDate).Ticks,
|
||||
Type = "Program"
|
||||
};
|
||||
|
||||
var imageTag = GetImageTag(item);
|
||||
|
||||
if (imageTag.HasValue)
|
||||
{
|
||||
dto.ImageTags[ImageType.Primary] = imageTag.Value;
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, item.GetUserDataKey()));
|
||||
|
||||
@@ -448,15 +448,31 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
if (!string.IsNullOrEmpty(query.ChannelId))
|
||||
{
|
||||
var guid = new Guid(query.ChannelId);
|
||||
|
||||
var currentServiceName = service.Name;
|
||||
|
||||
list = list
|
||||
.Where(i => _tvDtoService.GetInternalChannelId(service.Name, i.ChannelId) == new Guid(query.ChannelId))
|
||||
.Where(i => _tvDtoService.GetInternalChannelId(currentServiceName, i.ChannelId) == guid)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.Id))
|
||||
{
|
||||
var guid = new Guid(query.Id);
|
||||
|
||||
var currentServiceName = service.Name;
|
||||
|
||||
list = list
|
||||
.Where(i => _tvDtoService.GetInternalRecordingId(service.Name, i.Id) == new Guid(query.Id))
|
||||
.Where(i => _tvDtoService.GetInternalRecordingId(currentServiceName, i.Id) == guid)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.GroupId))
|
||||
{
|
||||
var guid = new Guid(query.GroupId);
|
||||
|
||||
list = list.Where(i => GetRecordingGroupIds(i).Contains(guid))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -734,5 +750,118 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
await service.UpdateSeriesTimerAsync(info, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private List<string> GetRecordingGroupNames(RecordingInfo recording)
|
||||
{
|
||||
var list = new List<string>();
|
||||
|
||||
if (recording.IsSeries)
|
||||
{
|
||||
list.Add(recording.Name);
|
||||
}
|
||||
|
||||
if (recording.IsKids)
|
||||
{
|
||||
list.Add("Kids");
|
||||
}
|
||||
|
||||
if (recording.IsMovie)
|
||||
{
|
||||
list.Add("Movies");
|
||||
}
|
||||
|
||||
if (recording.IsNews)
|
||||
{
|
||||
list.Add("News");
|
||||
}
|
||||
|
||||
if (recording.IsPremiere)
|
||||
{
|
||||
list.Add("Sports");
|
||||
}
|
||||
|
||||
if (!recording.IsSports && !recording.IsNews && !recording.IsMovie && !recording.IsKids && !recording.IsSeries)
|
||||
{
|
||||
list.Add("Others");
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<Guid> GetRecordingGroupIds(RecordingInfo recording)
|
||||
{
|
||||
return GetRecordingGroupNames(recording).Select(i => i.ToLower()
|
||||
.GetMD5())
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public async Task<QueryResult<RecordingGroupDto>> GetRecordingGroups(RecordingGroupQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var recordingResult = await GetRecordings(new RecordingQuery
|
||||
{
|
||||
UserId = query.UserId
|
||||
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var recordings = recordingResult.Items;
|
||||
|
||||
var groups = new List<RecordingGroupDto>();
|
||||
|
||||
var series = recordings
|
||||
.Where(i => i.IsSeries)
|
||||
.ToLookup(i => i.Name, StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
groups.AddRange(series.OrderBy(i => i.Key).Select(i => new RecordingGroupDto
|
||||
{
|
||||
Name = i.Key,
|
||||
RecordingCount = i.Count()
|
||||
}));
|
||||
|
||||
groups.Add(new RecordingGroupDto
|
||||
{
|
||||
Name = "Kids",
|
||||
RecordingCount = recordings.Count(i => i.IsKids)
|
||||
});
|
||||
|
||||
groups.Add(new RecordingGroupDto
|
||||
{
|
||||
Name = "Movies",
|
||||
RecordingCount = recordings.Count(i => i.IsMovie)
|
||||
});
|
||||
|
||||
groups.Add(new RecordingGroupDto
|
||||
{
|
||||
Name = "News",
|
||||
RecordingCount = recordings.Count(i => i.IsNews)
|
||||
});
|
||||
|
||||
groups.Add(new RecordingGroupDto
|
||||
{
|
||||
Name = "Sports",
|
||||
RecordingCount = recordings.Count(i => i.IsSports)
|
||||
});
|
||||
|
||||
groups.Add(new RecordingGroupDto
|
||||
{
|
||||
Name = "Others",
|
||||
RecordingCount = recordings.Count(i => !i.IsSports && !i.IsNews && !i.IsMovie && !i.IsKids && !i.IsSeries)
|
||||
});
|
||||
|
||||
groups = groups
|
||||
.Where(i => i.RecordingCount > 0)
|
||||
.ToList();
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
group.Id = group.Name.ToLower().GetMD5().ToString("N");
|
||||
}
|
||||
|
||||
return new QueryResult<RecordingGroupDto>
|
||||
{
|
||||
Items = groups.ToArray(),
|
||||
TotalRecordCount = groups.Count
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user